Class: Nylas::Account

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/nylas/account.rb

Overview

Representation of the accounts for Account management purposes.

Instance Attribute Summary

Attributes included from Model

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#auth_method, #create, #destroy, #execute, included, #model_class, #persisted?, #reload, #resource_path, #resources_path, #save, #save_all_attributes, #to_json, #update, #update_all_attributes

Class Method Details

.resources_path(api:) ⇒ Object



52
53
54
# File 'lib/nylas/account.rb', line 52

def self.resources_path(api:)
  "/a/#{api.app_id}/accounts"
end

Instance Method Details

#downgradeObject



31
32
33
34
# File 'lib/nylas/account.rb', line 31

def downgrade
  response = execute(method: :post, path: "#{resource_path}/downgrade")
  response[:success]
end

#revoke_all(keep_access_token: nil) ⇒ Object



36
37
38
39
40
41
# File 'lib/nylas/account.rb', line 36

def revoke_all(keep_access_token: nil)
  payload = JSON.dump(keep_access_token: keep_access_token) if keep_access_token

  response = execute(method: :post, path: "#{resource_path}/revoke-all", payload: payload)
  response[:success]
end

#token_info(access_token) ⇒ TokenInfo

Return information about an account's access token

Parameters:

  • access_token (String)

    The access token to inquire about

Returns:

  • (TokenInfo)

    The access token information



46
47
48
49
50
# File 'lib/nylas/account.rb', line 46

def token_info(access_token)
  payload = JSON.dump(access_token: access_token)
  response = execute(method: :post, path: "#{resource_path}/token-info", payload: payload)
  TokenInfo.new(**response)
end

#upgradeObject



26
27
28
29
# File 'lib/nylas/account.rb', line 26

def upgrade
  response = execute(method: :post, path: "#{resource_path}/upgrade")
  response[:success]
end