module Tickethub class Supplier < Resource path '/supplier', singleton: true require_relative 'supplier/bill' require_relative 'supplier/gateway' require_relative 'supplier/customer' require_relative 'supplier/template' 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 'contact' require_relative 'token' collection :bills, Bill collection :gateways, Gateway collection :customers, Customer collection :templates, Template 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 association :contact, Tickethub::Contact association :token, Tickethub::Token attribute :country, type: :country attribute :currency, type: :currency 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 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 def settings @endpoint[:settings].get end end end