def create_factory(status, created_by, updated_by, factory_name='', location='', region='', f_type='', owner='', owner_email='', owner_mobile=''): params = { 'factory_name': factory_name, 'location': location, 'region': region, 'type': f_type, 'owner': owner, 'owner_email': owner_email, 'owner_mobile': owner_mobile, 'status': status, 'created_by': created_by, 'updated_by': updated_by, 'created_time': utils.current_timestamp_in_millis(), 'updated_time': utils.current_timestamp_in_millis() } params = utils.clean_params(params) r = requests.post('%s/factory/info' % SERVER_HOST, params=params) return r.json() if r else None
def new_product(name=None, unit=None, status=0, created_by=None, updated_by=None, barcode=None, intro=None, icon=None, images=None, description=None): params = { 'name': name, 'unit': unit, 'status': status, 'created_by': created_by, 'created_time': utils.current_timestamp_in_millis(), 'updated_by': updated_by, 'updated_time': utils.current_timestamp_in_millis(), 'barcode': barcode, 'intro': intro, 'icon': icon, 'images': images, 'description': description } params = utils.clean_params(params) r = requests.post('%s/product' % SERVER_HOST, data=params) return r.json() if r else None
def create_batch(factory_id, product_id, incode_factory, outcode_factory, casecode_factory, case_count, case_size, unit_count, barcode, expired_time, product_info, callback_uri, created_by, updated_by): params = { 'factory_id': factory_id, 'product_id': product_id, 'incode_factory': incode_factory, 'outcode_factory': outcode_factory, 'casecode_factory': casecode_factory, 'case_count': case_count, 'case_size': case_size, 'unit_count': unit_count, 'barcode': barcode, 'expired_time': expired_time, 'product_info': product_info, 'callback_uri': callback_uri, 'created_by': created_by, 'created_time': utils.current_timestamp_in_millis(), 'updated_by': updated_by, 'updated_time': utils.current_timestamp_in_millis() } params = utils.clean_params(params) r = requests.post('%s/batch' % SERVER_HOST, data=params) return r.json() if r else None
def create_factory_secret(factory_id, factory_secret): params = { 'factory_id': factory_id, 'secret': factory_secret, 'created_time': utils.current_timestamp_in_millis(), 'updated_time': utils.current_timestamp_in_millis() } params = utils.clean_params(params) r = requests.post('%s/factory/secret' % SERVER_HOST, params=params) return r.json() if r else None
def update_factory(factory_id, factory_name=None, location=None, region=None, f_type=None, owner=None, owner_email=None, owner_mobile=None, status=None, updated_by=None): params = { 'factory_name': factory_name, 'location': location, 'region': region, 'type': f_type, 'owner': owner, 'owner_email': owner_email, 'owner_mobile': owner_mobile, 'status': status, 'updated_by': updated_by, 'updated_time': utils.current_timestamp_in_millis() } params = utils.clean_params(params) r = requests.put('%s/factory/info/%s' % (SERVER_HOST, factory_id), data=params) return r.json() if r else None
def update_product(product_id=None, name=None, unit=None, status=0, updated_by=None, barcode=None, intro=None, icon=None, images=None, description=None): if product_id: params = { 'name': name, 'unit': unit, 'status': status, 'updated_by': updated_by, 'updated_time': utils.current_timestamp_in_millis(), 'barcode': barcode, 'intro': intro, 'icon': icon, 'images': images, 'description': description } params = utils.clean_params(params) r = requests.put('%s/product/%s' % (SERVER_HOST, product_id), data=params) return r.json() if r else None else: return None
def update_factory_secret(secret_id, factory_id=None, factory_secret=None): params = { 'factory_id': factory_id, 'secret': factory_secret, 'updated_time': utils.current_timestamp_in_millis() } params = utils.clean_params(params) r = requests.put('%s/factory/secret/%s' % (SERVER_HOST, secret_id), params=params) return r.json() if r else None