Class: ZohoCrm::GrantToken::GetService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/zoho_crm/grant_token/get_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grant_token:, client_id: nil, client_secret: nil) ⇒ GetService



15
16
17
18
19
# File 'lib/zoho_crm/grant_token/get_service.rb', line 15

def initialize(grant_token:, client_id: nil, client_secret: nil)
  @grant_token   = grant_token
  @client_id     = client_id.presence || ZohoCrm::BaseService.client_id
  @client_secret = client_secret.presence || ZohoCrm::BaseService.client_secret
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



4
5
6
# File 'lib/zoho_crm/grant_token/get_service.rb', line 4

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



4
5
6
# File 'lib/zoho_crm/grant_token/get_service.rb', line 4

def client_secret
  @client_secret
end

#grant_tokenObject (readonly)

Returns the value of attribute grant_token.



4
5
6
# File 'lib/zoho_crm/grant_token/get_service.rb', line 4

def grant_token
  @grant_token
end

Instance Method Details

#callObject

Get refresh token from grant token.

www.zoho.com/crm/developer/docs/api/v7/access-refresh.html

Examples

service = ZohoCrm::GrantToken::GetService.call(grant_token: '', client_id: '', client_secret: '')
service.refresh_token # => '1000.xxxx.yyyy'
service.expires_in # => 3600

POST /oauth/v2/token



32
33
34
# File 'lib/zoho_crm/grant_token/get_service.rb', line 32

def call
  connection.post('oauth/v2/token', params.to_param)
end