Exemple #1
0
 def itemAddWarehouse(self, item_id: int, payload):
     """ attach warehouse to the item"""
     logger.debug(f'Add warehouse at {item_id} - {payload}')
     rq = f'{self.host}/item/{item_id}/warehouse'
     r = self.agent.post(rq, json=payload)
     if 204 != r.status_code:
         parseApiError(r)
         return False
     return True
Exemple #2
0
 def itemRemoveWarehouse(self, item_id: int, warehouse_id: int):
     """ attach warehouse to the item"""
     logger.debug(f'Remove warehouse {warehouse_id} @ item {item_id}')
     rq = f'{self.host}/item/{item_id}/warehouse/{warehouse_id}'
     r = self.agent.delete(rq)
     if 204 != r.status_code:
         parseApiError(r)
         return False
     return True
Exemple #3
0
 def itemAddCompetitor(self, item_id: int, payload):
     """ attach warehouse to the item"""
     logger.debug(f'Add xref item {item_id} {payload}')
     rq = f'{self.host}/item/{item_id}/xcompetitor'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     return True
Exemple #4
0
 def getAttribute(self, attribute_id: int, params=None):
     """ Attribute by id """
     logger.debug(f'Get attribute {attribute_id}')
     rq = f'{self.host}/attribute/{attribute_id}'
     r = self.agent.get(rq, params=params)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     return json.loads(r.text)
Exemple #5
0
 def itemPatchWarehouse(self, item_id: int, warehouse_id: int, payload):
     """ attach warehouse to the item"""
     logger.debug(
         f'Patching item {item_id}@warehouse {warehouse_id} - {payload}')
     rq = f'{self.host}/item/{item_id}/warehouse/{warehouse_id}'
     r = self.agent.patch(rq, json=payload)
     if 204 != r.status_code:
         parseApiError(r)
         return False
     return True
Exemple #6
0
 def itemDeleteCompetitor(self, item_id: int, competitor_id: int):
     """ Remove item competitor cross reference"""
     logger.debug(
         f'Removing competitor {competitor_id} from item {item_id}')
     rq = f'{self.host}/item/{item_id}/xcompetitor/{competitor_id}'
     r = self.agent.delete(rq)
     if 204 != r.status_code:
         parseApiError(r)
         return False
     return True
Exemple #7
0
 def itemUpdateCompetitor(self, item_id: int, xref_id: int, code):
     """ update item competitor cross reference"""
     logger.debug(f'Update competitor {xref_id} with code {code}')
     payload = {'code': code}
     rq = f'{self.host}/item/{item_id}/xcompetitor/{xref_id}'
     r = self.agent.post(rq, json=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     return True
Exemple #8
0
 def createItemAttribute(self, item_id: int, payload):
     """
     Create new item attributes.
     """
     logger.debug(f'Creating item {item_id} attributes {payload}')
     rq = '%s/item/%s/attribute' % (self.host, item_id)
     r = self.agent.post(rq, json=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     return json.loads(r.text)
Exemple #9
0
 def createAttribute(self, payload):
     """ crea un nuovo attributo """
     logger.debug('Creating new attribute %s' % payload)
     rq = f'{self.host}/attribute'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     attribute = json.loads(r.text)
     logger.info('Create attribute %s' % attribute['data']['id'])
     return attribute
Exemple #10
0
 def createCrtable(self, payload):
     """ crea una nuova tabella """
     logger.debug('Creating new crtabel %s' % payload)
     rq = '%s/crtable' % (self.host)
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     crtable = json.loads(r.text)
     logger.info('Create crtable %s' % crtable['data']['id'])
     return crtable
Exemple #11
0
 def updateItem(self, item_id: int, payload):
     """
     Update item.
     """
     logger.debug(f'Updating item {item_id} with {payload}')
     rq = '%s/item/%s' % (self.host, item_id)
     r = self.agent.post(rq, json=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     return json.loads(r.text)
Exemple #12
0
 def createCrimping(self, crtable_id: int, payload):
     """ crea nuovo parametro di pinzatura per tabella """
     logger.debug('Creating new crimping %s' % payload)
     rq = f'{self.host}/crtable/{crtable_id}/crimping'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     crimping = json.loads(r.text)
     logger.info('Create crimping %s' % crimping['data']['id'])
     return crimping
Exemple #13
0
 def createFamily(self, payload):
     """ crea una nuova famiglia """
     logger.debug('Creating new family %s' % payload)
     rq = '%s/family' % (self.host)
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     family = json.loads(r.text)
     logger.info('Create family %s' % family['data']['id'])
     return family
Exemple #14
0
 def erp_sap_customer(self, payload):
     """
     Call erp sap customer worker queue
     """
     logger.debug(f'Calling erp sap customer queue')
     rq = f'{self.host}/erp/sap/customer'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     return True
Exemple #15
0
 def createOrderDetail(self, order_id: int, payload):
     """
     Create order detail.
     """
     logger.debug('Creating order detail')
     rq = f'{self.host}/order/{order_id}/detail'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     order = json.loads(r.text)
     return order
Exemple #16
0
 def getOrder(self, order_id: int):
     """
     Get order by id
     """
     logger.debug(f'Reading order {order_id}..')
     rq = f'{self.host}/order/{order_id}'
     r = self.agent.get(rq)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     order = json.loads(r.text)
     return order
Exemple #17
0
 def getCompetitor(self, competitor_id: int):
     """
     Get competitor by id.
     """
     logger.debug(f'Reading competitor {competitor_id}...')
     rq = f'{self.host}/competitor/{competitor_id}'
     r = self.agent.get(rq)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     competitor = json.loads(r.text)
     return competitor
Exemple #18
0
 def createCustomerAddress(self, customer_id: int, payload):
     """
     Create new customer address
     """
     logger.debug(f'Creating customer {customer_id} address')
     rq = f'{self.host}/customer/{customer_id}/address'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     address = json.loads(r.text)
     return address
Exemple #19
0
 def createCustomerXerp(self, customer_id: int, payload):
     """
     Update customer ERP Xrefs.
     """
     logger.debug(f'Init creating customer {customer_id} ERP xref ...')
     rq = f'{self.host}/customer/{customer_id}/xerp'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     resp = json.loads(r.text)
     return resp
Exemple #20
0
 def updateAttribute(self, attribute_id: int, payload):
     """
     Update attribute.
     """
     logger.debug(f'Updating attribute {attribute_id} ...')
     rq = f'{self.host}/attribute/{attribute_id}'
     r = self.agent.post(rq, json=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     _family = json.loads(r.text)
     return _family
Exemple #21
0
 def createNorm(self, normName: str):
     """
     Create new norm.
     """
     logger.debug('Creating norm %s' % normName)
     rq = '%s/norm' % (self.host)
     payload = {'name': normName}
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     return json.loads(r.text)
Exemple #22
0
 def getCategoryByName(self, category_name: str):
     """
     Prende categoria da nome.
     """
     logger.debug('Search category by name %s' % category_name)
     rq = '%s/category/findByName?name=%s' % (self.host, category_name)
     r = self.agent.get(rq)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     _category = json.loads(r.text)
     return _category
Exemple #23
0
 def getHubByName(self, hub_name: str):
     """ 
     Get hub from name
     """
     logger.debug('Search hub by name %s' % hub_name)
     rq = f'{self.host}/hub/findByName?name={hub_name}'
     r = self.agent.get(rq)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     _hub = json.loads(r.text)
     return _hub
Exemple #24
0
 def patchItem(self, item_id: int, payload):
     """
     Patch know item field.
     """
     logger.debug(f'Patching item {item_id} with {payload}')
     rq = '%s/item/%s' % (self.host, item_id)
     r = self.agent.patch(rq, json=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     item = json.loads(r.text)
     return item
Exemple #25
0
 def updateFamily(self, family_id: int, payload):
     """
     Update family.
     """
     logger.debug('Updating family %s ...' % family_id)
     rq = '%s/family/%s' % (self.host, family_id)
     r = self.agent.post(rq, json=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     _family = json.loads(r.text)
     return _family
Exemple #26
0
 def getCustomer(self, customer_id: int):
     """
     Get customer by id.
     """
     logger.debug(f'Reading customer {customer_id}...')
     rq = f'{self.host}/customer/{customer_id}'
     r = self.agent.get(rq)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     customer = json.loads(r.text)
     return customer
Exemple #27
0
 def createWarehouse(self, payload):
     """ 
     Create new warehouse
     """
     logger.debug(f'Creating new warehouse {payload}')
     rq = f'{self.host}/warehouse'
     r = self.agent.post(rq, json=payload)
     if 201 != r.status_code:
         parseApiError(r)
         return False
     warehouse = json.loads(r.text)
     return warehouse
Exemple #28
0
 def updateWarehouse(self, warehouse_id: int, payload):
     """ 
     Create new warehouse
     """
     logger.debug(f'Updateing warehouse {warehouse_id} - {payload}')
     rq = f'{self.host}/warehouse/{warehouse_id}'
     r = self.agent.post(rq, json=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     warehouse = json.loads(r.text)
     return warehouse
Exemple #29
0
 def getNormFromName(self, normName: str):
     """
     Prende la norm dal nome.
     """
     logger.debug('Get norm by name %s' % normName)
     rq = '%s/norm/findByName' % (self.host)
     payload = {'name': normName}
     r = self.agent.get(rq, params=payload)
     if 200 != r.status_code:
         parseApiError(r)
         return False
     return json.loads(r.text)
Exemple #30
0
 def syncItemNorm(self, item_id: int, payload):
     """
     Sync item norm.
     """
     logger.debug(f'Sync item {item_id} norm {payload}')
     rq = '%s/item/%s/norm' % (self.host, item_id)
     r = self.agent.post(rq, json=payload)
     if 204 != r.status_code:
         parseApiError(r)
         return False
     logger.info(f'Sync item {item_id} norms complete')
     return True