Exemple #1
0
 def sites(self):
     """
     Returns information about the sites where MercadoLibre runs as JSON.
     """
     url = self.API_PREFIX_URL + endpoints.SITES
     response = get(url)
     return response
Exemple #2
0
 def sites(self):
     """
     Returns information about the sites where MercadoLibre runs as JSON.
     """
     url = self.API_PREFIX_URL + endpoints.SITES
     response = get(url)
     return response
Exemple #3
0
def collections_endpoint(url):
    """ Resource endpoint handler

    :param url: the url that led here

    .. versionchanged:: 0.0.7
       Using 'utils.request_method' helper function now.

    .. versionchanged:: 0.0.6
       Support for HEAD requests

    .. versionchanged:: 0.0.2
        Support for DELETE resource method.
    """

    resource = config.RESOURCES[url]
    response = None
    method = request_method()
    if method in ('GET', 'HEAD'):
        response = get(resource)
    elif method == 'POST':
        response = post(resource)
    elif method == 'DELETE':
        response = delete_resource(resource)
    elif method == 'OPTIONS':
        send_response(resource, response)
    else:
        abort(405)
    return send_response(resource, response)
Exemple #4
0
    def site_listing_prices(self, site_id, price, 
            listing_type_id=None, quantity=None, 
            category_id=None, currency_id=None
        ):
        """
        Lists the prices of listing items by different criteria

        @site_id: id of the request site, MPE (PERU)
        @price: price of the object, 500
        @listing_type_id: gold, premium, silver, bronce, free
        @quantity: amount of pulicid items, 5
        @category_id: , MLA1744
        @currency_id: USD(US dollars), PEN(Soles)

        @return: Returns the listing prices as JSON
        """
        url = self.API_PREFIX_URL + endpoints.SITE_LISTING_PRICES % {
            'site_id': site_id
        }

        # create query params
        params = {'price': price, 'listing_type_id': listing_type_id,
            'quantity': quantity, 'category_id': category_id, 
            'currency_id': currency_id
        }

        # erase fields with None
        utils.erase_none_values(params)

        response = get(url, params=params)
        return response
Exemple #5
0
 def currencies(self):
     """
     @return: Info of the currencies in MercadoLibre as JSON
     """
     url = self.API_PREFIX_URL + endpoints.CURRENCIES
     response = get(url)
     return response
Exemple #6
0
 def countries(self):
     """
     @return: Countries on MercadoLibre as JSON
     """
     url = self.API_PREFIX_URL + endpoints.COUNTRIES
     response = get(url)
     return response
Exemple #7
0
 def currencies(self):
     """
     @return: Info of the currencies in MercadoLibre as JSON
     """
     url = self.API_PREFIX_URL + endpoints.CURRENCIES
     response = get(url)
     return response
Exemple #8
0
 def countries(self):
     """
     @return: Countries on MercadoLibre as JSON
     """
     url = self.API_PREFIX_URL + endpoints.COUNTRIES
     response = get(url)
     return response
Exemple #9
0
def collections_endpoint(url):
    """ Resource endpoint handler

    :param url: the url that led here

    .. versionchanged:: 0.0.7
       Using 'utils.request_method' helper function now.

    .. versionchanged:: 0.0.6
       Support for HEAD requests

    .. versionchanged:: 0.0.2
        Support for DELETE resource method.
    """

    resource = config.RESOURCES[url]
    response = None
    method = request_method()
    if method in ('GET', 'HEAD'):
        response = get(resource)
    elif method == 'POST':
        response = post(resource)
    elif method == 'DELETE':
        response = delete_resource(resource)
    else:
        abort(405)
    return send_response(resource, response)
Exemple #10
0
 def site_detail(self, site_id):
     """
     @site_id: id of the request site, MPE (PERU)
     @return: Returns the detailed information of a site as JSON.
     """
     url = self.API_PREFIX_URL + endpoints.SITE_DETAIL % {
         'site_id': site_id
     }
     response = get(url)
     return response
Exemple #11
0
 def site_domains(self, site_domain_url):
     """
     @site_domain_url: www.mercadolibre.com.pe
     @returns: Information about specific domain as JSON
     """
     url = self.API_PREFIX_URL + endpoints.SITE_DOMAINS % {
         'site_domain_url': site_domain_url
     }
     response = get(url)
     return response
Exemple #12
0
 def site_listing_types(self, site_id):
     """
     @site_id: id of the request site, MPE (PERU)
     @return: Returns information about the listing types as JSON
     """
     url = self.API_PREFIX_URL + endpoints.SITE_LISTING_TYPES % {
         'site_id': site_id
     }
     response = get(url)
     return response
Exemple #13
0
 def site_detail(self, site_id):
     """
     @site_id: id of the request site, MPE (PERU)
     @return: Returns the detailed information of a site as JSON.
     """
     url = self.API_PREFIX_URL + endpoints.SITE_DETAIL % {
         'site_id': site_id
     }
     response = get(url)
     return response
Exemple #14
0
 def site_domains(self, site_domain_url):
     """
     @site_domain_url: www.mercadolibre.com.pe
     @returns: Information about specific domain as JSON
     """
     url = self.API_PREFIX_URL + endpoints.SITE_DOMAINS % {
         'site_domain_url': site_domain_url
     }
     response = get(url)
     return response
Exemple #15
0
 def site_listing_types(self, site_id):
     """
     @site_id: id of the request site, MPE (PERU)
     @return: Returns information about the listing types as JSON
     """
     url = self.API_PREFIX_URL + endpoints.SITE_LISTING_TYPES % {
         'site_id': site_id
     }
     response = get(url)
     return response
Exemple #16
0
    def currency_detail(self, currency_id):
        """
        @currency_id: PEN (Soles, Peru)...
        @return: Info of the given currency
        """
        url = self.API_PREFIX_URL + endpoints.CURRENCY_DETAIL % {
            'currency_id': currency_id
        }

        response = get(url)
        return response
Exemple #17
0
    def country_detail(self, country_id):
        """
        @country_id: PE(Peru), AR(Agentina)...
        @return: Detailed info of a country as JSON 
        """
        url = self.API_PREFIX_URL + endpoints.COUNTRY_DETAIL % {
            'country_id': country_id
        }

        response = get(url)
        return response
Exemple #18
0
    def city_detail(self, city_id):
        """
        @city_id: TVBFQ0FSRTE0YjA5 (Arequipa-Arequipa-Peru)
        @returns: Detailed info for the given city as JSON
        """
        url = self.API_PREFIX_URL + endpoints.CITY_DETAIL % {
            'city_id': city_id
        }

        response = get(url)
        return response
Exemple #19
0
    def state_detail(self, state_id):
        """
        @state_id: PE-ARE(Arequipa-Peru)...
        @return: Detailed info for given state as JSON
        """
        url = self.API_PREFIX_URL + endpoints.STATE_DETAIL % {
            'state_id': state_id
        }

        response = get(url)
        return response
Exemple #20
0
    def country_detail(self, country_id):
        """
        @country_id: PE(Peru), AR(Agentina)...
        @return: Detailed info of a country as JSON 
        """
        url = self.API_PREFIX_URL + endpoints.COUNTRY_DETAIL % {
            'country_id': country_id
        }

        response = get(url)
        return response
Exemple #21
0
    def state_detail(self, state_id):
        """
        @state_id: PE-ARE(Arequipa-Peru)...
        @return: Detailed info for given state as JSON
        """
        url = self.API_PREFIX_URL + endpoints.STATE_DETAIL % {
            'state_id': state_id
        }

        response = get(url)
        return response
Exemple #22
0
    def category_detail(self, category_id):
        """
        @category_id: MPE1182
        @returns Information of the category as JSON
        """
        url = self.API_PREFIX_URL + endpoints.CATEGORY_DETAIL % {
            'category_id': category_id
        }

        response = get(url)
        return response
Exemple #23
0
    def category_detail(self, category_id):
        """
        @category_id: MPE1182
        @returns Information of the category as JSON
        """
        url = self.API_PREFIX_URL + endpoints.CATEGORY_DETAIL % {
            'category_id': category_id
        }

        response = get(url)
        return response
Exemple #24
0
    def city_detail(self, city_id):
        """
        @city_id: TVBFQ0FSRTE0YjA5 (Arequipa-Arequipa-Peru)
        @returns: Detailed info for the given city as JSON
        """
        url = self.API_PREFIX_URL + endpoints.CITY_DETAIL % {
            'city_id': city_id
        }

        response = get(url)
        return response
Exemple #25
0
    def currency_detail(self, currency_id):
        """
        @currency_id: PEN (Soles, Peru)...
        @return: Info of the given currency
        """
        url = self.API_PREFIX_URL + endpoints.CURRENCY_DETAIL % {
            'currency_id': currency_id
        }

        response = get(url)
        return response
Exemple #26
0
    def site_categories(self, site_id):
        """
        @site_id: id of the request categories, MPE (PERU)
        @return: Returns the site categories as JSON.
        """
        url = self.API_PREFIX_URL + endpoints.SITE_CATEGORIES % {
            'site_id': site_id
        }

        response = get(url)
        return response
Exemple #27
0
    def site_categories(self, site_id):
        """
        @site_id: id of the request categories, MPE (PERU)
        @return: Returns the site categories as JSON.
        """
        url = self.API_PREFIX_URL + endpoints.SITE_CATEGORIES % {
            'site_id': site_id
        }

        response = get(url)
        return response
Exemple #28
0
    def currency_conversion(self, currency_id_from, currency_id_to):
        """
        @currency_id_from: currency to convert, PEN
        @currency_id_to: currency to convert to, USD
        @returns: Information about the conversion as JSON
        """
        url = self.API_PREFIX_URL + endpoints.CURRENCY_CONVERSION

        # create query params
        params = {'from': currency_id_from, 'to': currency_id_to}

        response = get(url, params=params)
        return response
Exemple #29
0
    def currency_conversion(self, currency_id_from, currency_id_to):
        """
        @currency_id_from: currency to convert, PEN
        @currency_id_to: currency to convert to, USD
        @returns: Information about the conversion as JSON
        """
        url = self.API_PREFIX_URL + endpoints.CURRENCY_CONVERSION

        # create query params
        params = { 'from': currency_id_from, 'to': currency_id_to }

        response = get(url, params=params)
        return response
Exemple #30
0
def collections_endpoint(url):
    """ Resource endpoint handler

    :param url: the url that led here

    .. versionadded:: 0.0.2
        Support for DELETE resource method.
    """

    resource = config.RESOURCES[url]
    response = None
    if request.method == 'GET':
        response = get(resource)
    elif request.method == 'POST':
        response = post(resource)
    elif request.method == 'DELETE':
        response = delete_resource(resource)
    return send_response(resource, response)
Exemple #31
0
def collections_endpoint(url):
    """ Resource endpoint handler

    :param url: the url that led here

    .. versionadded:: 0.0.2
        Support for DELETE resource method.
    """

    resource = config.RESOURCES[url]
    response = None
    if request.method == 'GET':
        response = get(resource)
    elif request.method == 'POST':
        response = post(resource)
    elif request.method == 'DELETE':
        response = delete_resource(resource)
    return send_response(resource, response)
Exemple #32
0
    def site_listing_exposures(self, site_id, listing_exposure_id=None):
        """
        Lisits the different exposures types on MercadoLibre

        @site_id: id of the request site, MPE (PERU)
        @listing_exposure_id: id of the exposure, low, mid, high...

        @return: Returns advertising exposures as JSON
        """
        url = self.API_PREFIX_URL + endpoints.SITE_LISTING_EXPOSURES % {
            'site_id': site_id
        }

        # adding exposure_id .../low
        if listing_exposure_id is not None:
            url += listing_exposure_id

        response = get(url)
        return response
Exemple #33
0
    def site_listing_exposures(self, site_id, listing_exposure_id=None):
        """
        Lisits the different exposures types on MercadoLibre

        @site_id: id of the request site, MPE (PERU)
        @listing_exposure_id: id of the exposure, low, mid, high...

        @return: Returns advertising exposures as JSON
        """
        url = self.API_PREFIX_URL + endpoints.SITE_LISTING_EXPOSURES % {
            'site_id': site_id
        }

        # adding exposure_id .../low 
        if listing_exposure_id is not None:
            url += listing_exposure_id

        response = get(url)
        return response
Exemple #34
0
    def site_listing_prices(self,
                            site_id,
                            price,
                            listing_type_id=None,
                            quantity=None,
                            category_id=None,
                            currency_id=None):
        """
        Lists the prices of listing items by different criteria

        @site_id: id of the request site, MPE (PERU)
        @price: price of the object, 500
        @listing_type_id: gold, premium, silver, bronce, free
        @quantity: amount of pulicid items, 5
        @category_id: , MLA1744
        @currency_id: USD(US dollars), PEN(Soles)

        @return: Returns the listing prices as JSON
        """
        url = self.API_PREFIX_URL + endpoints.SITE_LISTING_PRICES % {
            'site_id': site_id
        }

        # create query params
        params = {
            'price': price,
            'listing_type_id': listing_type_id,
            'quantity': quantity,
            'category_id': category_id,
            'currency_id': currency_id
        }

        # erase fields with None
        utils.erase_none_values(params)

        response = get(url, params=params)
        return response