Sha256: 36d3390a26d8bc3fd57b53680b3e3c5b9ab9a18a61982a3df24a87db2b00f530

Contents?: true

Size: 990 Bytes

Versions: 7

Compression:

Stored size: 990 Bytes

Contents

module Tickethub
  class App < Resource
    path '/apps'

    require_relative 'contact'
    require_relative 'category'
    require_relative 'app/package'
    require_relative 'app/subscription'

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

    collection :packages, App::Package
    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['/app', auth_type: :bearer, password: token]
    end

    def initialize(endpoint, attributes = nil)
      attributes ||= endpoint.get

      if attributes['token']
        endpoint = Tickethub.endpoint['/app', {
          auth_type: :bearer, password: attributes['token']['access_token'] }]
      end

      super(endpoint, attributes)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tickethub-0.0.7 lib/tickethub/app.rb
tickethub-0.0.6 lib/tickethub/app.rb
tickethub-0.0.5 lib/tickethub/app.rb
tickethub-0.0.4 lib/tickethub/app.rb
tickethub-0.0.3 lib/tickethub/app.rb
tickethub-0.0.2 lib/tickethub/app.rb
tickethub-0.0.1 lib/tickethub/app.rb