Class: Tickethub::Supplier

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

Direct Known Subclasses

User::Supplier

Defined Under Namespace

Classes: Answer, App, Bill, Booking, Card, Charge, Coupon, Customer, Fee, Invoice, Message, Option, Order, Payment, Product, Question, Rate, Receipt, Reseller, Scan, Season, Subscription, Tax, Ticket, Tier, User, Variant, Voucher

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

#initialize(endpoint, attributes = nil) ⇒ Supplier

Returns a new instance of Supplier.



69
70
71
72
73
74
75
76
77
78
# File 'lib/tickethub/supplier.rb', line 69

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

  if attributes['token']
    endpoint = Tickethub.endpoint['/supplier', {
      auth_type: :bearer, password: attributes['token']['access_token'] }]
  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



63
64
65
66
67
# File 'lib/tickethub/supplier.rb', line 63

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

Instance Method Details

#settingsObject



80
81
82
# File 'lib/tickethub/supplier.rb', line 80

def settings
  @endpoint[:settings].get.decoded
end