module Tickethub class Reseller < Resource path '/resellers' require_relative 'reseller/customer' require_relative 'reseller/order' require_relative 'reseller/booking' require_relative 'reseller/ticket' require_relative 'reseller/extra' require_relative 'reseller/product' require_relative 'reseller/option' require_relative 'reseller/variant' require_relative 'reseller/tier' require_relative 'reseller/voucher' require_relative 'reseller/invoice' require_relative 'reseller/payment' require_relative 'reseller/user' require_relative 'reseller/question' require_relative 'reseller/answer' require_relative 'reseller/tax' require_relative 'reseller/fee' require_relative 'reseller/source' require_relative 'contact' require_relative 'address' require_relative 'token' require_relative 'supplier' collection :customers, Customer collection :orders, Order collection :bookings, Booking collection :tickets, Ticket collection :extras, Extra collection :products, Product collection :options, Option collection :variants, Variant collection :tiers, Tier collection :vouchers, Voucher collection :invoices, Invoice collection :payments, Payment collection :users, User collection :questions, Question collection :answers, Answer collection :taxes, Tax collection :fees, Fee collection :sources, Source association :contact, Tickethub::Contact association :address, Tickethub::Address association :supplier, Tickethub::Supplier association :token, Tickethub::Token attribute :period, type: :duration attribute :notice, type: :duration attribute :currency, type: :currency attribute :limit, type: :money attribute :balance, type: :money attribute :overdue, type: :money attribute :next_invoice_date, type: :date attribute :first_invoice_date, type: :date 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 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 end end