Class: AlfaInsurance::BaseClient
- Inherits:
-
Object
- Object
- AlfaInsurance::BaseClient
- Defined in:
- lib/alfa_insurance/base_client.rb
Direct Known Subclasses
Constant Summary collapse
- SANDBOX_WSDL =
'https://uat-tes.alfastrah.ru/travel-ext-services/TravelExtService?wsdl'.freeze
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#product_code ⇒ Object
Returns the value of attribute product_code.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#wsdl ⇒ Object
Returns the value of attribute wsdl.
Instance Method Summary collapse
- #calculate ⇒ Object
- #cancel(insurance_id) ⇒ Object
- #confirm(insurance_id) ⇒ Object
- #create ⇒ Object
- #find(insurance_id) ⇒ Object
- #get_available_products ⇒ Object
- #get_policy_parameters(product_code) ⇒ Object
-
#initialize(debug: false, wsdl: SANDBOX_WSDL, operator:, product_code:, timeout: 5, logger: nil) ⇒ BaseClient
constructor
A new instance of BaseClient.
Constructor Details
#initialize(debug: false, wsdl: SANDBOX_WSDL, operator:, product_code:, timeout: 5, logger: nil) ⇒ BaseClient
Returns a new instance of BaseClient.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/alfa_insurance/base_client.rb', line 7 def initialize(debug: false, wsdl: SANDBOX_WSDL, operator:, product_code:, timeout: 5, logger: nil) if debug @log_level = :debug @log = true else @log = false end @wsdl = wsdl @operator = operator @product_code = product_code @timeout = timeout @logger = logger end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
5 6 7 |
# File 'lib/alfa_insurance/base_client.rb', line 5 def log @log end |
#log_level ⇒ Object
Returns the value of attribute log_level.
5 6 7 |
# File 'lib/alfa_insurance/base_client.rb', line 5 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/alfa_insurance/base_client.rb', line 5 def logger @logger end |
#operator ⇒ Object
Returns the value of attribute operator.
5 6 7 |
# File 'lib/alfa_insurance/base_client.rb', line 5 def operator @operator end |
#product_code ⇒ Object
Returns the value of attribute product_code.
5 6 7 |
# File 'lib/alfa_insurance/base_client.rb', line 5 def product_code @product_code end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/alfa_insurance/base_client.rb', line 5 def timeout @timeout end |
#wsdl ⇒ Object
Returns the value of attribute wsdl.
5 6 7 |
# File 'lib/alfa_insurance/base_client.rb', line 5 def wsdl @wsdl end |
Instance Method Details
#calculate ⇒ Object
35 36 37 |
# File 'lib/alfa_insurance/base_client.rb', line 35 def calculate(*) raise NotImplementedError end |
#cancel(insurance_id) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/alfa_insurance/base_client.rb', line 51 def cancel(insurance_id) response = send_soap_request(:cancel_policy) do |xml| xml.operator { xml.code(operator) } xml.policyId(insurance_id) end Response.new(response) end |
#confirm(insurance_id) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/alfa_insurance/base_client.rb', line 43 def confirm(insurance_id) response = send_soap_request(:confirm_policy) do |xml| xml.operator { xml.code(operator) } xml.policyId(insurance_id) end ConfirmResponse.new(response) end |
#create ⇒ Object
39 40 41 |
# File 'lib/alfa_insurance/base_client.rb', line 39 def create(*) raise NotImplementedError end |
#find(insurance_id) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/alfa_insurance/base_client.rb', line 59 def find(insurance_id) response = send_soap_request(:get_policy) do |xml| xml.operator { xml.code(operator) } xml.policyId(insurance_id) end FindResponse.new(response) end |
#get_available_products ⇒ Object
22 23 24 25 26 |
# File 'lib/alfa_insurance/base_client.rb', line 22 def get_available_products send_soap_request(:get_available_products) do |xml| xml.operator { xml.code(operator) } end.body end |
#get_policy_parameters(product_code) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/alfa_insurance/base_client.rb', line 28 def get_policy_parameters(product_code) send_soap_request(:get_policy_parameters) do |xml| xml.operator { xml.code(operator) } xml.product { xml.code(product_code) } end.body end |