def build_payload(url, params, type, **kwargs):
    """Build response payload for a request,
    pass parameters and optional parameters
    send external parameters for mapping and validation
    parse json like string
    return json object
    
    :type url: string
    :param url: request url
    
    :type params: string
    :param params: request parameters
    
    :type kwargs: string
    :param kwargs: optional request parameters
    
    :rtype: response json
    :return: Returns actual response payload from the webservice in the json format if success raises exception otherwise
    
    """
    # build  request parameters, set defaults, map external parameters
    transformed_params = rb.build_param_map(params, type)
    log.debug("Transformed_params: {0}".format(transformed_params))
    
    # execute a request by passing completely mapped and validated request parameters
    response = requests.get(url, params=transformed_params)
    log.debug("Response Text:")
    log.debug(response.text)
    
    # Raise exception and abort if requests is not successful
    response.raise_for_status()
    
    # convert received response (json like string) in a valid json object
    parsed_response = json.loads(response.text)
    return parsed_response
def loadMetabolites(url, params, type, **kwargs):
    """Build response payload for a request,
    pass parameters and optional parameters
    send external parameters for mapping and validation
    parse json like string
    return json object
    
    :type url: string
    :param url: request url
    
    :type params: string
    :param params: request parameters
    
    :type kwargs: string
    :param kwargs: optional request parameters
    
    :rtype: response json
    :return: Returns actual response payload: list of all metabolites for a given experiment ID, and platform ID from the webservice in the json format if success raises exception otherwise
    
    """
    # build  request parameters, set defaults, map external parameters
    transformed_params = rb.build_param_map(params, type)
    log.debug("Transformed_params: {0}".format(transformed_params))

    # execute a request by passing completely mapped and validated request parameters
    response = requests.get(url, params=transformed_params)
    log.debug("Response Text:")
    log.debug(response.text)

    # Raise exception and abort if requests is not successful
    response.raise_for_status()

    metabolites = json.loads(response.text, object_hook=lambda x: ml.Metabolite(**x))

    return metabolites
def main():
    """test logic for when running this module as the primary one!"""

    ## pass the namespace you test again (your dev namespace or production namespace)
    test_namespace = 'ibelyaev-dev'

    #search test case
    args = {'experimentID': '106', 'platformID':'84', 'metaboliteID':'4349', '_url': 'https://api.araport.org/community/v0.3', '_namespace': test_namespace}
    driver.search(args)
    param_map = rb.build_param_map(args, 'search')
    log.info("Param Map:")
    log.info(param_map)

    # list test case
    args = {'experimentID': '106', 'platformID':'84', '_url': 'https://api.araport.org/community/v0.3', '_namespace': test_namespace}
    driver.list(args)
    param_map = rb.build_param_map(args, 'list')
    log.info("Param Map:")
    log.info(param_map)
def loadPlatforms(url, params, request_type, **kwargs):
    """Build response payload for a request,
    pass parameters and optional parameters
    send external parameters for mapping and validation
    parse json like string
    return json object
    
    :type url: string
    :param url: request url
    
    :type params: string
    :param params: request parameters
    
    :type kwargs: string
    :param kwargs: optional request parameters
    
    :rtype: response json
    :return: Returns actual response payload: list of all platforms for a given experiment ID from the webservice in the json format if success raises exception otherwise
    
    """
    
    # build  request parameters, set defaults, map external parameters
    transformed_params = rb.build_param_map(params, request_type)
    log.debug("Transformed_params: {0}".format(transformed_params))
    
    # execute a request by passing completely mapped and validated request parameters
    response = requests.get(url, params=transformed_params)
    log.debug("Response Text:")
    log.debug(response.text)
    
    # Raise exception and abort if requests is not successful
    response.raise_for_status()

    try:
        platforms = json.loads(response.text, object_hook=lambda x: pl.Platform(**x))
    except Exception as e:
            error_msg = "There are no information of experiments for a experimentID submitted!"
            raise exception.NotFound(error_msg)

    return platforms