Class: PrioTicket::Booking
- Inherits:
-
Object
- Object
- PrioTicket::Booking
- 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
-
#booking_details ⇒ Object
Returns the value of attribute booking_details.
-
#booking_email ⇒ Object
Returns the value of attribute booking_email.
-
#booking_name ⇒ Object
Returns the value of attribute booking_name.
-
#booking_reference ⇒ Object
completed booking attrs.
-
#booking_status ⇒ Object
Returns the value of attribute booking_status.
-
#booking_type ⇒ Object
attr_accessor :booking_type.
-
#city ⇒ Object
Returns the value of attribute city.
-
#contact ⇒ Object
Returns the value of attribute contact.
-
#distributor_id ⇒ Object
Returns the value of attribute distributor_id.
-
#distributor_reference ⇒ Object
Returns the value of attribute distributor_reference.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#phone_number ⇒ Object
contact details.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#product_language ⇒ Object
Returns the value of attribute product_language.
-
#reservation_reference ⇒ Object
Returns the value of attribute reservation_reference.
-
#street ⇒ Object
Returns the value of attribute street.
Class Method Summary collapse
-
.cancel(distributor_id: nil, booking_reference: nil, distributor_reference: nil, identifier: nil) ⇒ Object
Cancels a Booking.
-
.get_status(distributor_id: nil, booking_reference: nil, distributor_reference: nil, identifier: nil) ⇒ Object
Gets the status from a Booking.
Instance Method Summary collapse
- #canceled ⇒ Object (also: #canceled?)
-
#initialize(args) ⇒ Booking
constructor
A new instance of Booking.
-
#save ⇒ Object
Sends the reservation request tot the API.
- #success ⇒ Object
-
#ticket ⇒ type
Fetches information from ticket_details, to validate the input for this booking.
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_details ⇒ Object
Returns the value of attribute booking_details.
37 38 39 |
# File 'lib/prioticket/booking.rb', line 37 def booking_details @booking_details end |
#booking_email ⇒ Object
Returns the value of attribute booking_email.
20 21 22 |
# File 'lib/prioticket/booking.rb', line 20 def booking_email @booking_email end |
#booking_name ⇒ Object
Returns the value of attribute booking_name.
19 20 21 |
# File 'lib/prioticket/booking.rb', line 19 def booking_name @booking_name end |
#booking_reference ⇒ Object
completed booking attrs
35 36 37 |
# File 'lib/prioticket/booking.rb', line 35 def booking_reference @booking_reference end |
#booking_status ⇒ Object
Returns the value of attribute booking_status.
36 37 38 |
# File 'lib/prioticket/booking.rb', line 36 def booking_status @booking_status end |
#booking_type ⇒ Object
attr_accessor :booking_type
18 19 20 |
# File 'lib/prioticket/booking.rb', line 18 def booking_type @booking_type end |
#city ⇒ Object
Returns the value of attribute city.
32 33 34 |
# File 'lib/prioticket/booking.rb', line 32 def city @city end |
#contact ⇒ Object
Returns the value of attribute contact.
22 23 24 |
# File 'lib/prioticket/booking.rb', line 22 def contact @contact end |
#distributor_id ⇒ Object
Returns the value of attribute distributor_id.
16 17 18 |
# File 'lib/prioticket/booking.rb', line 16 def distributor_id @distributor_id end |
#distributor_reference ⇒ Object
Returns the value of attribute distributor_reference.
24 25 26 |
# File 'lib/prioticket/booking.rb', line 24 def distributor_reference @distributor_reference end |
#identifier ⇒ Object
Returns the value of attribute identifier.
15 16 17 |
# File 'lib/prioticket/booking.rb', line 15 def identifier @identifier end |
#notes ⇒ Object
Returns the value of attribute notes.
21 22 23 |
# File 'lib/prioticket/booking.rb', line 21 def notes @notes end |
#phone_number ⇒ Object
contact details
29 30 31 |
# File 'lib/prioticket/booking.rb', line 29 def phone_number @phone_number end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
31 32 33 |
# File 'lib/prioticket/booking.rb', line 31 def postal_code @postal_code end |
#product_language ⇒ Object
Returns the value of attribute product_language.
23 24 25 |
# File 'lib/prioticket/booking.rb', line 23 def product_language @product_language end |
#reservation_reference ⇒ Object
Returns the value of attribute reservation_reference.
25 26 27 |
# File 'lib/prioticket/booking.rb', line 25 def reservation_reference @reservation_reference end |
#street ⇒ Object
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
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
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
#canceled ⇒ Object Also known as: canceled?
54 55 56 |
# File 'lib/prioticket/booking.rb', line 54 def canceled booking_status == "Cancelled" end |
#save ⇒ Object
Sends the reservation request tot the API
49 50 51 |
# File 'lib/prioticket/booking.rb', line 49 def save request_booking end |
#success ⇒ Object
60 61 62 |
# File 'lib/prioticket/booking.rb', line 60 def success booking_status == "Confirmed" end |
#ticket ⇒ type
Fetches information from ticket_details, to validate the input for this booking. e.g. if ticket_type == 2, from/to date are required.
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 |