Class: AlfaInsurance::BusInsuranceRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ BusInsuranceRequest

Returns a new instance of BusInsuranceRequest.



47
48
49
50
51
# File 'lib/alfa_insurance/insurance.rb', line 47

def initialize(params = {})
  params.each do |attr, value|
    instance_variable_set("@#{attr}", value)
  end
end

Instance Attribute Details

#bus_segmentsObject (readonly)

Returns the value of attribute bus_segments.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def bus_segments
  @bus_segments
end

#customer_emailObject (readonly)

Returns the value of attribute customer_email.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def customer_email
  @customer_email
end

#customer_phoneObject (readonly)

Returns the value of attribute customer_phone.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def customer_phone
  @customer_phone
end

#insured_birth_dateObject (readonly)

Returns the value of attribute insured_birth_date.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def insured_birth_date
  @insured_birth_date
end

#insured_document_numberObject (readonly)

Returns the value of attribute insured_document_number.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def insured_document_number
  @insured_document_number
end

#insured_document_typeObject (readonly)

Returns the value of attribute insured_document_type.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def insured_document_type
  @insured_document_type
end

#insured_first_nameObject (readonly)

Returns the value of attribute insured_first_name.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def insured_first_name
  @insured_first_name
end

#insured_last_nameObject (readonly)

Returns the value of attribute insured_last_name.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def insured_last_name
  @insured_last_name
end

#insured_patronymicObject (readonly)

Returns the value of attribute insured_patronymic.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def insured_patronymic
  @insured_patronymic
end

#insured_ticket_numberObject (readonly)

Returns the value of attribute insured_ticket_number.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def insured_ticket_number
  @insured_ticket_number
end

#total_valueObject (readonly)

Returns the value of attribute total_value.



35
36
37
# File 'lib/alfa_insurance/insurance.rb', line 35

def total_value
  @total_value
end

Instance Method Details

#generate_xml(xml, ticket_issue_date) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/alfa_insurance/insurance.rb', line 53

def generate_xml(xml, ticket_issue_date)
  xml.insuredFirstName(insured_first_name)
  xml.insuredLastName(insured_last_name)
  xml.insuredPatronymic(insured_patronymic)
  xml.insuredBirthDate(insured_birth_date)
  xml.insuredTicketNumber(insured_ticket_number)
  xml.insuredCount(1)
#      xml.insuredDocumentType(insured_document_type)
#      xml.insuredDocumentNumber(insured_document_number)
  bus_segments.each_with_index do |segment, index|
    xml.busSegmentRouteNumber(seqNo: index) {
      xml.value(segment.route_number)
    }
    xml.busSegmentPlaceNumber(seqNo: index) {
      xml.value(segment.place_number)
    }
    xml.busSegmentDepartureStation(seqNo: index) {
      xml.value(segment.departure_station)
    }
    xml.busSegmentDepartureDate(seqNo: index) {
      xml.value(segment.departure_date)
    }
    xml.busSegmentDepartureTime(seqNo: index) {
      xml.value(segment.departure_time)
    }
    xml.busSegmentArrivalStation(seqNo: index) {
      xml.value(segment.arrival_station)
    }
    xml.busSegmentArrivalDate(seqNo: index) {
      xml.value(segment.arrival_date)
    }
    xml.busSegmentArrivalTime(seqNo: index) {
      xml.value(segment.arrival_time)
    }
    xml.busSegmentNumber(seqNo: index) {
      xml.value(segment.number)
    }
  end
  xml.busSegmentsCount(bus_segments.size)
  xml.ticketInformation {
      xml.ticketTotalValue(total_value.to_f)
      xml.ticketIssueDate(ticket_issue_date.iso8601)
    }
  xml.customerPhoneType 'MOBILE'
  xml.customerPhone customer_phone
  xml.customerEmail customer_email
  xml
end