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



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



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

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

#confirm_order(order_id, order_attributes = nil) ⇒ Object



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

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



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

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



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

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

#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

#seasonsObject



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

def seasons
  get 'seasons'
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



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

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