Beispiel #1
0
 def retrieveBottomLineAllProducts(self, count=100, page=1, since_id='0'):
     response = requests.get(
         '{}/{}/bottom_lines?utoken={}&page={}&count={}&since_id={}'.format(
             yotpo.api_base, yotpo.api_key, yotpo.get_access_token(), page,
             count, since_id))
     if response.status_code != 200:
         raise YotpoException(response)
     return response.json()['response']['bottomlines']
Beispiel #2
0
 def retrieveAll(self, count=10, since_id=0):
     response = requests.get(
         '{}/{}/purchases?utoken={}&count={}&since_id={}'.format(
             yotpo.api_base, yotpo.api_key, yotpo.get_access_token(), count,
             since_id))
     if response.status_code != 200:
         raise YotpoException(response)
     return response.json()['response']['purchases']
Beispiel #3
0
 def create(self):
     if not self.name:
         raise Exception('Name is required')
     response = requests.post('{}/{}/products_groups'.format(
         yotpo.api_base_v1, yotpo.api_key),
                              headers={"Content-Type": "application/json"},
                              data={
                                  'utoken': yotpo.get_access_token(),
                                  'group_name': self.name,
                              })
     if response.status_code != 200:
         raise YotpoException(response)
     return True
Beispiel #4
0
 def create(self):
     if not self.user_email or not self.user_name or not self.currency_iso \
             or not self.order_id or not self.products:
         raise Exception('Data does not have the required keys')
     data = json.dumps({
         'validate_data': True,
         'platform': yotpo.platform,
         'utoken': yotpo.get_access_token(),
         'email': self.user_email,
         'customer_name': self.user_name,
         'order_id': self.order_id,
         'order_date': datetime.now().strftime('%Y-%m-%d'),
         'currency_iso': self.currency_iso,
         'products': self.build_products_json(),
     })
     response = requests.post('{}/{}/purchases'.format(
         yotpo.api_base, yotpo.api_key),
                              data=data,
                              headers={"Content-Type": "application/json"},
                              timeout=30)
     if int(response.status_code) != 200:
         raise YotpoException(response)
     return True
Beispiel #5
0
 def retrieveAll(self):
     response = requests.get('{}/{}/products_groups?utoken={}'.format(
         yotpo.api_base_v1, yotpo.api_key, yotpo.get_access_token()))
     if response.status_code != 200:
         raise YotpoException(response)
     return response.json()['response']['products_groups']