Class: Tickethub::Reseller

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

Direct Known Subclasses

User::Reseller

Defined Under Namespace

Classes: Answer, Booking, Channel, Customer, Discount, Extra, Fee, Invoice, Option, Order, Payment, Product, Purchase, Question, Refund, Scan, Source, Supplier, Tax, Ticket, Tier, User, Variant

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) ⇒ Reseller

Returns a new instance of Reseller.



71
72
73
74
75
76
77
78
79
80
# File 'lib/tickethub/reseller.rb', line 71

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



65
66
67
68
69
# File 'lib/tickethub/reseller.rb', line 65

def self.[](attributes)
  token = attributes[:token].is_a?(String) ? attributes[:token]
    : attributes[:token][:access_token]
  self.new Tickethub.endpoint(auth_type: :bearer, password: token)['/reseller']
end