Module: BusinessInsightApiClient::Api::Applications
- Included in:
- Client
- Defined in:
- lib/business_insight_api_client/api/applications.rb
Overview
Applications API based methods. This module contains methods to query the Applications API.
Instance Method Summary collapse
-
#get_access_token(client_credential_token, installation_id) ⇒ OAuth2::AccessToken
Retrieves an access token belonging to the application for a specific installation.
-
#get_access_tokens(client_credential_token) ⇒ Hash{Integer => OAuth2::AccessToken}
Retrieves an access token for a specific application.
Instance Method Details
#get_access_token(client_credential_token, installation_id) ⇒ OAuth2::AccessToken
Retrieves an access token belonging to the application for a specific installation.
48 49 50 51 |
# File 'lib/business_insight_api_client/api/applications.rb', line 48 def get_access_token(client_credential_token, installation_id) tokens = get_access_tokens(client_credential_token) tokens[installation_id] end |
#get_access_tokens(client_credential_token) ⇒ Hash{Integer => OAuth2::AccessToken}
Retrieves an access token for a specific application.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/business_insight_api_client/api/applications.rb', line 20 def get_access_tokens(client_credential_token) tokens = ::BusinessInsightApiClient::Mash.from_json client.get('/applications/access_tokens', header: client_credential_token.headers) expired_time = Time.now Hash[tokens.access_tokens.collect do |token| [ token.resource_owner_id, .access_token_from_hash( token: token.token, expires_in: token.expires_in_seconds, expires_at: Time.now.to_i + token.expires_in_seconds, refresh_token: token.refresh_token ) ] end] end |