Class: PrioTicket::TicketList

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

Overview

This API provides all the tickets that are available in the PrioTicket system per distributor.

Author:

  • henkm

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, distributor_id, identifier) ⇒ TicketList

Returns a new instance of TicketList.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/prioticket/ticket_list.rb', line 14

def initialize(args, distributor_id, identifier)
  @tickets = []
  
  # Add ticket details as array of TicketListItem objects
  for ticket_hash in args["data"]["tickets"]
    ticket = Ticket.new(ticket_hash)
    ticket.distributor_id = distributor_id
    ticket.identifier     = identifier
    @tickets << ticket
  end
end

Instance Attribute Details

#distributor_idObject

Returns the value of attribute distributor_id.



11
12
13
# File 'lib/prioticket/ticket_list.rb', line 11

def distributor_id
  @distributor_id
end

#identifierObject

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

#ticketsObject

Returns the value of attribute tickets.



10
11
12
# File 'lib/prioticket/ticket_list.rb', line 10

def tickets
  @tickets
end

Class Method Details

.find(distributor_id: nil, identifier: '') ⇒ TicketList

Calls the request type ‘list’ with given

Parameters:

  • distributor_id (defaults to: nil)

    Integer

Returns:



31
32
33
34
35
36
37
# File 'lib/prioticket/ticket_list.rb', line 31

def self.find(distributor_id: nil, identifier: '')
  result = PrioTicket::API.call(request_body(distributor_id: distributor_id), identifier, false)
  return_obj = self.new(result, distributor_id, identifier)
  return_obj.distributor_id = distributor_id
  return_obj.identifier     = identifier
  return return_obj
end

.request_body(distributor_id: nil) ⇒ Object

Computes the request body to send to the API endpoint

Parameters:

  • distributor_id (defaults to: nil)

    Integer

Returns:

  • Hash



44
45
46
47
48
49
50
51
# File 'lib/prioticket/ticket_list.rb', line 44

def self.request_body(distributor_id: nil)
  {
    request_type: "list",
    data: {
      distributor_id: distributor_id
    }
  }
end