Sha256: f70c689ec0f16a63e96e6df1ed3d12ed48c650d4e7721c8bbd44d1e8507697f5

Contents?: true

Size: 919 Bytes

Versions: 75

Compression:

Stored size: 919 Bytes

Contents

module Tickethub
  class App < Resource
    path '/apps'

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

    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)['/app']
    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

75 entries across 75 versions & 1 rubygems

Version Path
tickethub-0.3.67 lib/tickethub/app.rb
tickethub-0.3.66 lib/tickethub/app.rb
tickethub-0.3.65 lib/tickethub/app.rb
tickethub-0.3.64 lib/tickethub/app.rb
tickethub-0.3.63 lib/tickethub/app.rb
tickethub-0.3.62 lib/tickethub/app.rb
tickethub-0.3.61 lib/tickethub/app.rb
tickethub-0.3.60 lib/tickethub/app.rb
tickethub-0.3.59 lib/tickethub/app.rb
tickethub-0.3.58 lib/tickethub/app.rb
tickethub-0.3.57 lib/tickethub/app.rb
tickethub-0.3.56 lib/tickethub/app.rb
tickethub-0.3.55 lib/tickethub/app.rb
tickethub-0.3.54 lib/tickethub/app.rb
tickethub-0.3.53 lib/tickethub/app.rb
tickethub-0.3.52 lib/tickethub/app.rb
tickethub-0.3.51 lib/tickethub/app.rb
tickethub-0.3.50 lib/tickethub/app.rb
tickethub-0.3.49 lib/tickethub/app.rb
tickethub-0.3.47 lib/tickethub/app.rb