def itemAddCompetitor(self, item_id: int, payload): """ attach warehouse to the item""" logging.info(f'Add xref item {item_id} {payload}') rq = f'{self.host}/item/{item_id}/xcompetitor' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False return True
def itemRemoveWarehouse(self, item_id: int, warehouse_id: int): """ attach warehouse to the item""" logging.info(f'Remove warehouse {warehouse_id} @ item {item_id}') rq = f'{self.host}/item/{item_id}/warehouse/{warehouse_id}' agent = self.s.getAgent() r = agent.delete(rq) if 204 != r.status_code: parseApiError(r) return False return True
def itemAddWarehouse(self, item_id: int, payload): """ attach warehouse to the item""" logging.info(f'Add warehouse at {item_id} - {payload}') rq = f'{self.host}/item/{item_id}/warehouse' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 204 != r.status_code: parseApiError(r) return False return True
def getAttribute(self, attribute_id: int, params=None): """ Attribute by id """ logging.info(f'Get attribute {attribute_id}') rq = f'{self.host}/attribute/{attribute_id}' agent = self.s.getAgent() r = agent.get(rq, params=params) if 200 != r.status_code: parseApiError(r) return False return json.loads(r.text)
def itemUpdateCompetitor(self, item_id: int, xref_id: int, code): """ update item competitor cross reference""" logging.info(f'Update competitor {xref_id} with code {code}') payload = {'code': code} rq = f'{self.host}/item/{item_id}/xcompetitor/{xref_id}' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False return True
def itemDeleteCompetitor(self, item_id: int, competitor_id: int): """ Remove item competitor cross reference""" logging.info( f'Removing competitor {competitor_id} from item {item_id}') rq = f'{self.host}/item/{item_id}/xcompetitor/{competitor_id}' agent = self.s.getAgent() r = agent.delete(rq) if 204 != r.status_code: parseApiError(r) return False return True
def itemPatchWarehouse(self, item_id: int, warehouse_id: int, payload): """ attach warehouse to the item""" logging.info( f'Patching item {item_id}@warehouse {warehouse_id} - {payload}') rq = f'{self.host}/item/{item_id}/warehouse/{warehouse_id}' agent = self.s.getAgent() r = agent.patch(rq, json=payload) if 204 != r.status_code: parseApiError(r) return False return True
def createItemAttribute(self, item_id: int, payload): """ Create new item attributes. """ logging.info(f'Creating item {item_id} attributes {payload}') rq = '%s/item/%s/attribute' % (self.host, item_id) agent = self.s.getAgent() r = agent.post(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False return json.loads(r.text)
def updateItem(self, item_id: int, payload): """ Update item. """ logging.info(f'Updating item {item_id} with {payload}') rq = '%s/item/%s' % (self.host, item_id) agent = self.s.getAgent() r = agent.post(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False return json.loads(r.text)
def updateCategory(self, category_id:int, payload): """ Update category. """ logging.info(f'Updating category {category_id} with {payload}') rq = f'{self.host}/category/{category_id}' agent=self.s.getAgent() r = 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 """ logging.info('Creating new crimping %s' % payload) rq = f'{self.host}/crtable/{crtable_id}/crimping' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False crimping = json.loads(r.text) logging.info('Create crimping %s' % crimping['data']['id']) return crimping
def updateSupplier(self, supplier_id:int, payload): """ Update supplier. """ logging.info(f'Updating supplier {supplier_id} with {payload}') rq = f'{self.host}/supplier/{supplier_id}' agent=self.s.getAgent() r = agent.post(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False return json.loads(r.text)
def createCrtable(self, payload): """ crea una nuova tabella """ logging.info('Creating new crtabel %s' % payload) rq = '%s/crtable' % (self.host) agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False crtable = json.loads(r.text) logging.info('Create crtable %s' % crtable['data']['id']) return crtable
def createFamily(self, payload): """ crea una nuova famiglia """ logging.info('Creating new family %s' % payload) rq = '%s/family' % (self.host) agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False family = json.loads(r.text) logging.info('Create family %s' % family['data']['id']) return family
def createAttribute(self, payload): """ crea un nuovo attributo """ logging.info('Creating new attribute %s' % payload) rq = f'{self.host}/attribute' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False attribute = json.loads(r.text) logging.info('Create attribute %s' % attribute['data']['id']) return attribute
def erp_sap_supplier(self, payload): """ Call erp sap supplier worker queue """ logging.debug(f'Calling erp sap supplier queue') rq = f'{self.host}/erp/sap/supplier' agent=self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False return True
def updateWarehouse(self, warehouse_id: int, payload): """ Create new warehouse """ logging.info(f'Updateing warehouse {warehouse_id} - {payload}') rq = f'{self.host}/warehouse/{warehouse_id}' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False warehouse = json.loads(r.text) return warehouse
def createWarehouse(self, payload): """ Create new warehouse """ logging.info(f'Creating new warehouse {payload}') rq = f'{self.host}/warehouse' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False warehouse = json.loads(r.text) return warehouse
def getCategoryByName(self, category_name: str): """ Prende categoria da nome. """ logging.info('Search category by name %s' % category_name) rq = '%s/category/findByName?name=%s' % (self.host, category_name) agent = self.s.getAgent() r = 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 """ logging.info('Search hub by name %s' % hub_name) rq = f'{self.host}/hub/findByName?name={hub_name}' agent = self.s.getAgent() r = agent.get(rq) if 200 != r.status_code: parseApiError(r) return False _hub = json.loads(r.text) return _hub
def updateFamily(self, family_id: int, payload): """ Update family. """ logging.info('Updating family %s ...' % family_id) rq = '%s/family/%s' % (self.host, family_id) agent = self.s.getAgent() r = agent.post(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False _family = json.loads(r.text) return _family
def getItemFromErpId(self, erp_id: int, ext_id: str): """ Get item from ext_id of Erp. """ logging.info(f'Search item ext_id {ext_id} for erp {erp_id}.') rq = '%s/item/findByErpExtId' % (self.host) payload = {'erp_id': erp_id, 'ext_id': ext_id} agent = self.s.getAgent() r = agent.get(rq, params=payload) if 200 != r.status_code: parseApiError(r) return False return json.loads(r.text)
def patchItem(self, item_id: int, payload): """ Patch know item field. """ logging.info(f'Patching item {item_id} with {payload}') rq = '%s/item/%s' % (self.host, item_id) agent = self.s.getAgent() r = agent.patch(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False item = json.loads(r.text) return item
def syncItemNorm(self, item_id: int, payload): """ Sync item norm. """ logging.info(f'Sync item {item_id} norm {payload}') rq = '%s/item/%s/norm' % (self.host, item_id) agent = self.s.getAgent() r = agent.post(rq, json=payload) if 204 != r.status_code: parseApiError(r) return False logging.info(f'Sync item {item_id} norms complete') return True
def getNormFromName(self, normName: str): """ Prende la norm dal nome. """ logging.info(f'Get norm by name {normName}') rq = f'{self.host}/norm/findByName' payload = {'name': normName} agent = self.s.getAgent() r = agent.get(rq, params=payload) if 200 != r.status_code: parseApiError(r) return False return json.loads(r.text)
def updateAttribute(self, attribute_id: int, payload): """ Update attribute. """ logging.info(f'Updating attribute {attribute_id} ...') rq = f'{self.host}/attribute/{attribute_id}' agent = self.s.getAgent() r = 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. """ logging.info(f'Creating norm {normName}') rq = f'{self.host}/norm' payload = {'name': normName} agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False return json.loads(r.text)
def listCategories(self, query=None): """ Read all categories. """ logging.info('Getting all categories') rq = f'{self.host}/category' agent = self.s.getAgent() r = agent.get(rq, params=query) if 200 != r.status_code: parseApiError(r) return False category = json.loads(r.text) return category
def createCategoryType(self, payload): """ Create new category type. """ logging.info('Init creating category type...') rq = f'{self.host}/category/type' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 201 != r.status_code: parseApiError(r) return False category = json.loads(r.text) logging.info('Category %s created' % category['data']['id']) return category
def updateTicket(self, ticket_id, payload): """ Update ticket. """ logging.info(f'Updating ticket {ticket_id}...') rq = f'{self.host}/ticket/{ticket_id}' agent = self.s.getAgent() r = agent.post(rq, json=payload) if 200 != r.status_code: parseApiError(r) return False ticket = json.loads(r.text) logging.info(f'Updated ticket {ticket_id}') return ticket