def create_profile_entry(cls, profile_entry_info): for f in ProfilesService.required_create_fields: v = profile_entry_info.get(f, None) if v is None: raise ServiceException(ServiceException.missing_field, "Missing field = " + f) profile_entry_info = { k: profile_entry_info[k] for k in ProfilesService.required_create_fields } if profile_entry_info['type'] not in ProfilesService.valid_types: raise ServiceException('Invalid type was supplied!') if profile_entry_info['subtype'] not in ProfilesService.valid_subtypes: raise ServiceException('Invalid subtype was supplied!') if profile_entry_info['type'] == 'Address': address_microservice_body = { "address": profile_entry_info['value'] } req = requests.post(os.environ['address_microservice_url'], json=address_microservice_body) if req.status_code == 200: profile_entry_info['value'] = "/address/" + req.text else: print(req.text) raise ServiceException( 'An invalid address was supplied to create a profile entry!' ) profile_entry_info['profile_entry_id'] = str(uuid.uuid4()) result = ProfilesRDB.create_profile_entry(profile_entry_info) return result
def update_profile_entry(cls, body, profile_entry_id, existing): for k in body.keys(): if k not in ProfilesService.required_create_fields: raise ServiceException( "Attempting to update unsupported field!") if k == 'type' and body['type'] not in ProfilesService.valid_types: raise ServiceException('Invalid type was supplied!') if k == 'subtype' and body[ 'subtype'] not in ProfilesService.valid_subtypes: raise ServiceException('Invalid subtype was supplied!') if existing['type'] == 'Address' and 'value' in body.keys(): address_microservice_body = {"address": body['value']} req = requests.post(os.environ['address_microservice_url'], json=address_microservice_body) if req.status_code == 200: body['value'] = "/address/" + req.text else: raise ServiceException( 'An invalid address was supplied to update the profile entry!' ) result = ProfilesRDB.update_profile_entry(profile_entry_id, body) return result
def delete_profile_entry(cls, entry_info): result = ProfilesRDB.delete_profile_entry(entry_info) return result
def update_profile_entry(cls, entry_info): result = ProfilesRDB.update_profile_entry(entry_info) return result
def create_profile_entry(cls, entry_info): result = ProfilesRDB.create_profile_entry(entry_info) return result
def get_profile_entries(cls, queryParams): result = ProfilesRDB.get_profile_entries(queryParams) return result
def delete_profile_entry(cls, profile_entry_id): result = ProfilesRDB.delete_profile_entry(profile_entry_id) return result
def get_by_profile_entry_id(cls, profile_entry_id): result = ProfilesRDB.get_by_profile_entry_id(profile_entry_id) return result
def get_by_customer_id(cls, customer_id): result = ProfilesRDB.get_by_customer_id(customer_id) return result
def get_queried(cls, queries): return ProfilesRDB.get_queried(queries)
def get_first(cls): return ProfilesRDB.get_first()