module Tickethub class Supplier < Resource path '/supplier', singleton: true require_relative 'supplier/bill' require_relative 'supplier/customer' require_relative 'supplier/order' require_relative 'supplier/booking' require_relative 'supplier/reseller' require_relative 'supplier/ticket' require_relative 'supplier/product' require_relative 'supplier/subscription' require_relative 'supplier/season' require_relative 'supplier/option' require_relative 'supplier/variant' require_relative 'supplier/tier' require_relative 'supplier/voucher' require_relative 'supplier/rate' require_relative 'supplier/invoice' require_relative 'supplier/payment' require_relative 'supplier/user' require_relative 'supplier/question' require_relative 'supplier/answer' require_relative 'supplier/tax' require_relative 'supplier/fee' require_relative 'supplier/message' require_relative 'supplier/charge' require_relative 'contact' require_relative 'token' collection :bills, Bill collection :customers, Customer collection :orders, Order collection :bookings, Booking collection :resellers, Reseller collection :tickets, Ticket collection :products, Product collection :subscriptions, Subscription collection :seasons, Season collection :options, Option collection :variants, Variant collection :tiers, Tier collection :vouchers, Voucher collection :rates, Rate collection :invoices, Invoice collection :coupons, Coupon collection :payments, Payment collection :users, User collection :questions, Question collection :answers, Answer collection :taxes, Tax collection :fees, Fee collection :messages, Message collection :charges, Charge association :contact, Tickethub::Contact association :token, Tickethub::Token attribute :country, type: :country attribute :currency, type: :currency attribute :created_at, type: :datetime attribute :updated_at, type: :datetime def self.[](attributes) token = attributes[:token].is_a?(String) ? attributes[:token] : attributes[:token][:access_token] self.load Tickethub.endpoint(auth_type: :bearer, password: token)[path] 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 def settings @endpoint[:settings].get.decoded end end end