Class: PrioTicket::TicketDetails
- Inherits:
-
Object
- Object
- PrioTicket::TicketDetails
- Defined in:
- lib/prioticket/ticket_details.rb
Overview
This API provides all the ticket information that is available in the PrioTicket system for requested ‘ticket_id`.
Instance Attribute Summary collapse
-
#distributor_id ⇒ Object
Returns the value of attribute distributor_id.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
Class Method Summary collapse
-
.find(distributor_id: nil, ticket_id: nil, identifier: nil) ⇒ Object
Calls the request type ‘details’ with given.
-
.request_body(ticket_id: nil, distributor_id: nil) ⇒ Object
Computes the request body to send to the API endpoint.
Instance Method Summary collapse
-
#availabilities(from_date: Time.now, until_date: Time.now+(60*60*24*21)) ⇒ type
Finds availabilities for given dates.
-
#initialize(args = nil) ⇒ TicketDetails
constructor
A new instance of TicketDetails.
- #reserve_timeslot ⇒ Object
Constructor Details
#initialize(args = nil) ⇒ TicketDetails
Returns a new instance of TicketDetails.
31 32 33 34 35 36 |
# File 'lib/prioticket/ticket_details.rb', line 31 def initialize(args=nil) return if args.nil? args.each do |k,v| PrioTicket.parse_json_value(self, k,v) end end |
Instance Attribute Details
#distributor_id ⇒ Object
Returns the value of attribute distributor_id.
12 13 14 |
# File 'lib/prioticket/ticket_details.rb', line 12 def distributor_id @distributor_id end |
#identifier ⇒ Object
Returns the value of attribute identifier.
11 12 13 |
# File 'lib/prioticket/ticket_details.rb', line 11 def identifier @identifier end |
Class Method Details
.find(distributor_id: nil, ticket_id: nil, identifier: nil) ⇒ Object
Calls the request type ‘details’ with given
44 45 46 47 48 49 50 |
# File 'lib/prioticket/ticket_details.rb', line 44 def self.find(distributor_id: nil, ticket_id: nil, identifier: nil) result = PrioTicket::API.call(request_body(ticket_id: ticket_id, distributor_id: distributor_id), identifier) new_obj = self.new(result["data"]) new_obj.distributor_id = distributor_id new_obj.identifier = identifier return new_obj end |
.request_body(ticket_id: nil, distributor_id: nil) ⇒ Object
Computes the request body to send to the API endpoint
57 58 59 60 61 62 63 64 65 |
# File 'lib/prioticket/ticket_details.rb', line 57 def self.request_body(ticket_id: nil, distributor_id: nil) { request_type: "details", data: { distributor_id: distributor_id, ticket_id: ticket_id } } end |
Instance Method Details
#availabilities(from_date: Time.now, until_date: Time.now+(60*60*24*21)) ⇒ type
Finds availabilities for given dates
75 76 77 |
# File 'lib/prioticket/ticket_details.rb', line 75 def availabilities(from_date: Time.now, until_date: Time.now+(60*60*24*21)) PrioTicket::Availabilities.find(distributor_id: distributor_id, ticket_id: ticket_id, identifier: identifier, from_date: from_date, until_date: until_date) end |
#reserve_timeslot ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/prioticket/ticket_details.rb', line 79 def reserve_timeslot # "request_type": "reserve", # "data": { # "distributor_id": "501", # "ticket_id": "509", # "pickup_point_id": "Wyndham_Apollo_hotel", # "from_date_time": "2017-11-22T09:00:00+01:00", # "to_date_time": "2017-11-23T09:00:00+01:00", # "booking_details": [ # { # "ticket_type": "ADULT", # "count": 1 # } # ], # "distributor_reference": "ABC123456" end |