Class: PrioTicket::TicketDetails

Inherits:
Object
  • Object
show all
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`.

Author:

  • henkm

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_idObject

Returns the value of attribute distributor_id.



12
13
14
# File 'lib/prioticket/ticket_details.rb', line 12

def distributor_id
  @distributor_id
end

#identifierObject

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

Parameters:

  • distributor_id (defaults to: nil)

    Integer

Returns:

  • TicketDetails



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

Parameters:

  • distributor_id (defaults to: nil)

    Integer

Returns:

  • Hash



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

Parameters:

  • from_date: (defaults to: Time.now)

    DateTime

  • until_date: (defaults to: Time.now+(60*60*24*21))

    DateTime

Returns:

  • (type)
    description


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_timeslotObject



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