"""Interface to the ows-product-workflow microservice.""" from oto import response from owsrequest import request from product_digital.constants import header, services def update_product_physical(data, product_id, orchard_user_id='', account_type='', account_id=''): """Update product physical metadata. Args: data (dict): dictionary of data for update product_id (int): product identifier orchard_user_id (str): Orchard user identifier, formatted as "oa:" (e.g., "oa:562"), identifying the user making the update account_type (str): type of account associated with the request account_id (str): identifier of the account associated with the request Returns: response.Response status of put call and dictionary of results """ request_headers = {} if orchard_user_id: request_headers[header.ORCHARD_USER_ID] = orchard_user_id if account_type: request_headers[header.GRASS_ACCOUNT_TYPE] = account_type if account_id: request_headers[header.GRASS_ACCOUNT_ID] = str(account_id) ows_product_physical_response = request.put( services.OWS_PRODUCT_PHYSICAL, '/product/{product_id}'.format( product_id=product_id), json={ 'sale_start_date': data['sale_start_date'], 'release_date': data['release_date'] }, headers=request_headers ) info_body = ows_product_physical_response.json() if ows_product_physical_response.status_code != 200: return response.create_error_response( status=ows_product_physical_response.status_code, code=info_body.get('code'), message=info_body.get('message')) return response.Response(message=info_body)