Class: Outreach::Authorization
- Inherits:
-
Object
- Object
- Outreach::Authorization
- Defined in:
- lib/outreach/authorization.rb
Constant Summary collapse
- API_URL =
"https://api.outreach.io/oauth/token"
Instance Attribute Summary collapse
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Authorization
constructor
A new instance of Authorization.
Constructor Details
#initialize(attrs) ⇒ Authorization
Returns a new instance of Authorization.
9 10 11 12 13 |
# File 'lib/outreach/authorization.rb', line 9 def initialize(attrs) @token = attrs['access_token'] @refresh_token = attrs['refresh_token'] @expires_in = attrs['expires_in'] end |
Instance Attribute Details
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
7 8 9 |
# File 'lib/outreach/authorization.rb', line 7 def expires_in @expires_in end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
7 8 9 |
# File 'lib/outreach/authorization.rb', line 7 def refresh_token @refresh_token end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/outreach/authorization.rb', line 7 def token @token end |
Class Method Details
.authorization_url ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/outreach/authorization.rb', line 15 def self. url = "https://api.outreach.io/oauth/authorize" params = { client_id: Outreach.application_identifier, redirect_uri: Outreach.redirect_uri, response_type: 'code', scope: Outreach.scopes } url + "?" + URI.encode_www_form(params) end |
.create(authorization_code) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/outreach/authorization.rb', line 26 def self.create() params = { client_id: Outreach.application_identifier, client_secret: Outreach.application_secret, redirect_uri: Outreach.redirect_uri, grant_type: 'authorization_code', code: } response = Outreach::Request.new.post(API_URL, params) new(response) end |
.refresh(refresh_token) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/outreach/authorization.rb', line 38 def self.refresh(refresh_token) params = { client_id: Outreach.application_identifier, client_secret: Outreach.application_secret, redirect_uri: Outreach.redirect_uri, grant_type: 'refresh_token', refresh_token: refresh_token } response = Request.new.post(API_URL, params) new(response) end |