Class: Gecko::Client
- Inherits:
 - 
      Object
      
        
- Object
 - Gecko::Client
 
 
- Extended by:
 - Helpers::RecordHelper
 
- Defined in:
 - lib/gecko/client.rb
 
Overview
The Gecko::Client class
Instance Attribute Summary collapse
- 
  
    
      #access_token  ⇒ OAuth2::AccessToken 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Access the OAuth AccessToken for this client.
 - 
  
    
      #oauth_client  ⇒ OAuth2::Client 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  private
  
    
Return OAuth client.
 
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #adapter_for(klass_name)  ⇒ Gecko::Record::BaseAdapter 
    
    
  
  
  
  
  
  
  
  private
  
    
Fetch the adapter for a specified Gecko::Record class.
 - 
  
    
      #authorize_from_existing(access_token, refresh_token, expires_at)  ⇒ OAuth2::AccessToken 
    
    
  
  
  
  
  
  
  
  
  
    
Authorize client from existing access and refresh token.
 - 
  
    
      #authorize_from_refresh_token(refresh_token)  ⇒ OAuth2::AccessToken 
    
    
  
  
  
  
  
  
  
  
  
    
Authorize client by fetching a new access_token via refresh token.
 - 
  
    
      #initialize(client_id, client_secret, options = {})  ⇒ undefined 
    
    
  
  
  
    constructor
  
  
  
  
  
  private
  
    
Initialize a new Gecko client object with an instantiated OAuth2::Client.
 
Methods included from Helpers::RecordHelper
Constructor Details
#initialize(client_id, client_secret, options = {}) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new Gecko client object with an instantiated OAuth2::Client
      63 64 65  | 
    
      # File 'lib/gecko/client.rb', line 63 def initialize(client_id, client_secret, = {}) setup_oauth_client(client_id, client_secret, ) end  | 
  
Instance Attribute Details
#access_token ⇒ OAuth2::AccessToken
Access the OAuth AccessToken for this client
      52 53 54  | 
    
      # File 'lib/gecko/client.rb', line 52 def access_token @access_token end  | 
  
#oauth_client ⇒ OAuth2::Client (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return OAuth client
      45 46 47  | 
    
      # File 'lib/gecko/client.rb', line 45 def oauth_client @oauth_client end  | 
  
Class Method Details
Instance Method Details
#adapter_for(klass_name) ⇒ Gecko::Record::BaseAdapter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Fetch the adapter for a specified Gecko::Record class
      112 113 114  | 
    
      # File 'lib/gecko/client.rb', line 112 def adapter_for(klass_name) public_send(klass_name.to_sym) end  | 
  
#authorize_from_existing(access_token, refresh_token, expires_at) ⇒ OAuth2::AccessToken
Authorize client from existing access and refresh token
      79 80 81 82 83 84  | 
    
      # File 'lib/gecko/client.rb', line 79 def (access_token, refresh_token, expires_at) @access_token = OAuth2::AccessToken.new(oauth_client, access_token, { refresh_token: refresh_token, expires_at: expires_at }) end  | 
  
#authorize_from_refresh_token(refresh_token) ⇒ OAuth2::AccessToken
Authorize client by fetching a new access_token via refresh token
      96 97 98 99 100 101 102 103  | 
    
      # File 'lib/gecko/client.rb', line 96 def (refresh_token) @access_token = oauth_client.get_token({ client_id: oauth_client.id, client_secret: oauth_client.secret, refresh_token: refresh_token, grant_type: 'refresh_token' }) end  |