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.15.7d lib/account.rb
inbox-0.15.7d lib/account.rb
nylas-0.15.7c lib/account.rb
nylas-0.15.7b lib/account.rb
nylas-0.15.7 lib/account.rb
nylas-0.15.6 lib/account.rb
nylas-0.15.5 lib/account.rb
inbox-0.15.4 lib/account.rb
inbox-0.15.3 lib/account.rb
inbox-0.15.2 lib/account.rb
inbox-0.15.1 lib/account.rb
inbox-0.15.0 lib/account.rb
inbox-0.14.1 lib/account.rb
inbox-0.14.0 lib/account.rb