Sha256: 88107e8d7c69f300033baffdc4646cab38fbcd52cd0e8e869238528a1f114651
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
require_relative 'connection' require_relative 'request' module TicketingHub class Client include TicketingHub::Connection include TicketingHub::Request attr_accessor *Configuration::VALID_OPTIONS_KEYS def initialize options={} options = TicketingHub.options.merge options Configuration::VALID_OPTIONS_KEYS.each do |key| send "#{key}=", options[key] end end 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 def venue get 'venue' end def user get 'user' end def orders get 'orders' end def order order_id get "orders/#{_normalize_object_id order_id}" end def tiers option_id=nil get 'tiers', { option_id: option_id } end def options date=nil date = Date.parse(date.to_s) if date get 'options', { date: date } end def option option_id get "options/#{_normalize_object_id option_id}" end 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 def create_order order_attributes post 'orders', order_attributes end def cancel_order order_id delete "orders/#{_normalize_object_id order_id}" end def update_order order_id, order_attributes patch "orders/#{_normalize_object_id order_id}", order_attributes end 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 private def _normalize_object_id object_id (object_id.is_a?(Hash) ? object_id['id'] : object_id).to_i end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ticketinghub-0.0.3 | lib/ticketing_hub/client.rb |