Class: DotloopApi::Auth
- Inherits:
- 
      Object
      
        - Object
- DotloopApi::Auth
 
- Includes:
- HTTParty
- Defined in:
- lib/dotloop_api/auth.rb
Instance Attribute Summary collapse
- 
  
    
      #config  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute config. 
Instance Method Summary collapse
- #grant_uri ⇒ Object
- 
  
    
      #initialize(client_id:, client_secret:, redirect_uri:, redirect_on_deny: true, application: 'dotloop')  ⇒ Auth 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Auth. 
- #refresh ⇒ Object
- #request(code:, state: nil) ⇒ Object
- #request_from_url(url) ⇒ Object
- #revoke ⇒ Object
Constructor Details
#initialize(client_id:, client_secret:, redirect_uri:, redirect_on_deny: true, application: 'dotloop') ⇒ Auth
Returns a new instance of Auth.
| 6 7 8 9 10 11 12 13 14 15 | # File 'lib/dotloop_api/auth.rb', line 6 def initialize(client_id:, client_secret:, redirect_uri:, redirect_on_deny: true, application: 'dotloop') @config = DotloopApi::Models::Config.new( application: application, client_id: client_id, client_secret: client_secret, redirect_on_deny: redirect_on_deny, redirect_uri: redirect_uri, state: SecureRandom.uuid ) end | 
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
| 4 5 6 | # File 'lib/dotloop_api/auth.rb', line 4 def config @config end | 
Instance Method Details
#grant_uri ⇒ Object
| 17 18 19 20 21 | # File 'lib/dotloop_api/auth.rb', line 17 def grant_uri uri = URI("#{base_uri}authorize") uri.query = URI.encode_www_form(grant_params) uri.to_s end | 
#refresh ⇒ Object
| 34 35 36 37 38 39 | # File 'lib/dotloop_api/auth.rb', line 34 def refresh check_refresh_token response = self.class.post("#{base_uri}token", query: refresh_params, headers: headers, timeout: 60) handle_error(response) @config.attributes = response.parsed_response end | 
#request(code:, state: nil) ⇒ Object
| 23 24 25 26 27 28 | # File 'lib/dotloop_api/auth.rb', line 23 def request(code:, state: nil) check_state(state) response = self.class.post("#{base_uri}token", query: request_params(code), headers: headers, timeout: 60) handle_error(response) @config.attributes = response.parsed_response end | 
#request_from_url(url) ⇒ Object
| 30 31 32 | # File 'lib/dotloop_api/auth.rb', line 30 def request_from_url(url) request(parse_url_response(url)) end | 
#revoke ⇒ Object
| 41 42 43 44 45 46 47 | # File 'lib/dotloop_api/auth.rb', line 41 def revoke check_revoke_token params = { token: @config.access_token } response = self.class.post("#{base_uri}token/revoke", query: params, headers: headers, timeout: 60) handle_error(response) clear_auth end |