Module: HubSpot::OAuth::Client
- Defined in:
- lib/hub_spot/oauth/client.rb
Defined Under Namespace
Classes: APIError
Constant Summary collapse
- URL =
rubocop:disable Metrics/LineLength
"https://api.hubapi.com/oauth/v1/token?grant_type=refresh_token&client_id=%<client_id>s&client_secret=%<client_secret>s&redirect_uri=%<redirect_uri>s&refresh_token=%<refresh_token>s"
Class Method Summary collapse
-
.api_response ⇒ Object
Below here are private methods.
- .token_params ⇒ Object
- .url ⇒ Object
- .url_params ⇒ Object
Class Method Details
.api_response ⇒ Object
Below here are private methods
19 20 21 22 23 24 25 |
# File 'lib/hub_spot/oauth/client.rb', line 19 def api_response response = HubSpot::HTTP.post(url: url) if response.code.to_s != "200" raise APIError, "OAuth API call returned a #{response.code} != 200" end JSON.parse(response.body) end |
.token_params ⇒ Object
12 13 14 15 16 |
# File 'lib/hub_spot/oauth/client.rb', line 12 def token_params expires_in, token_value = api_response.values_at("expires_in", "access_token") expires_at = Time.now + expires_in { value: token_value, expires_at: expires_at } end |
.url ⇒ Object
27 28 29 |
# File 'lib/hub_spot/oauth/client.rb', line 27 def url URL % url_params end |
.url_params ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/hub_spot/oauth/client.rb', line 31 def url_params { client_id: HubSpot::Configuration.client_id, client_secret: HubSpot::Configuration.client_secret, redirect_uri: HubSpot::Configuration.redirect_uri, refresh_token: HubSpot::Configuration.refresh_token, } end |