Class: Tickethub::Supplier

Inherits:
Resource show all
Defined in:
lib/tickethub/supplier.rb

Direct Known Subclasses

User::Supplier

Defined Under Namespace

Classes: Adjustment, Answer, Booking, Broadcast, Channel, Charge, Coupon, Customer, Discount, Dispute, Extra, Fee, Import, Invoice, Location, Message, Option, Order, Override, Party, Payment, Product, Purchase, Question, Rate, Refund, Reseller, Scan, Season, Session, Shift, Source, Tax, Ticket, Tier, Transfer, User, Variant, Weather

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, all, association, attribute, attributes, call, collection, collection_method, collection_methods, descendants, #destroy, dump_value, #eql?, #errors, #hash, inherited, #inspect, #load, load_value, path, polymorphic, register_type, registered_types, #reload!, #respond_to?, scope, scopes, serialize, singleton?, #to_h, #to_param, #to_s, #update, #valid?

Constructor Details

#initialize(endpoint, attributes = nil) ⇒ Supplier

Returns a new instance of Supplier.



98
99
100
101
102
103
104
105
106
107
# File 'lib/tickethub/supplier.rb', line 98

def initialize(endpoint, attributes = nil)
  attributes ||= endpoint.get

  if attributes['token']
    endpoint = Tickethub.endpoint(auth_type: :bearer,
      password: attributes['token']['access_token'])[self.class.path]
  end

  super(endpoint, attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tickethub::Resource

Class Method Details

.[](attributes) ⇒ Object



92
93
94
95
96
# File 'lib/tickethub/supplier.rb', line 92

def self.[](attributes)
  token = attributes[:token].is_a?(String) ? attributes[:token]
    : attributes[:token][:access_token]
  self.call Tickethub.endpoint(auth_type: :bearer, password: token)[path]
end