Class: Nylas::API

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Logging
Defined in:
lib/nylas/api.rb

Overview

Methods to retrieve data from the Nylas API as Ruby objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, level, logger, logger=

Constructor Details

#initialize(client: nil, app_id: nil, app_secret: nil, access_token: nil, api_server: "https://api.nylas.com", service_domain: "api.nylas.com") ⇒ Nylas::API

rubocop:disable Metrics/ParameterLists


19
20
21
22
23
24
# File 'lib/nylas/api.rb', line 19

def initialize(client: nil, app_id: nil, app_secret: nil, access_token: nil,
               api_server: "https://api.nylas.com", service_domain: "api.nylas.com")
  self.client = client || HttpClient.new(app_id: app_id, app_secret: app_secret,
                                         access_token: access_token, api_server: api_server,
                                         service_domain: service_domain)
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


4
5
6
# File 'lib/nylas/api.rb', line 4

def client
  @client
end

Instance Method Details

#contactsCollection<Contact>


28
29
30
# File 'lib/nylas/api.rb', line 28

def contacts
  @contacts ||= Collection.new(model: Contact, api: self)
end

#current_accountCurrentAccount


33
34
35
36
# File 'lib/nylas/api.rb', line 33

def 
  prevent_calling_if_missing_access_token(:current_account)
  CurrentAccount.from_hash(client.execute(method: :get, path: "/account"), api: self)
end