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, 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

#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

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
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)


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

#createObject

Raises:

  • (NotImplementedError)


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_productsObject



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