Class: SealineInsurance::Operations::CreateOrder
- Defined in:
- lib/sealine_insurance/operations/create_order.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #fetch_status! ⇒ Object
-
#initialize(config:, product_type:, product:, options: [], ticket_number:, ticket_price:, departure_datetime:, arrival_datetime:, insured_first_name:, insured_middle_name: nil, insured_last_name:, insured_birthday:, insurer_first_name:, insurer_middle_name: nil, insurer_last_name:) ⇒ CreateOrder
constructor
rubocop:disable Metrics/ParameterLists.
Methods inherited from Base
#finished?, #result, #success?
Constructor Details
#initialize(config:, product_type:, product:, options: [], ticket_number:, ticket_price:, departure_datetime:, arrival_datetime:, insured_first_name:, insured_middle_name: nil, insured_last_name:, insured_birthday:, insurer_first_name:, insurer_middle_name: nil, insurer_last_name:) ⇒ CreateOrder
rubocop:disable Metrics/ParameterLists
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sealine_insurance/operations/create_order.rb', line 7 def initialize( config:, product_type:, product:, options: [], ticket_number:, ticket_price:, departure_datetime:, arrival_datetime:, insured_first_name:, insured_middle_name: nil, insured_last_name:, insured_birthday:, insurer_first_name:, insurer_middle_name: nil, insurer_last_name: ) super(config: config) @product_type = product_type @product = product = @ticket_number = ticket_number @ticket_price = ticket_price @departure_datetime = departure_datetime @arrival_datetime = arrival_datetime @insured_first_name = insured_first_name @insured_middle_name = insured_middle_name @insured_last_name = insured_last_name @insured_birthday = insured_birthday @insurer_first_name = insurer_first_name @insurer_middle_name = insurer_middle_name @insurer_last_name = insurer_last_name end |
Instance Method Details
#call ⇒ Object
rubocop:enable Metrics/ParameterLists
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sealine_insurance/operations/create_order.rb', line 42 def call raw_response = request.post('/order', product_type: @product_type, product: @product, options: , data: { ticket_number: @ticket_number.to_i, ticket_price: @ticket_price.to_i, departure: @departure_datetime.strftime('%Y-%m-%dT%H:%M'), arrival: @arrival_datetime&.strftime('%Y-%m-%dT%H:%M'), insured: { first_name: @insured_first_name, middle_name: @insured_middle_name, last_name: @insured_last_name, birthday: @insured_birthday.strftime('%Y-%m-%d'), }.reject { |k, v| v.nil? }, insurer: { first_name: @insurer_first_name, middle_name: @insurer_middle_name, last_name: @insurer_last_name, }.reject { |k, v| v.nil? }, }, ) @response = Responses::Order.new(raw_response) @order_id = @response.order_id end |
#fetch_status! ⇒ Object
69 70 71 72 |
# File 'lib/sealine_insurance/operations/create_order.rb', line 69 def fetch_status! raw_response = request.get("/order/#{@order_id}") @response = Responses::Order.new(raw_response) end |