Sha256: 2cac4cbdaef2c799e3149f27202feef920632981d9bbbf5fedc006feb48db88f

Contents?: true

Size: 973 Bytes

Versions: 6

Compression:

Stored size: 973 Bytes

Contents

module AlfaInsurance
  class BusClient < BaseClient
    def calculate(total_cost, ticket_issue_date)
      response = send_soap_request(:calculate_policy) do |xml|
        xml.operator { xml.code(operator) }
        xml.product { xml.code(product_code) }
        xml.policyParameters {
          xml.ticketInformation {
            xml.ticketTotalValue(total_cost.to_f)
            xml.ticketIssueDate(ticket_issue_date.iso8601)
          }
        }
      end
      CalculateResponse.new(response)
    end

    def create(insurance_object, ticket_issue_date)
      raise ArgumentError, "BusInsuranceRequest is expected" unless insurance_object.is_a?(BusInsuranceRequest)
      response = send_soap_request(:create_policy) do |xml|
        xml.operator { xml.code(operator) }
        xml.product { xml.code(product_code) }
        xml.policyParameters { insurance_object.generate_xml(xml, ticket_issue_date) }
      end
      CreateResponse.new(response)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alfa_insurance-0.2.1 lib/alfa_insurance/bus_client.rb
alfa_insurance-0.2.0 lib/alfa_insurance/bus_client.rb
alfa_insurance-0.1.8 lib/alfa_insurance/bus_client.rb
alfa_insurance-0.1.7 lib/alfa_insurance/bus_client.rb
alfa_insurance-0.1.6 lib/alfa_insurance/bus_client.rb
alfa_insurance-0.1.5 lib/alfa_insurance/bus_client.rb