Class: AlfaInsurance::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/alfa_insurance/base_client.rb

Direct Known Subclasses

BusClient

Constant Summary collapse

SANDBOX_WSDL =
'https://uat-tes.alfastrah.ru/travel-ext-services/TravelExtService?wsdl'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug: false, wsdl: SANDBOX_WSDL, operator:, product_code:, timeout: 5) ⇒ BaseClient

Returns a new instance of BaseClient.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/alfa_insurance/base_client.rb', line 7

def initialize(debug: false, wsdl: SANDBOX_WSDL, operator:, product_code:, timeout: 5)
  if debug
    @log_level = :debug
    @log = true
  else
    @log = false
  end
  @wsdl = wsdl
  @operator = operator
  @product_code = product_code
  @timeout = timeout
end

Instance Attribute Details

#logObject

Returns the value of attribute log.



5
6
7
# File 'lib/alfa_insurance/base_client.rb', line 5

def log
  @log
end

#log_levelObject

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

#operatorObject

Returns the value of attribute operator.



5
6
7
# File 'lib/alfa_insurance/base_client.rb', line 5

def operator
  @operator
end

#product_codeObject

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

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/alfa_insurance/base_client.rb', line 5

def timeout
  @timeout
end

#wsdlObject

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

#calculateObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/alfa_insurance/base_client.rb', line 33

def calculate(*)
  raise NotImplementedError
end

#cancel(insurance_id) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/alfa_insurance/base_client.rb', line 49

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



41
42
43
44
45
46
47
# File 'lib/alfa_insurance/base_client.rb', line 41

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

#createObject

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/alfa_insurance/base_client.rb', line 37

def create(*)
  raise NotImplementedError
end

#find(insurance_id) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/alfa_insurance/base_client.rb', line 57

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_productsObject



20
21
22
23
24
# File 'lib/alfa_insurance/base_client.rb', line 20

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



26
27
28
29
30
31
# File 'lib/alfa_insurance/base_client.rb', line 26

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