Class: SealineInsurance::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sealine_insurance/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/sealine_insurance/client.rb', line 5

def initialize(**args)
  @config = Config.new(**args)
end

Instance Method Details

#calculate(**args) ⇒ Object



46
47
48
# File 'lib/sealine_insurance/client.rb', line 46

def calculate(**args)
  Operations::Calculate.new(config: @config, **args).tap(&:call)
end

#calculate_status_listObject



21
22
23
# File 'lib/sealine_insurance/client.rb', line 21

def calculate_status_list
  classifiers(path: 'status/calculate-product')
end

#cancel_order(**args) ⇒ Object



63
64
65
# File 'lib/sealine_insurance/client.rb', line 63

def cancel_order(**args)
  Operations::CancelOrder.new(config: @config, **args).tap(&:call)
end

#classifiers(path:) ⇒ Object



33
34
35
36
# File 'lib/sealine_insurance/client.rb', line 33

def classifiers(path:)
  response = request.get("/classifiers/#{path}")
  Responses::Base.new(response)
end

#create_order(**args) ⇒ Object



50
51
52
# File 'lib/sealine_insurance/client.rb', line 50

def create_order(**args)
  Operations::CreateOrder.new(config: @config, **args).tap(&:call)
end

#create_payment(**args) ⇒ Object



59
60
61
# File 'lib/sealine_insurance/client.rb', line 59

def create_payment(**args)
  Operations::CreatePayment.new(config: @config, **args).tap(&:call)
end

#get_order(order_id:) ⇒ Object



54
55
56
57
# File 'lib/sealine_insurance/client.rb', line 54

def get_order(order_id:)
  raw_response = request.get("/order/#{order_id}")
  Responses::Order.new(raw_response)
end

#order_status_listObject



25
26
27
# File 'lib/sealine_insurance/client.rb', line 25

def order_status_list
  classifiers(path: 'status/order')
end

#payment_status_listObject



29
30
31
# File 'lib/sealine_insurance/client.rb', line 29

def payment_status_list
  classifiers(path: 'status/payment')
end

#product_type(id:) ⇒ Object



13
14
15
# File 'lib/sealine_insurance/client.rb', line 13

def product_type(id:)
  classifiers(path: "product-type/#{id}")
end

#product_typesObject



9
10
11
# File 'lib/sealine_insurance/client.rb', line 9

def product_types
  classifiers(path: 'product-type')
end

#productsObject



17
18
19
# File 'lib/sealine_insurance/client.rb', line 17

def products
  classifiers(path: 'product')
end

#search_products(product_type:, options: []) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/sealine_insurance/client.rb', line 38

def search_products(product_type:, options: [])
  response = request.post('/search',
    product_type: product_type,
    options: options,
  )
  Responses::Base.new(response)
end