Exemplo n.º 1
0
def GetCategory(opts):
    # Toys : 220

    try:
        api = trading(debug=opts.debug,
                      appid=opts.appid,
                      config_file=opts.yaml,
                      warnings=True)

        # Include a function to exclude all special characters here
        api_request = {
            'CategoryParent': 220,
            'LevelLimit': 4,
            'ViewAllNodes': 'False',
            'DetailLevel': 'ReturnAll'
        }

        response = api.execute('GetCategories', api_request)

        dump(api)

        return response.dict()

    except ConnectionError as e:
        print(e)
        print(e.response.dict())
Exemplo n.º 2
0
def connect_api():
    global trading_api, finding_api, shopping_api
    trading_api = trading(
        config_file="ebay.yaml",
        siteid=77,
        token="AgAAAA**AQAAAA**aAAAAA**gNoiVA**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wJkYWoDpmGqA2dj6x9nY+seQ**PXkCAA**AAMAAA**hzDKea9fTGWVfQz6a+ULxm8p20w2dRegRC1r3fy5UQjAbb/gQc7m76reGs4JHLA8/Dq6hdxVx6kNmP/78rG9ii4NXu3UIjyFPDA2G4Yg+BMZ7BfDdCVgBPtigPhrrf6GJxTQF/yP0nWbFW0hDN6ZwFURMEcFXazayEUbqNDD9V0zj35Z1X7WE3xV8tnph37SDZDhplGC1ha3MjcDRZqZURhz74TxmH1nugJ9pSsjY7GsDvmVgFk0BP/AFgA8jOXiA6avHSAzWstY9AK/Pxmcj5fO3Df+w5WYrjnNMPZcwPMyFeb+oAxABG8KkYmKbWmh/D57JVHn0G6J2tEysCQMUXUZa8VxbP9noKjmIADhmYh6pjx7PzAtjB0feAdFOb9BGmVeczGgYJrMaBhujrwPB9beaC6d1EuUnw4dON/RJqHWRq9ecQkAMsVB5+eki+/HS0LA4ZVA01FaMW6QlgNRefwj5fAJbv20mggfYx5dA+e8STAmk05ThzUktiaRzHxZEtIiVsf3xqZkSFfCZVpFskdWsBb+ifLYpjEAf+KG+56zijYC50HOP+oTcVqfUcQ9EaBZyiS6+VrYR2KVkGiVGNWyOdY56Y7Q7yJfhMxMi2YAxEFyhPZt6qVg02Ka6ubV0Mcm6Xn1jq02XUzkq3+Q0QMYV2D37MGYxaq0qVCfvp3l6GuY+hZ1S7z9BPu2uXDC8h0t+JurlSveX+/2cj+2loCX+nneCgikupnwrmZCFbqV4jmX36qrIDbE7KU2d7TE",
    )
    finding_api = finding(config_file="ebay.yaml", siteid="EBAY-DE")
    shopping_api = shopping(config_file="ebay.yaml", siteid=77)
 def api(self):
     api = None
     if self.method in _EBAY_TRADING_METHOD_LIST.keys():
         api = trading(config_file=None,
                       appid=self._backend.client_id,
                       devid=self._backend.dev_id,
                       certid=self._backend.client_secret,
                       token=self._backend.token)
         self.method = _EBAY_TRADING_METHOD_LIST[self.method]
     self._api = api
     return self._api
Exemplo n.º 4
0
    def __init__(self, **kwargs):
        """Initialization method.

        Parameters
        ----------
        sandbox : boolean
        see Ebay class

        Returns
        -------
        New instance of :class:`Trading` : Trading

        Examples
        --------
        >>> trading = Trading(sandbox=True)
        >>> trading  #doctest: +ELLIPSIS
        <app.api.Trading object at 0x...>
        >>> trading.api.config.values['siteid'] == '0'
        True
        >>> trading = Trading(sandbox=True, country='UK')
        >>> trading.api.config.values['siteid'] == '3'
        True
        """
        super(Trading, self).__init__(**kwargs)

        # for travis.ci since the token is too large for travis encrypt
        env_file = 'envs.yml'

        if self.sandbox:
            domain = 'api.sandbox.ebay.com'
            certid = kwargs.get('certid', getenv('EBAY_SB_CERT_ID'))
            token = kwargs.get('token', getenv('EBAY_SB_TOKEN'))
            token = (token or getenv_from_file('EBAY_SB_TOKEN', env_file))
        else:
            domain = 'api.ebay.com'
            certid = kwargs.get('certid', getenv('EBAY_LIVE_CERT_ID'))
            token = kwargs.get('token', getenv('EBAY_LIVE_TOKEN'))
            token = (token or getenv_from_file('EBAY_LIVE_TOKEN', env_file))

        # TODO: add KeyError exception handling
        new = {
            'siteid': self.global_ids[self.kwargs['country']]['countryid'],
            'domain': domain,
            'certid': certid,
            'token': token,
            'version': '861',
            'compatibility': '861',
        }

        self.kwargs.update(new)
        self.api = trading(**self.kwargs)
Exemplo n.º 5
0
    def __init__(self, **kwargs):
        """Initialization method.

        Parameters
        ----------
        sandbox : boolean
        see Ebay class

        Returns
        -------
        New instance of :class:`Trading` : Trading

        Examples
        --------
        >>> trading = Trading(sandbox=True)
        >>> trading  #doctest: +ELLIPSIS
        <app.api.Trading object at 0x...>
        >>> trading.api.config.values['siteid'] == '0'
        True
        >>> trading = Trading(sandbox=True, country='UK')
        >>> trading.api.config.values['siteid'] == '3'
        True
        """
        super(Trading, self).__init__(**kwargs)

        # for travis.ci since the token is too large for travis encrypt
        env_file = 'envs.yml'

        if self.sandbox:
            domain = 'api.sandbox.ebay.com'
            certid = kwargs.get('certid', getenv('EBAY_SB_CERT_ID'))
            token = kwargs.get('token', getenv('EBAY_SB_TOKEN'))
            token = (token or getenv_from_file('EBAY_SB_TOKEN', env_file))
        else:
            domain = 'api.ebay.com'
            certid = kwargs.get('certid', getenv('EBAY_LIVE_CERT_ID'))
            token = kwargs.get('token', getenv('EBAY_LIVE_TOKEN'))
            token = (token or getenv_from_file('EBAY_LIVE_TOKEN', env_file))

        # TODO: add KeyError exception handling
        new = {
            'siteid': self.global_ids[self.kwargs['country']]['countryid'],
            'domain': domain,
            'certid': certid,
            'token': token,
            'version': '861',
            'compatibility': '861',
        }

        self.kwargs.update(new)
        self.api = trading(**self.kwargs)
Exemplo n.º 6
0
    def __init__(self, module, endpoint, payload, returnDictOnly=True):
        mods = {
            'Trading':  trading(appid=APPID, devid=DEVID, certid=CERTID, token=TOKEN, config_file=None)
        }
        try:
            api = mods.get(module)
            response = api.execute(endpoint, json.loads(payload))

            if(returnDictOnly):
                print(json.dumps(response.dict()))
            else:
                print(json.dumps(response.reply))
        except ConnectionError as e:
            print(json.dumps(e.response.dict()))
Exemplo n.º 7
0
    def get_ebay_trading_api(self):
        """Create an instance of ebay trading api

        :return: ebay trading api instance
        """
        domain = 'api.sandbox.ebay.com' if \
            self.is_ebay_sandbox else 'api.ebay.com'
        return trading(
            appid=self.ebay_app_id,
            certid=self.ebay_cert_id,
            devid=self.ebay_dev_id,
            token=self.ebay_token,
            domain=domain,
            config_file=None,
        )
Exemplo n.º 8
0
    def get_ebay_trading_api(self):
        """Create an instance of ebay trading api

        :return: ebay trading api instance
        """
        domain = 'api.sandbox.ebay.com' if \
            self.is_ebay_sandbox else 'api.ebay.com'
        return trading(
            appid=self.ebay_app_id,
            certid=self.ebay_cert_id,
            devid=self.ebay_dev_id,
            token=self.ebay_token,
            domain=domain,
            config_file=None,
        )
Exemplo n.º 9
0
 def getObjects(self, Verbose=False):
     api = trading(appid=self.AppID, devid=self.DevID, certid=self.CertID, token=self.AuthToken)
     api.execute('GetMyeBaySelling', {})
     if Verbose:
         print api.response_obj()
     return api.response_obj()
Exemplo n.º 10
0
 def getUserInfo(self):
     api = trading(appid=self.AppID, devid=self.DevID, certid=self.CertID, token=self.AuthToken)
     api.execute('GetUser', {})
     print api.response_dict()
     return api.response_dict()
Exemplo n.º 11
0
def get_items_by_category(category, category_aspects, category_order, query_type="findItemsByCategory"):
    global finding_api
    try:

        keys = category_aspects.keys()
        for c in category_order:
            aspects = category_aspects[keys[c]]
            print keys[c]
            for a in range(len(aspects)):
                print aspects[a]
                response = finding_api.execute(
                    query_type,
                    {
                        "outputSelector": "AspectHistogram",
                        "sortOrder": "StartTimeNewest",
                        "categoryId": category,
                        "aspectFilter": {"aspectName": keys[c], "aspectValueName": aspects[a]},
                    },
                )
                aspects = response.dict()["aspectHistogramContainer"]["aspect"]
                print (aspects)
                result = response.dict()
                print (result["paginationOutput"])
                print (result["itemSearchURL"])

        # =======================================================================
        # print(category_aspects.keys()[1])
        # print(category_aspects[category_aspects.keys()[1]][2])
        #
        # response=finding_api.execute(query_type,{'sortOrder':'StartTimeNewest','categoryId':category,'aspectFilter':{'aspectName':category_aspects.keys()[1],'aspectValueName':category_aspects[category_aspects.keys()[1]][2]}})
        #
        # result=response.dict()
        # print(result['paginationOutput'])
        # print(result['itemSearchURL'])
        # #sprint(result['searchResult'])
        # for i in range(len(result['searchResult']['item'])):
        #     print(result['searchResult']['item'][i]['title'])
        #     print(result['searchResult']['item'][i]['viewItemURL'])
        #     #print(result['searchResult']['item'][i]['productId'])
        #
        # =======================================================================
        # finding_api.next_page()
        # response=finding_api.response
        # print(response.dict()['paginationOutput'])
        # response = finding_api.response_dict()
        # print 'here2'
        # print(finding_api.response_dict())
        # r=response.dict()

        # output = open('items_by_category.pkl', 'w')
        # pickle.dump(r,output,-1)
        # output.close()
        # r2=r['searchResult']
        # print(response)
    except ConnectionError as e:
        print (e)
        print (e.response.dict())

    # api = FindItem(config_file='ebay.yaml')
    # records = api.find_items_by_ids([121429757727])

    # print(records)

    # api = Connection(config_file='ebay.yaml', debug=False)
    # api = Connection(appid='ColinBau-c01c-4e3d-85cf-380674b047ac')
    # response = api.execute('findItemsAdvanced', {'keywords': 'legos'})

    # api = shopping(config_file='ebay.yaml',siteid=77)
    # response = api.execute('GetSingleItem', {'ItemID': '121429757727'})
    api = trading(config_file="ebay.yaml", siteid=77)
    response = api.execute("GetItem", {"ItemID": "111453544170"})
    print (response.dict())