def get_verify_sms_token(self, mobile, token, insurance_centre_sub_domain, alias_name, resource, x_api_key): """Does a GET request to /Account/verifySmsToken. تایید توکن پیامک شده به کاربر، برای احراز هویت Args: mobile (string): شماره موبایل token (int): توکن دریافتی کاربر از پیامک insurance_centre_sub_domain (string): دامنه یا زیر دامنه ی اختصاصی مرکز بیمه alias_name (string): نام و نام خانوادگی کاربر resource (string): دامنه ی درخواست دهنده x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: Status200: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/Account/verifySmsToken' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'mobile': mobile, 'token': token, 'insuranceCentreSubDomain': insurance_centre_sub_domain, 'aliasName': alias_name, 'resource': resource } _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _context.response.status_code == 400: raise Status400Exception('Bad Request', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, Status200.from_dictionary)
def add_query_parameter(self, name, value): """ Add a query parameter to the HttpRequest. Args: name (string): The name of the query parameter. value (string): The value of the query parameter. """ self.query_url = APIHelper.append_url_with_query_parameters(self.query_url, {name:value}) self.query_url = APIHelper.clean_url(self.query_url)
def get_insurance_policy_tracking(self, tracking_code, national_code, x_api_key): """Does a GET request to /InsurancePolicy/Tracking. پیگیری وضعیت بیمه نامه Args: tracking_code (int): شماره ی پیگیری بیمه نامه national_code (long|int): کد ملی کاربر x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelInsurancePolicyTracking: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/InsurancePolicy/Tracking' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'trackingCode': tracking_code, 'nationalCode': national_code } _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _context.response.status_code == 500: raise InternalServerErrorException('Internal Server Error', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, BaseModelInsurancePolicyTracking.from_dictionary)
def get_tracking_code(self, tracking_code, x_api_key): """Does a GET request to /TrackingDamage/TrackingCode/. استعلام وضعیت خسارت Args: tracking_code (string): کد پیگیری خسارت x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelTrakingCode: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/TrackingDamage/TrackingCode/' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { '/{TrackingCode}': tracking_code } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key } # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) # Endpoint and global error handling using HTTP status codes. if _context.response.status_code == 400: raise Status400Exception('Bad Request', _context) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, BaseModelTrakingCode.from_dictionary)
def test_insurance_policy_tracking(self): # Parameters for the API call tracking_code = 213981083 national_code = 3080115309 x_api_key = 'd6dfd932-75d8-e911-811a-000c294ecf01' # Perform the API call through the SDK function result = self.controller.get_insurance_policy_tracking( tracking_code, national_code, x_api_key) # Test response code self.assertEquals(self.response_catcher.response.status_code, 200) # Test headers expected_headers = {} expected_headers['date'] = None expected_headers['content-type'] = None expected_headers['transfer-encoding'] = None expected_headers['connection'] = None expected_headers['keep-alive'] = None expected_headers['vary'] = None expected_headers['cache-control'] = None expected_headers['pragma'] = None expected_headers['expires'] = None expected_headers['x-stackifyid'] = None expected_headers['x-aspnet-version'] = None expected_headers['x-powered-by'] = None expected_headers['server'] = None expected_headers['ar-poweredby'] = None expected_headers['ar-sid'] = None expected_headers['ar-atime'] = None expected_headers['ar-cache'] = None expected_headers['ar-request-id'] = None expected_headers['content-encoding'] = None self.assertTrue( TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) # Test whether the captured response is as we expected self.assertIsNotNone(result) expected_body = APIHelper.json_deserialize( '{"isSuccess":true,"status":200,"message":{"id":1129,"aliasName":"کاظم ملکی' '","status":"ثبت اولیه","createOnPersianDate":"1398/04/12 13:00","centerName' '":"کارگزاری بیمه حافظان آرامش","insurancePolicyType":8,"insuranceType":"بیم' 'ه درمان خانواده","price":1890060,"paymented":null},"extraData":null,"except' 'ion":null}') received_body = APIHelper.json_deserialize( self.response_catcher.response.raw_body) self.assertTrue(TestHelper.match_body(expected_body, received_body))
def get_has_plan(self, sub_domain, insurance_policy_type, x_api_key): """Does a GET request to /InsurancePolicyPlan/HasPlan. آیا این نوع بیمه نامه، طرح بیمه ای دارد؟ Args: sub_domain (string): دامنه یا زیر دامنه ی مرکز بیمه insurance_policy_type (int): شناسه ی نوع بیمه نامه => بیمه بدنه=2 x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: HasPlan: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/InsurancePolicyPlan/HasPlan' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'subDomain': sub_domain, 'insurancePolicyType': insurance_policy_type } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key } # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, HasPlan.from_dictionary)
def get_fire_insurance(self, sub_domain, insurance_policy_id, x_api_key): """Does a GET request to /FireInsurance/Initialize. دریافت اطلاعات پایه بیمه ی آتش سوزی Args: sub_domain (string): دامنه یا زیر دامنه ی مرکز بیمه insurance_policy_id (int): شناسه ی بیمه نامه x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelFireInsurance: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/FireInsurance/Initialize' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'subDomain': sub_domain, 'insurancePolicyId': insurance_policy_id } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key } # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, BaseModelFireInsurance.from_dictionary)
def upload(self, sub_domain, x_api_key, file): """Does a POST request to /FileManager/Upload. آپلود فایل در ایزی بیمه بعد از آپلود، ادرس فایل باید در api های بعدی ارسال شود. Args: sub_domain (string): دامنه یا زیر دامنه ی مرکز بیمه x_api_key (string): کلید اختصاصی ارتباط با سرور file (string): فایل ارسالی Returns: BaseModelUpload: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/FileManager/Upload' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'subDomain': sub_domain} _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare form parameters _form_parameters = {'file': file} # Prepare and execute request _request = self.http_client.post(_query_url, headers=_headers, parameters=_form_parameters) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, BaseModelUpload.from_dictionary)
def execute_request(self, request, binary=False): """Executes an HttpRequest. Args: request (HttpRequest): The HttpRequest to execute. binary (bool): A flag which should be set to True if a binary response is expected. Returns: HttpContext: The HttpContext of the request. It contains, both, the request itself and the HttpResponse object. """ # Invoke the on before request HttpCallBack if specified if self.http_call_back != None: self.http_call_back.on_before_request(request) # Add global headers to request request.headers = APIHelper.merge_dicts(self.global_headers, request.headers) # Invoke the API call to fetch the response. func = self.http_client.execute_as_binary if binary else self.http_client.execute_as_string response = func(request) context = HttpContext(request, response) # Invoke the on after response HttpCallBack if specified if self.http_call_back != None: self.http_call_back.on_after_response(context) return context
def get_send_sms_token(self, mobile, insurance_centre_sub_domain, x_api_key): """Does a GET request to /Account/SendSmsToken. ارسال توکن تایید شماره تماس، برای احراز هویت کاربر Args: mobile (string): شماره موبایل insurance_centre_sub_domain (string): دامنه یا زیردامنه ی مرکز بیمه x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: SendSmsToken: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/Account/SendSmsToken' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'mobile': mobile, 'insuranceCentreSubDomain': insurance_centre_sub_domain } _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, SendSmsToken.from_dictionary)
def get_medical_specialties(self, id, x_api_key): """Does a GET request to /MedicalSpecialties. دریافت لیست تخصص های پزشکی Args: id (string): نوع تخصص => ParamedicalExpertise => پیراپزشکی MedicalExpertise => پزشکی x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelMedicalSpecialties: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/MedicalSpecialties' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'id': id } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key } # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, BaseModelMedicalSpecialties.from_dictionary)
def get_risk_level(self, insurance_policy_type, x_api_key): """Does a GET request to /ComboData/RiskLevel. دریافت لیست تخفیف های بیمه Args: insurance_policy_type (int): شناسه ی نوع بیمه نامه x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: RiskLevel: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/ComboData/RiskLevel' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'insurancePolicyType': insurance_policy_type } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key } # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, RiskLevel.from_dictionary)
def get_device_brand_types(self, device_group, device_type_id, x_api_key): """Does a GET request to /ComboData/DeviceBrandTypes. دریافت لیست نوع برند دستگاه Args: device_group (int): شناسه ی گروه دستگاه device_type_id (int): شناسه ی نوع دستگاه x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelDeviceBrandTypes: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/ComboData/DeviceBrandTypes' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'deviceGroup': device_group, 'deviceTypeId': device_type_id } _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, BaseModelDeviceBrandTypes.from_dictionary)
def get_status(self, entity_id, x_api_key): """Does a GET request to /Status. دریافت اطلاعات وضعیت Args: entity_id (int): شناسه ی وضعیت x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelStatus: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/Status' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'entityId': entity_id } _query_builder = APIHelper.append_url_with_query_parameters(_query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key } # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, BaseModelStatus.from_dictionary)
def get_insurance_types(self, sub_domain, issue_insurance, x_api_key): """Does a GET request to /ComboData/InsuranceTypes. دریافت لیست نوع بیمه نامه Args: sub_domain (string): دامنه یا زیر دامنه ی مرکز بیمه issue_insurance (bool): دریافت بیمه نامه های قابل صدور x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: InsuranceTypes: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/ComboData/InsuranceTypes' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = { 'subDomain': sub_domain, 'issueInsurance': issue_insurance } _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, InsuranceTypes.from_dictionary)
def test_divice_franchisee(self): # Parameters for the API call device_model_id = 1340 x_api_key = 'd6dfd932-75d8-e911-811a-000c294ecf01' # Perform the API call through the SDK function result = self.controller.get_divice_franchisee(device_model_id, x_api_key) # Test response code self.assertEquals(self.response_catcher.response.status_code, 200) # Test headers expected_headers = {} expected_headers['date'] = None expected_headers['content-type'] = None expected_headers['transfer-encoding'] = None expected_headers['connection'] = None expected_headers['keep-alive'] = None expected_headers['vary'] = None expected_headers['cache-control'] = None expected_headers['pragma'] = None expected_headers['expires'] = None expected_headers['x-stackifyid'] = None expected_headers['x-aspnet-version'] = None expected_headers['x-powered-by'] = None expected_headers['server'] = None expected_headers['ar-poweredby'] = None expected_headers['ar-sid'] = None expected_headers['ar-atime'] = None expected_headers['ar-cache'] = None expected_headers['ar-request-id'] = None expected_headers['content-encoding'] = None self.assertTrue(TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) # Test whether the captured response is as we expected self.assertIsNotNone(result) expected_body = APIHelper.json_deserialize( '{"isSuccess":true,"status":200,"message":[{"id":5404,"title":"30%","extraD' 'ata":null},{"id":5401,"title":"40%","extraData":null}],"extraData":null,"ex' 'ception":null}' ) received_body = APIHelper.json_deserialize(self.response_catcher.response.raw_body) self.assertTrue(TestHelper.match_body(expected_body, received_body))
def create_tracking_damage(self, body, x_api_key, content_type): """Does a POST request to /TrackingDamage. ثبت خسارت بیمه Args: body (TrackingDamageRequest): اطلاعات خسارت x_api_key (string): کلید اختصاصی ارتباط با سرور content_type (string): TODO: type description here. Example: Returns: TrackingDamage: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/TrackingDamage' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key, 'Content-Type': content_type } # Prepare and execute request _request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body)) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, TrackingDamage.from_dictionary)
def get_portal_landing_page(self, id, x_api_key): """Does a GET request to /InsuranceCentre/PortalLandingPage. در یافت اطلاعات لندینگ مراکز بیمه Args: id (string): دامنه یا زیر دامنه ی مرکز بیمه x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelPortalLandingPage: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/InsuranceCentre/PortalLandingPage' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'id': id} _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, BaseModelPortalLandingPage.from_dictionary)
def get_divice_franchisee(self, device_model_id, x_api_key): """Does a GET request to /ElectronicEquipmentInsurance/DiviceFranchisee. دریافت لیست فرانشیر استعلام بیمه نامه ی تجهیزات الکترونیک Args: device_model_id (int): شناسه ی مدل دستگاه x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelDiviceFranchisee: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/ElectronicEquipmentInsurance/DiviceFranchisee' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_parameters = {'deviceModelId': device_model_id} _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, Configuration.array_serialization) _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, BaseModelDiviceFranchisee.from_dictionary)
def get_car_brand(self, x_api_key): """Does a GET request to /ComboData/CarBrands. دریافت برند خودرو Args: x_api_key (string): شناسه ی اختصاصی ارتباط با سرور Returns: CarBrand: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/ComboData/CarBrands' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = { 'accept': 'application/json', 'x-api-key': x_api_key } # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize(_context.response.raw_body, CarBrand.from_dictionary)
def __init__(self, reason, context): """Constructor for the InternalServerErrorException class Args: reason (string): The reason (or error message) for the Exception to be raised. context (HttpContext): The HttpContext of the API call. """ super(InternalServerErrorException, self).__init__(reason, context) dictionary = APIHelper.json_deserialize(self.context.response.raw_body) if isinstance(dictionary, dict): self.unbox(dictionary)
def get_faq_insurance_centre(self, x_api_key): """Does a GET request to /Faq/InsuranceCentre/hfz1. دریافت لیست سوالات متداول Args: x_api_key (string): کلید اختصاصی ارتباط با سرور Returns: BaseModelFaqInsuranceCentre: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/Faq/InsuranceCentre/hfz1' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, BaseModelFaqInsuranceCentre.from_dictionary)
def get_portal_landing_contact_about(self, x_api_key): """Does a GET request to /InsuranceCentre/PortalLandingContactAbout/hfz1. دریافت اطلاعات درباره ی ما Args: x_api_key (string): TODO: type description here. Example: Returns: BaseModelPortalLandingContactAbout: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # Prepare query URL _url_path = '/InsuranceCentre/PortalLandingContactAbout/hfz1' _query_builder = Configuration.get_base_uri() _query_builder += _url_path _query_url = APIHelper.clean_url(_query_builder) # Prepare headers _headers = {'accept': 'application/json', 'x-api-key': x_api_key} # Prepare and execute request _request = self.http_client.get(_query_url, headers=_headers) _context = self.execute_request(_request) self.validate_response(_context) # Return appropriate type return APIHelper.json_deserialize( _context.response.raw_body, BaseModelPortalLandingContactAbout.from_dictionary)
def test_faq_insurance_centre(self): # Parameters for the API call x_api_key = 'd6dfd932-75d8-e911-811a-000c294ecf01' # Perform the API call through the SDK function result = self.controller.get_faq_insurance_centre(x_api_key) # Test response code self.assertEquals(self.response_catcher.response.status_code, 200) # Test headers expected_headers = {} expected_headers['date'] = None expected_headers['content-type'] = None expected_headers['content-length'] = None expected_headers['connection'] = None expected_headers['keep-alive'] = None expected_headers['cache-control'] = None expected_headers['pragma'] = None expected_headers['content-encoding'] = None expected_headers['expires'] = None expected_headers['x-stackifyid'] = None expected_headers['x-aspnet-version'] = None expected_headers['x-powered-by'] = None expected_headers['server'] = None expected_headers['ar-poweredby'] = None expected_headers['ar-sid'] = None expected_headers['ar-atime'] = None expected_headers['ar-cache'] = None expected_headers['ar-request-id'] = None self.assertTrue( TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) # Test whether the captured response is as we expected self.assertIsNotNone(result) expected_body = APIHelper.json_deserialize( '{"isSuccess":true,"status":200,"message":[{"id":1009,"insuranceCentreId":2' ',"question":"بیمه شخص ثالث چیست؟","answer":"بیمه شخص ثالث یکی از انواع بیمه' ' خودرو است که خسارات جانی و مالی وارد شده به اشخاص زیاندیده را پرداخت میک' 'ند. داشتن بیمه شخص ثالث برای تمامی وسایل نقلیه موتوری اجباری است.","sortPri' 'ority":0,"questionGroupParamId":2,"isActive":true,"theInsuranceCentre":null' ',"theQuestionGroupParam":null,"createOn":"2018-06-17T00:00:00","updateOn":"' '2019-04-13T11:17:49.51","createdBy":"fbddedc4-0804-409d-91ee-cb062ef33f42",' '"updatedBy":"fbddedc4-0804-409d-91ee-cb062ef33f42","createOnPersianDate":"1' '397/03/27 00:00","updateOnPersianDate":"1398/01/24 11:17"},{"id":1010,"insu' 'ranceCentreId":2,"question":"آیا پس از تایید شماره همراه در مراحل ثبت نام، ' 'میتوانم شماره خود را تغییر دهم؟","answer":"شما زمانی میتوانید شماره خود را ' 'تغییر دهید که شماره ی همراه جدید نیز تایید شود. \\r\\n\\r\\n در صورتی که ش' 'ماره همراه خود را به فردی دیگر واگذار کردید، جهت جلوگیری از سواستفاده یا مش' 'کلات احتمالی، شماره موبایل خود را در پروفایل تغییر داده و شماره جدیدی ثبت ن' 'مایید.","sortPriority":null,"questionGroupParamId":2,"isActive":true,"theIn' 'suranceCentre":null,"theQuestionGroupParam":null,"createOn":"2018-06-19T10:' '34:51.217","updateOn":"2019-04-13T11:17:49.51","createdBy":"fbddedc4-0804-4' '09d-91ee-cb062ef33f42","updatedBy":null,"createOnPersianDate":"1397/03/29 1' '0:34","updateOnPersianDate":"1398/01/24 11:17"},{"id":1012,"insuranceCentre' 'Id":2,"question":"منظور از شخص ثالث در بیمه شخص ثالث چیست؟","answer":"در بی' 'مه شخص ثالث، شخص اول شخص بیمهگزار (کسی که برای وسیله نقلیهای بیمه شخص ثال' 'ث خریداری میکند)، شخص ثانی، بیمهگر یا شرکت بیمه و شخص ثالث فرد یا افرادی ' 'هستند در حادثه رانندگی زیان دیدهاند به جز راننده مقصر.","sortPriority":nul' 'l,"questionGroupParamId":2,"isActive":true,"theInsuranceCentre":null,"theQu' 'estionGroupParam":null,"createOn":"2018-08-19T16:02:22.87","updateOn":"2019' '-04-13T11:17:49.51","createdBy":"fbddedc4-0804-409d-91ee-cb062ef33f42","upd' 'atedBy":null,"createOnPersianDate":"1397/05/28 16:02","updateOnPersianDate"' ':"1398/01/24 11:17"},{"id":1013,"insuranceCentreId":2,"question":"نداشتن بی' 'مه شخص ثالث، چه مشکلاتی برای من ایجاد میکند؟","answer":"اولاً حرکت وسیله ن' 'قلیه بدون داشتن بیمه شخص ثالث، ممنوع است و پلیس راهنمایی رانندگی در هر زمان' 'ی که متوجه نداشتن بیمه شخص ثالث یک وسیله نقلیه شود، میتواند آن را توقیف کن' 'د. درصورتیکه یک وسیله نقلیه دارای بیمهنامه شخص ثالث نباشد و دچار حادثه شو' 'د، راننده تا زمان پرداخت خسارت جانی و مالی اشخاص زیاندیده، زندانی میشود. ' 'همچنین، در هر زمان که راننده بخواهد بیمه شخص ثالث بخرد، باید جریمه دیرکرد آ' 'ن را که قابل بخشش نیست، بپردازد. از سوی دیگر، فروش وسیله نقلیه فاقد بیمه شخ' 'ص ثالث، امکانپذیر نیست.","sortPriority":null,"questionGroupParamId":2,"isA' 'ctive":true,"theInsuranceCentre":null,"theQuestionGroupParam":null,"createO' 'n":"2018-08-19T16:02:50.603","updateOn":"2019-04-13T11:17:49.51","createdBy' '":"fbddedc4-0804-409d-91ee-cb062ef33f42","updatedBy":null,"createOnPersianD' 'ate":"1397/05/28 16:02","updateOnPersianDate":"1398/01/24 11:17"},{"id":101' '4,"insuranceCentreId":2,"question":"بیمه شخص ثالث برای من چه فایدهای دارد؟' '","answer":"علاوه بر آنکه خرید بیمه شخص ثالث برای تمامی دارندگان وسایل نقلی' 'ه موتوری الزامی است، داشتن این بیمه میتواند خسارات مالی و جانی ناشی از برو' 'ز حادثه را که میتواند تا مرز صدها میلیون تومان باشد، جبران نماید.","sortPr' 'iority":null,"questionGroupParamId":2,"isActive":true,"theInsuranceCentre":' 'null,"theQuestionGroupParam":null,"createOn":"2018-08-19T16:03:30.28","upda' 'teOn":"2019-04-13T11:17:49.51","createdBy":"fbddedc4-0804-409d-91ee-cb062ef' '33f42","updatedBy":null,"createOnPersianDate":"1397/05/28 16:03","updateOnP' 'ersianDate":"1398/01/24 11:17"},{"id":1015,"insuranceCentreId":2,"question"' ':"نداشتن بیمه شخص ثالث، چه مشکلاتی برای من ایجاد میکند؟","answer":"اولاً ح' 'رکت وسیله نقلیه بدون داشتن بیمه شخص ثالث، ممنوع است و پلیس راهنمایی رانندگی' ' در هر زمانی که متوجه نداشتن بیمه شخص ثالث یک وسیله نقلیه شود، میتواند آن ' 'را توقیف کند. درصورتیکه یک وسیله نقلیه دارای بیمهنامه شخص ثالث نباشد و دچ' 'ار حادثه شود، راننده تا زمان پرداخت خسارت جانی و مالی اشخاص زیاندیده، زندا' 'نی میشود. همچنین، در هر زمان که راننده بخواهد بیمه شخص ثالث بخرد، باید جری' 'مه دیرکرد آن را که قابل بخشش نیست، بپردازد. از سوی دیگر، فروش وسیله نقلیه ف' 'اقد بیمه شخص ثالث، امکانپذیر نیست.","sortPriority":null,"questionGroupPara' 'mId":2,"isActive":true,"theInsuranceCentre":null,"theQuestionGroupParam":nu' 'll,"createOn":"2018-08-19T16:03:55.527","updateOn":"2019-04-13T11:17:49.51"' ',"createdBy":"fbddedc4-0804-409d-91ee-cb062ef33f42","updatedBy":null,"creat' 'eOnPersianDate":"1397/05/28 16:03","updateOnPersianDate":"1398/01/24 11:17"' '}],"extraData":null,"exception":null}') received_body = APIHelper.json_deserialize( self.response_catcher.response.raw_body) self.assertTrue(TestHelper.match_body(expected_body, received_body))
def test_portal_landing_contact_about(self): # Parameters for the API call x_api_key = 'd6dfd932-75d8-e911-811a-000c294ecf01' # Perform the API call through the SDK function result = self.controller.get_portal_landing_contact_about(x_api_key) # Test response code self.assertEquals(self.response_catcher.response.status_code, 200) # Test headers expected_headers = {} expected_headers['date'] = None expected_headers['content-type'] = None expected_headers['content-length'] = None expected_headers['connection'] = None expected_headers['keep-alive'] = None expected_headers['cache-control'] = None expected_headers['pragma'] = None expected_headers['content-encoding'] = None expected_headers['expires'] = None expected_headers['x-stackifyid'] = None expected_headers['x-aspnet-version'] = None expected_headers['x-powered-by'] = None expected_headers['server'] = None expected_headers['ar-poweredby'] = None expected_headers['ar-sid'] = None expected_headers['ar-atime'] = None expected_headers['ar-cache'] = None expected_headers['ar-request-id'] = None self.assertTrue( TestHelper.match_headers(expected_headers, self.response_catcher.response.headers)) # Test whether the captured response is as we expected self.assertIsNotNone(result) expected_body = APIHelper.json_deserialize( '{"isSuccess":true,"status":200,"message":{"licensed":false,"insuranceGroup' '":[],"insuranceType":[],"summaryCards":[],"summaryNotics":[],"imageAlbums":' '[],"videoGalleries":[],"insuranceCentre":{"id":2,"personId":"fbddedc4-0804-' '409d-91ee-cb062ef33f42","personalityType":0,"insuranceCentreType":5,"regist' 'erStatus":99,"centerName":"میز کار مجازی بیمه ","centerCode":"1020","bran' 'chCount":null,"registrationNumber":"4121","freeUseGoldenPackExpireDate":"20' '19-06-17T12:46:51.763","cityId":329,"cashPayment":true,"showInEasyBimeh":tr' 'ue,"installmentsPayment":false,"isInitialApplicant":false,"branchsCount":9,' '"employeesCount":20,"zoneId":null,"smsChargingStock":null,"independentBranc' 'h":null,"disableReason":null,"termsConditions":null,"disableReasonDescripti' 'on":null,"unlimitedAccount":null,"whiteLabel":false,"phone":"02188207290","' 'fax":"","address":"استان تهران، تهران، خیابان گاندی، خیابان پانزدهم، شماره1' '5، واحد 1","zipCode":"","email":"*****@*****.**","paymentUrl":null,"call' 'backUrl":null,"callbackUrlWhitelabel":null,"webSite":"","latitude":35.6892,' '"longitude":51.389,"isActive":true,"insuranceCentreId":null,"cityRegionId":' 'null,"provinceId":8,"cityName":"تهران","metaMediaActivityLicenceId":20453,"' 'metaMediaActivityLicenceUrl":null,"createOnPersianDate":"1397/05/05 00:00",' '"insuranceCompanyId":[31,32,33,34,35,36,37,39],"activePackageId":9,"package' 'ActivationLastDate":"2019-08-31T14:49:47.55","licenseApiKey":null,"verifyRe' 'questUrl":null,"onlinePayment":true,"cardToCardPayment":true,"bankTransferP' 'ayment":true,"cashOnDelivery":true,"bankTransferSameOnlinePaymentInfo":fals' 'e,"bankParamId":109,"accountOwner":"فرزاد","accountNumber":"1761496408","ib' 'an":"550120000000001761496408","cardBankParamId":109,"cardAccountOwner":"فر' 'زاد","cardAccountNumber":"6104333344445555","bankTransferParamId":109,"bank' 'TransferAccountOwner":"فرزاد","bankTransferAccountNumber":"1761496408","ban' 'kTransferIBAN":"550120000000001761496408"},"insuranceCentrePortal":{"insura' 'nceCentreId":2,"centreName":"میز کار مجازی بیمه ","subDomainName":"hfz1",' '"title":"","subTitle":"","contactUs":null,"aboutUs":"","ourService":"<div i' 'temprop=\"mainContentOfPage\"><p>تمامی بیمه نامه ها با اعمال حداکثر تخفیفات' ' قانونی ویژه ، با تسهیل در پرداخت حق بیمه (بصورت قسطی) توسط هریک از شرکتهای' ' بیمه مورد نظر شما صادر خواهد گردید.</p></div>","termsConditions":null,"cop' 'yright":null,"headerTitle":null,"headerBody":null,"footerColor":null,"backg' 'roundColor":null,"licensed":false,"defaultLogo":null,"titleColor":"#ffffff"' ',"subTitleColor":"#ffffff","eTrustSymbol":null,"digitalMediaOrganizerSymbol' '":null,"googlePlus":"http://instagram.com","telegram":"http://telegram.com"' ',"instagram":"http://instagram.com","faceBook":"http://instagram.com","twit' 'ter":"http://instagram.com","saturdayToWednesdayFromHour":null,"saturdayToW' 'ednesdayToHour":null,"thursdayFromHour":null,"thursdayToHour":null,"fridayF' 'romHour":null,"fridayToHour":null,"metaMediaFileHeaderId":20817,"metaMediaF' 'ileHeaderUrl":"https://media.easybimeh.com//Easybimeh/FileManager/Insurance' 'Centre/hfz1/636780551712391762.jpg","metaMediaFileLogoId":81580,"metaMediaF' 'ileLogoUrl":"https://media.easybimeh.com//Easybimeh/FileManager/InsuranceCe' 'ntre/hfz1/636994283394589289.png","metaMediaFileFaviconId":162557,"metaMedi' 'aFileFaviconUrl":"https://media.easybimeh.com//Easybimeh/FileManager/Insura' 'nceCentre/hfz1/637082986134004537.jpeg","metaMediaFileFooterId":null,"metaM' 'ediaFileFooterUrl":null}},"extraData":null,"exception":null}') received_body = APIHelper.json_deserialize( self.response_catcher.response.raw_body) self.assertTrue(TestHelper.match_body(expected_body, received_body))