Sha256: 9599fe476593b507aa85ea6d4f87290661e961bc2c00900b02ce0d77975fa74d

Contents?: true

Size: 836 Bytes

Versions: 34

Compression:

Stored size: 836 Bytes

Contents

require 'restful_model'

module Inbox
  class Account < RestfulModel

    parameter :account_id
    parameter :trial
    parameter :trial_expires
    parameter :sync_state
    parameter :billing_state

    def _perform_account_action!(action)
      raise UnexpectedAccountAction.new unless action == "upgrade" || action == "downgrade"

      collection = ManagementModelCollection.new(Account, @_api, @namespace_id, {:account_id=>@account_id})
      ::RestClient.post("#{collection.url}/#{@account_id}/#{action}",{}) do |response, request, result|
          # Throw any exceptions
        json = Inbox.interpret_response(result, response, :expected_class => Object)
      end
    end

    def upgrade!
      _perform_account_action!('upgrade')
    end

    def downgrade!
      _perform_account_action!('downgrade')
    end


  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
nylas-0.18.2 lib/account.rb
inbox-0.18.2 lib/account.rb
nylas-0.18.1 lib/account.rb
inbox-0.18.1 lib/account.rb
inbox-0.18.0 lib/account.rb
nylas-0.18.0 lib/account.rb
nylas-0.17.4 lib/account.rb
inbox-0.17.4 lib/account.rb
inbox-0.17.3 lib/account.rb
inbox-0.17.2 lib/account.rb
nylas-0.17.2 lib/account.rb
inbox-0.17.1 lib/account.rb
nylas-0.17.1 lib/account.rb
nylas-0.17.0 lib/account.rb
inbox-0.17.0 lib/account.rb
inbox-0.16.1 lib/account.rb
nylas-0.16.1 lib/account.rb
nylas-0.16.0 lib/account.rb
inbox-0.16.0 lib/account.rb
inbox-0.15.8 lib/account.rb