def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = SupplierDeleteProductRequest.pre_deserialize(json_dict) res = self.is_session_valid() if not res: return False, Result.language.SESSION_KEY_IS_NOT_VALID if result[0]: self.phone_number = SessionManager.retrieve_session_value_by_key( key=Keys.PHONE_NUMBER) self.supplier_id = SessionManager.retrieve_session_value_by_key( key=Keys.USER_ID) # check_supplier = Supplier.check_supplier(self.phone_number) # if check_supplier[0]: # self.supplier_id = check_supplier[1] result = SupplierDeleteProductRequest.pre_deserialize(json_dict) if result[0]: self.product_id = json_dict[Keys.PRODUCT_ID] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = NewCarRequest.pre_deserialize(json_dict) if result[0]: car_info = json_dict[Keys.CAR_INFO] vin_number = '' if Keys.VIN_NUMBER not in car_info: vin_number = json_dict[Keys.CAR_INFO][Keys.VIN_NUMBER] plate_number = json_dict[Keys.CAR_INFO][Keys.PLATE_NUMBER] auto_type = json_dict[Keys.CAR_INFO][Keys.AUTO_TYPE] color = json_dict[Keys.CAR_INFO][Keys.CAR_COLOR] auto_model = json_dict[Keys.CAR_INFO][Keys.AUTO_MODEL] current_kilometer = json_dict[Keys.CAR_INFO][ Keys.CURRENT_KILOMETER] car = Car(vin_number=vin_number, plate_number=plate_number, auto_type_id=auto_type, color_id=color, current_kilometer=current_kilometer, auto_model_id=auto_model) self.car_owner = json_dict[Keys.CAR_OWNER] self.car = car result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = SupplierManageProductInfoRequest.pre_deserialize(json_dict) res = self.is_session_valid() if not res: return False, Result.language.SESSION_KEY_IS_NOT_VALID if result[0]: self.phone_number = SessionManager.retrieve_session_value_by_key( key=Keys.PHONE_NUMBER) self.supplier_id = SessionManager.retrieve_session_value_by_key( key=Keys.USER_ID) code = json_dict[Keys.CODE] company_id = json_dict[Keys.COMPANY_ID] sub_category_id = json_dict[Keys.SUB_CATEGORY_ID] brand_id = json_dict[Keys.BRAND_ID] price = json_dict[Keys.PRICE] minimum_order = json_dict[Keys.MINIMUM_ORDER] check_id_existence = self.check_optional_item_is_in_dict( json_dict, Keys.ID) if check_id_existence[0]: id = json_dict[Keys.ID] description_result = self.check_optional_item_is_in_dict( json_dict, Keys.DESCRIPTION) if description_result[0]: description = json_dict[Keys.DESCRIPTION] product = Product(minimum_order=minimum_order, company_id=company_id, code=code, sub_category_id=sub_category_id, price=price, supplier_id=self.supplier_id, brand_id=brand_id, description=description) else: product = Product(minimum_order=minimum_order, company_id=company_id, code=code, sub_category_id=sub_category_id, price=price, supplier_id=self.supplier_id, brand_id=brand_id) self.product = product result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = CalendarDeletionRequest.pre_deserialize(json_dict) if result[0]: self.id = json_dict[Keys.CALENDAR_ID] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = DenyOrderRequest.pre_deserialize(json_dict) if not result[0]: return result self.order = OrderItem(id=json_dict[Keys.ORDER_ID]) result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ListServiceGradesRequest.pre_deserialize(json_dict) if result[0]: self.car_id = json_dict['car_id'] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = CancelJobRequest.pre_deserialize(json_dict) if not result[0]: return result self.job = Job(id=json_dict[Keys.JOB_ID]) result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self
def deserialize(json_obj): if not type(json_obj) is dict: json_dict = Serializable.convert_input_to_dict(json_obj) else: json_dict = json_obj result = BaseJobProcessStatusesRequest.pre_deserialize(json_dict) if not result[0]: return result result = BaseJobProcessStatusesRequest.generate_appropriate_request(json_dict[Keys.USER_TYPE]) if not result[0]: res = False, result[1].params return res return BaseJobProcessStatusesRequest.child_class_deserialize(result[1], json_dict)
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ListJobsByStatusRequest.pre_deserialize(json_dict) if not result[0]: return result self.business_owner = BusinessOwner(id=SessionManager.retrieve_session_value_by_key(Keys.USER_ID)) self.status = json_dict[Keys.STATUS] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = IWSRegisterRequest.pre_deserialize(json_dict) if result[0]: self.iws = self.create_user(json_dict) result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def send_dict_to_endpoint(self): for item in self.array: item_dict = Serializable.convert_input_to_dict(item) res = self.app.post(Endpoints.RATE_BUSINESS_OWNER_BY_CAR_OWNER, data=item_dict, content_type=Keys.APPLICATION_CONTENT_TYPE_JSON) # def get_dict_from_array(self): # if isinstance(self.array, list): # for item in self.array: # if not type(item) is dict: # item_dict = Serializable.convert_input_to_dict(item) # else: # item_dict = item # RateJobRequest(item)
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = CodeValidationRequest.pre_deserialize(json_dict) if result[0]: self.code = json_dict['code'] self.phone_number = json_dict['phone_number'] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if Keys.USER_TYPE not in self.json_obj: return False, Result.language.MISSING_PHONE_NUMBER_IN_JSON if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj self.type = json_dict[Keys.USER_TYPE] if not self.type == Keys.SUPPLIER: result = self.deserialize_none_supplier_users(json_dict) else: result = self.deserialize_supplier_users(json_dict) return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = CalendarInsertionRequest.pre_deserialize(json_dict) if result[0]: self.start_time = json_dict[Keys.START_TIME] self.finish_time = json_dict[Keys.FINISH_TIME] self.business_owners_id = json_dict[Keys.BUSINESS_OWNER_ID] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = NewServiceGradeRequest.pre_deserialize(json_dict) if not result[0]: return result service_grade = ServiceGrade(name=json_dict['service_grade_name']) self.service_grade = service_grade result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ListAutoTypeConsumableItemsRequest.pre_deserialize(json_dict) if result[0]: self.auto_type_id = json_dict[Keys.AUTO_TYPE_ID] self.service_type_id = json_dict[Keys.SERVICE_TYPE_ID] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = CancellationByCarOwnerRequest.pre_deserialize(json_dict) if result[0]: self.job = Job(json_dict[Keys.JOB_ID]) self.car_owner = CarOwner( id=SessionManager.retrieve_session_value_by_key(Keys.USER_ID)) result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self.job return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = JobBaseRequest.pre_deserialize(json_dict) if not result[0]: return result result = JobBaseRequest.generate_appropriate_request( json_dict[Keys.USER_TYPE], JobBaseRequest.dct) if not result[0]: res = False, result[1].params return res return JobBaseRequest.child_class_deserialize(result[1], json_dict)
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = AdminRegistrationRequest.pre_deserialize(json_dict) if result[0]: self.name = json_dict['name'] self.last_name = json_dict['last_name'] self.password = json_dict['password'] self.phone_number = json_dict['phone_number'] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = BusinessOwnerUpdateLocationRequest.pre_deserialize(json_dict) if not result[0]: return result self.business_owner = BusinessOwner( id=json_dict[Keys.BUSINESS_OWNER_ID], lat=json_dict[Keys.LATITUDE], lng=json_dict[Keys.LONGITUDE]) result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ScheduleAppointmentRequest.pre_deserialize(json_dict) if result[0]: job = ScheduleAppointmentRequest.extract_job(json_dict) car_problem = ScheduleAppointmentRequest.extract_problem(json_dict) self.car_problem = car_problem self.job = job result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = FullRequest.pre_deserialize(json_dict) if not result[0]: return result self.job = Job(id=json_dict[Keys.JOB_ID]) self.payment = FullPayment(payment_type_id=json_dict[Keys.PAYMENT_TYPE], amount=json_dict[Keys.PAYMENT_AMOUNT], currency='IRR', transaction_number=json_dict[Keys.TRANSACTION_NUMBER]) result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ChangePasswordRequest.pre_deserialize(json_dict) if result[0]: self.phone_number = SessionManager.retrieve_session_value_by_key( Keys.PHONE_NUMBER) self.old_password = json_dict[Keys.OLD_PASSWORD] self.new_password = json_dict[Keys.NEW_PASSWORD] self.type_user = json_dict[Keys.TYPE_USER] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = SupplierRegistrationRequest.pre_deserialize(json_dict) if result[0]: supplier = Supplier(name=json_dict[Keys.NAME], password=json_dict[Keys.PASSWORD], business_license=json_dict[Keys.BUSINESS_LICENSE], phone_number=json_dict[Keys.PHONE_NUMBER], address=json_dict[Keys.ADDRESS]) self.supplier = supplier result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ListSearchIWSRequest.pre_deserialize(json_dict) if result[0]: self.options = json_dict['options'] self.service_grade = json_dict['service_grade'] # self.business_owner_type = json_dict['business_owner_type'] self.service_category = json_dict['service_category'] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, result_pattern[1] return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = RateJobRequest.pre_deserialize(json_dict) res = self.is_session_valid() if not res: return False, Result.language.SESSION_KEY_IS_NOT_VALID if result: self.phone_number = SessionManager.retrieve_session_value_by_key( key=Keys.PHONE_NUMBER) self.rate = json_dict[Keys.RATE] self.job_id = json_dict[Keys.JOB_ID] result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = AutoServiceRequest.pre_deserialize(json_dict) if result[0]: job = AutoServiceRequest.extract_job(json_dict) car_problem = AutoServiceRequest.extract_problem(json_dict) service_definition = AutoServiceRequest.extract_service_definition( json_dict) # self.car_problem = car_problem self.job = job self.car_problems = car_problem self.service_definition = service_definition # self.job.car_problems.extend(car_problem) result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = SearchOnProductsRequest.pre_deserialize(json_dict) res = self.is_session_valid() if not res: return False, Result.language.SESSION_KEY_IS_NOT_VALID if result[0]: self.options = json_dict[Keys.OPTIONS] self.phone_number = SessionManager.retrieve_session_value_by_key(key=Keys.PHONE_NUMBER) self.supplier_id = SessionManager.retrieve_session_value_by_key(key=Keys.USER_ID) self.options[Keys.SUPPLIER_ID] = self.supplier_id result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, result_pattern[1] return result
def deserialize(self): if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = UpdateCarRequest.pre_deserialize(json_dict) if result[0]: vin_number = json_dict['car_info']['vin_number'] plate_number = json_dict['car_info']['plate_number'] auto_type = json_dict['car_info']['auto_type'] car_id = json_dict['car_id'] car = Car( id=car_id, vin_number=vin_number, plate_number=plate_number, auto_type_id=auto_type, car_owner_id=SessionManager.retrieve_session_value_by_key( Keys.USER_ID)) self.car = car result_pattern = self.post_deserialize() if not result_pattern[0]: return result_pattern return True, self return result
def deserialize(self): if self.state_id == Keys.PHONE_NUMBER: if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ForgetPasswordRequest.pre_deserialize_state_phone_number( json_dict) if result[0]: self.phone_number = self.json_obj[Keys.PHONE_NUMBER] self.type_user = self.json_obj[Keys.TYPE_USER] session[Keys.FORGET_PASS][Keys.TYPE_USER] = self.json_obj[ Keys.TYPE_USER] result_pattern = self.post_deserialize_state_phone_number() if not result_pattern[0]: return result_pattern return True, self else: return result elif self.state_id == Keys.CODE: if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ForgetPasswordRequest.pre_deserialize_state_code( json_dict) if result[0]: self.phone_number = self.json_obj[Keys.PHONE_NUMBER] self.code = json_dict[Keys.CODE] result_pattern = self.post_deserialize_state_state_code() if not result_pattern[0]: session[Keys.FORGET_PASS][ Keys.STATE_ID] = Keys.PHONE_NUMBER return result_pattern return True, self else: session[Keys.FORGET_PASS][Keys.STATE_ID] = Keys.PHONE_NUMBER return result elif self.state_id == Keys.PASSWORD: self.phone_number = session[Keys.FORGET_PASS][Keys.USER_ID] if not type(self.json_obj) is dict: json_dict = Serializable.convert_input_to_dict(self.json_obj) else: json_dict = self.json_obj result = ForgetPasswordRequest.pre_deserialize_state_password( json_dict) if result[0]: self.password = json_dict[Keys.PASSWORD] result_pattern = self.post_deserialize_state_password() if not result_pattern[0]: return result_pattern return True, self else: return result elif self.state_id == Keys.RESEND_CODE: return True, self else: return False, Result.language.WRONG_STATE