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
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
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
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)
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
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
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
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)
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
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
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)
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
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
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
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
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
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
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
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
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
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)
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
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
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
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
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
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
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
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)
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