class BusinessInsightApiClient::Client
The client that has to make requests to the Business Insight Api
. This class includes all api endpoint methods. See section Instance Method Summary, for available methods.
@example Call an API method
client = BusinessInsightApiClient::Client.new access_token = client.authorization.access_token_from_hash(token: 'abc', refresh_token: 'efc', expires_in: 30020, expires_at: 23939192) client.access_token= access_token animals = client.animals
@see Api::Applications
Applications endpoint methods. @see Api::Animals
Animals endpoint methods. @see Api::Calendar
Calendar endpoint methods. @see Api::Groups
Groups endpoint methods. @see Api::Installations
Installations endpoint methods.
Attributes
Lists all options that are set for the client.
Public Class Methods
Initializes a new Client
with options. If no options are given the default configuration options are used for the client, like configured in BusinessInsightApiClient.configure
. @example
BusinessInsightApiClient::Client.new api_url: 'some url', client_id: 'some id' , client_secret: 'some secret'
@param [Hash] options the options to configure the client. @option options [String] :api_url (BusinessInsightApiClient.api_url
) the api url. @option options [String] :authorization_url (BusinessInsightApiClient.authorization_url
) the authorization url of the api. @option options [String] :content_type (BusinessInsightApiClient.default_content_type
) the content type used for sending and requesting. @option options [String] :client_id (BusinessInsightApiClient.client_id
) the client id uses in OAuth authorization. @option options [String] :client_secret (BusinessInsightApiClient.client_secret
) the client secret uses in OAuth authorization.
# File lib/business_insight_api_client/client.rb, line 40 def initialize(options = {}) @options = options @options[:api_url] ||= BusinessInsightApiClient.api_url @options[:authorization_url] ||= BusinessInsightApiClient.authorization_url @options[:content_type] ||= BusinessInsightApiClient.default_content_type @options[:client_id] ||= BusinessInsightApiClient.client_id @options[:client_secret] ||= BusinessInsightApiClient.client_secret end
Public Instance Methods
Sets the access token to make requests with to the protected endpoints. Make sure the access token is not expired, or has enough time to make requests. Otherwise refresh the token with {OAuth2::AccessToken#refresh!} @param [OAuth2::AccessToken] token sets a auth token to make requests with. @see www.rubydoc.info/gems/oauth2/1.0.0/OAuth2/AccessToken OAuth2::AccessToken information @see www.rubydoc.info/gems/oauth2/1.0.0/OAuth2/AccessToken#refresh%21-instance_method Refreshing an Access Token.
# File lib/business_insight_api_client/client.rb, line 65 def access_token=(token) # TODO: fail when not access token class. authorization.current_token = token end
Private Instance Methods
# File lib/business_insight_api_client/client.rb, line 72 def client @client ||= BusinessInsightApiClient::Helpers::RESTClient.new(authorization, options) end