module Tickethub class Supplier < Resource path '/supplier', singleton: true require_relative 'supplier/customer' require_relative 'supplier/order' require_relative 'supplier/booking' require_relative 'supplier/purchase' require_relative 'supplier/reseller' require_relative 'supplier/ticket' require_relative 'supplier/extra' require_relative 'supplier/product' require_relative 'supplier/season' require_relative 'supplier/option' require_relative 'supplier/variant' require_relative 'supplier/tier' require_relative 'supplier/rate' require_relative 'supplier/invoice' require_relative 'supplier/payment' require_relative 'supplier/refund' 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 'supplier/import' require_relative 'supplier/broadcast' require_relative 'supplier/transfer' require_relative 'supplier/channel' require_relative 'supplier/discount' require_relative 'supplier/partner' require_relative 'supplier/scan' require_relative 'supplier/session' require_relative 'supplier/shift' require_relative 'contact' require_relative 'address' require_relative 'token' collection :customers, Customer collection :orders, Order collection :bookings, Booking collection :purchases, Purchase collection :resellers, Reseller collection :tickets, Ticket collection :extras, Extra collection :products, Product collection :seasons, Season collection :options, Option collection :variants, Variant collection :tiers, Tier collection :rates, Rate collection :invoices, Invoice collection :coupons, Coupon collection :payments, Payment collection :refunds, Refund collection :users, User collection :questions, Question collection :answers, Answer collection :taxes, Tax collection :fees, Fee collection :messages, Message collection :charges, Charge collection :imports, Import collection :broadcasts, Broadcast collection :transfers, Transfer collection :channels, Channel collection :discounts, Discount collection :partners, Partner collection :scans, Scan collection :sessions, Session collection :shifts, Shift association :address, Tickethub::Address association :contact, Tickethub::Contact association :token, Tickethub::Token attribute :country, type: :country attribute :currency, type: :currency attribute :balance, type: :money 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.call 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 end end