Sha256: 2b0fb5c7c92ea19f2aa711f5aefff6787cedc833014421783ffb3e84701d8886

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 Bytes

Contents

module Tickethub
  class Reseller < Resource
    path '/resellers'

    require_relative 'contact'
    require_relative 'reseller/channel'

    association :contact, Tickethub::Contact
    association :token, Tickethub::Token

    association :category, App::Category
    collection :subscriptions, App::Subscription

    attribute :currency, type: :currency

    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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tickethub-0.3.33 lib/tickethub/reseller.rb
tickethub-0.3.32 lib/tickethub/reseller.rb
tickethub-0.3.31 lib/tickethub/reseller.rb