class AlfaInsurance::BusInsuranceRequest
Attributes
bus_segments[R]
customer_email[R]
customer_phone[R]
insured_birth_date[R]
insured_document_number[R]
insured_document_type[R]
insured_first_name[R]
insured_last_name[R]
insured_patronymic[R]
insured_ticket_number[R]
total_value[R]
Public Class Methods
new(params = {})
click to toggle source
# File lib/alfa_insurance/insurance.rb, line 47 def initialize(params = {}) params.each do |attr, value| instance_variable_set("@#{attr}", value) end end
Public Instance Methods
generate_xml(xml, ticket_issue_date)
click to toggle source
# 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) bus_segments.each_with_index do |segment, index| xml.busSegmentRouteNumber(seqNo: index) { xml.value(segment.route_number) if present?(segment.route_number) } xml.busSegmentPlaceNumber(seqNo: index) { xml.value(segment.place_number) if present?(segment.place_number) } xml.busSegmentDepartureStation(seqNo: index) { xml.value(segment.departure_station) if present?(segment.departure_station) } xml.busSegmentDepartureDate(seqNo: index) { xml.value(segment.departure_date) if present?(segment.departure_date) } xml.busSegmentDepartureTime(seqNo: index) { xml.value(segment.departure_time) if present?(segment.departure_time) } xml.busSegmentArrivalStation(seqNo: index) { xml.value(segment.arrival_station) if present?(segment.arrival_station) } xml.busSegmentArrivalDate(seqNo: index) { xml.value(segment.arrival_date) if present?(segment.arrival_date) } xml.busSegmentArrivalTime(seqNo: index) { xml.value(segment.arrival_time) if present?(segment.arrival_time) } xml.busSegmentNumber(seqNo: index) { xml.value(segment.number) if present?(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
Private Instance Methods
present?(value)
click to toggle source
# File lib/alfa_insurance/insurance.rb, line 102 def present?(value) !value.nil? && value != '' end