Class: TicketingHub::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Request
Defined in:
lib/ticketing_hub/client.rb

Instance Method Summary collapse

Methods included from Request

#delete, #get, #patch, #post, #put

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
# File 'lib/ticketing_hub/client.rb', line 11

def initialize options={}
  options = TicketingHub.options.merge options
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send "#{key}=", options[key]
  end
end

Instance Method Details

#cancel_order(order_id) ⇒ Object



57
58
59
# File 'lib/ticketing_hub/client.rb', line 57

def cancel_order order_id
  delete "orders/#{_normalize_object_id order_id}"
end

#confirm_order(order_id, order_attributes = nil) ⇒ Object



65
66
67
68
# File 'lib/ticketing_hub/client.rb', line 65

def confirm_order order_id, order_attributes=nil
  update_order order_id, order_attributes if order_attributes
  post "orders/#{_normalize_object_id order_id}/confirm"
end

#consumer_fields(order_id, ticket_id = nil) ⇒ Object



48
49
50
51
# File 'lib/ticketing_hub/client.rb', line 48

def consumer_fields order_id, ticket_id=nil
  ticket_id.nil?? get("orders/#{_normalize_object_id order_id}/fields") :
    get("tickets/#{_normalize_object_id ticket_id}/fields")
end

#create_order(order_attributes) ⇒ Object



53
54
55
# File 'lib/ticketing_hub/client.rb', line 53

def create_order order_attributes
  post 'orders', order_attributes
end

#get_token(code) ⇒ Object



18
19
20
21
# File 'lib/ticketing_hub/client.rb', line 18

def get_token code
  post('token', grant_type: 'code', client_id: client_id,
    client_secret: client_secret, code: code, endpoint: oauth_endpoint)['access_token']
end

#options(date = nil) ⇒ Object



43
44
45
46
# File 'lib/ticketing_hub/client.rb', line 43

def options date=nil
  date = Date.parse(date.to_s) if date
  get 'options', { date: date }
end

#order(order_id) ⇒ Object



35
36
37
# File 'lib/ticketing_hub/client.rb', line 35

def order order_id
  get "orders/#{_normalize_object_id order_id}"
end

#ordersObject



31
32
33
# File 'lib/ticketing_hub/client.rb', line 31

def orders
  get 'orders'
end

#tiers(date, starts_at) ⇒ Object



39
40
41
# File 'lib/ticketing_hub/client.rb', line 39

def tiers date, starts_at
  get 'tiers', { date: date, starts_at: starts_at }
end

#update_order(order_id, order_attributes) ⇒ Object



61
62
63
# File 'lib/ticketing_hub/client.rb', line 61

def update_order order_id, order_attributes
  patch "orders/#{_normalize_object_id order_id}", order_attributes
end

#userObject



27
28
29
# File 'lib/ticketing_hub/client.rb', line 27

def user
  get 'user'
end

#venueObject



23
24
25
# File 'lib/ticketing_hub/client.rb', line 23

def venue
  get 'venue'
end