Class: PrioTicket::Booking

Inherits:
Object
  • Object
show all
Defined in:
lib/prioticket/booking.rb

Overview

This API is called to get a ticket booked and get a barcode/QR-code in response. The booking API provides a booking reference in response. There are 5 different booking options:

  • Booking of ticket without timeslot (ticket_class 1).

  • Booking of ticket with timeslot (ticket_class 2/ticket_class 3),

without reservation_reference.

  • Booking of ticket with timeslot (ticket_class 2/ticket_class 3),

with reservation_reference.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Booking

Returns a new instance of Booking.



39
40
41
42
43
44
# File 'lib/prioticket/booking.rb', line 39

def initialize(args)
  return if args.nil?
  args.each do |k,v|
    PrioTicket.parse_json_value(self, k,v)
  end
end

Instance Attribute Details

#booking_detailsObject

Returns the value of attribute booking_details.



37
38
39
# File 'lib/prioticket/booking.rb', line 37

def booking_details
  @booking_details
end

#booking_emailObject

Returns the value of attribute booking_email.



20
21
22
# File 'lib/prioticket/booking.rb', line 20

def booking_email
  @booking_email
end

#booking_nameObject

Returns the value of attribute booking_name.



19
20
21
# File 'lib/prioticket/booking.rb', line 19

def booking_name
  @booking_name
end

#booking_referenceObject

completed booking attrs



35
36
37
# File 'lib/prioticket/booking.rb', line 35

def booking_reference
  @booking_reference
end

#booking_statusObject

Returns the value of attribute booking_status.



36
37
38
# File 'lib/prioticket/booking.rb', line 36

def booking_status
  @booking_status
end

#booking_typeObject

attr_accessor :booking_type



18
19
20
# File 'lib/prioticket/booking.rb', line 18

def booking_type
  @booking_type
end

#cityObject

Returns the value of attribute city.



32
33
34
# File 'lib/prioticket/booking.rb', line 32

def city
  @city
end

#contactObject

Returns the value of attribute contact.



22
23
24
# File 'lib/prioticket/booking.rb', line 22

def contact
  @contact
end

#distributor_idObject

Returns the value of attribute distributor_id.



16
17
18
# File 'lib/prioticket/booking.rb', line 16

def distributor_id
  @distributor_id
end

#distributor_referenceObject

Returns the value of attribute distributor_reference.



24
25
26
# File 'lib/prioticket/booking.rb', line 24

def distributor_reference
  @distributor_reference
end

#identifierObject

Returns the value of attribute identifier.



15
16
17
# File 'lib/prioticket/booking.rb', line 15

def identifier
  @identifier
end

#notesObject

Returns the value of attribute notes.



21
22
23
# File 'lib/prioticket/booking.rb', line 21

def notes
  @notes
end

#phone_numberObject

contact details



29
30
31
# File 'lib/prioticket/booking.rb', line 29

def phone_number
  @phone_number
end

#postal_codeObject

Returns the value of attribute postal_code.



31
32
33
# File 'lib/prioticket/booking.rb', line 31

def postal_code
  @postal_code
end

#product_languageObject

Returns the value of attribute product_language.



23
24
25
# File 'lib/prioticket/booking.rb', line 23

def product_language
  @product_language
end

#reservation_referenceObject

Returns the value of attribute reservation_reference.



25
26
27
# File 'lib/prioticket/booking.rb', line 25

def reservation_reference
  @reservation_reference
end

#streetObject

Returns the value of attribute street.



30
31
32
# File 'lib/prioticket/booking.rb', line 30

def street
  @street
end

Class Method Details

.cancel(distributor_id: nil, booking_reference: nil, distributor_reference: nil, identifier: nil) ⇒ Object

Cancels a Booking

Returns:

  • Booking



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/prioticket/booking.rb', line 86

def self.cancel(distributor_id: nil, booking_reference: nil, distributor_reference: nil, identifier: nil)
  body = {
    request_type: "cancel_booking",
    data: {
      distributor_id: distributor_id,
      booking_reference: booking_reference,
      distributor_reference: booking_reference  
    }
  }
  result = PrioTicket::API.call(body, identifier)
  booking = PrioTicket::Booking.new(result["data"])
  return booking
end

.get_status(distributor_id: nil, booking_reference: nil, distributor_reference: nil, identifier: nil) ⇒ Object

Gets the status from a Booking

Returns:

  • Booking



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/prioticket/booking.rb', line 104

def self.get_status(distributor_id: nil, booking_reference: nil, distributor_reference: nil, identifier: nil)
  body = {
    request_type: "booking_status",
    data: {
      distributor_id: distributor_id,
      booking_reference: booking_reference,
      distributor_reference: booking_reference  
    }
  }
  result = PrioTicket::API.call(body, identifier)
  booking = PrioTicket::Booking.new(result["data"])
  return booking
end

Instance Method Details

#canceledObject Also known as: canceled?



54
55
56
# File 'lib/prioticket/booking.rb', line 54

def canceled
  booking_status == "Cancelled"
end

#saveObject

Sends the reservation request tot the API



49
50
51
# File 'lib/prioticket/booking.rb', line 49

def save
  request_booking
end

#successObject



60
61
62
# File 'lib/prioticket/booking.rb', line 60

def success
	booking_status == "Confirmed"
end

#tickettype

Fetches information from ticket_details, to validate the input for this booking. e.g. if ticket_type == 2, from/to date are required.

Returns:

  • (type)
    description


73
74
75
76
77
78
79
# File 'lib/prioticket/booking.rb', line 73

def ticket
  begin
    @ticket ||= PrioTicket::TicketDetails.find(distributor_id: distributor_id, ticket_id: booking_type['ticket_id'], identifier: identifier)
  rescue
    false
  end
end