示例#1
0
 def check_webhooks(self):
     r = requests.get("%s/admin/webhooks.json" % self.url_prefix,
                      headers={'X-Shopify-Access-Token': self.access_token})
     if not r.status_code == 200:
         raise ApiException(r.text, r.status_code)
     response = r.json()
     return response
示例#2
0
 def get_products_count(self):
     r = requests.get("%s/admin/products/count.json" % self.url_prefix,
                      headers={'X-Shopify-Access-Token': self.access_token})
     if not r.status_code == 200:
         raise ApiException(r.text, r.status_code)
     response = r.json()
     return response.get('count', 0)
示例#3
0
 def get_orders(self,
                limit=Constants.SHOPIFY_MAX_PRODUCTS_PER_PAGE,
                page=1):
     r = requests.get("%s/admin/orders.json?status=any&limit=%s&page=%s" %
                      (self.url_prefix, limit, page),
                      headers={'X-Shopify-Access-Token': self.access_token})
     if not r.status_code == 200:
         raise ApiException(r.text, r.status_code)
     response = r.json()
     return response.get('orders', [])
示例#4
0
    def get_access_token(self, code):
        r = requests.post('%s/admin/oauth/access_token' % self.url_prefix,
                          data={
                              'client_id': self.client_id,
                              'client_secret': self.client_secret,
                              'code': code
                          })

        if not r.status_code == 200:
            raise ApiException(r.text, r.status_code)
        json_r = r.json()
        access_token = json_r.get('access_token')
        self.access_token = access_token