Class: BusinessInsightApiClient::Client
- Inherits:
-
Object
- Object
- BusinessInsightApiClient::Client
- Includes:
- Api::Animals, Api::Applications, Api::Calendar, Api::Groups, Api::Installations
- Defined in:
- lib/business_insight_api_client/client.rb
Overview
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.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Lists all options that are set for the client.
Instance Method Summary collapse
-
#access_token=(token) ⇒ Object
Sets the access token to make requests with to the protected endpoints.
-
#authorization ⇒ BusinessInsightApiClient::Helpers::Authorization
Creates new or returns an existing Authorization helper.
-
#initialize(options = {}) ⇒ Client
constructor
Initializes a new Client with options.
Methods included from Api::Groups
#create_group, #group, #groups, #update_group
Methods included from Api::Calendar
#calendar_event, #calendar_events, #calendar_events_by_cycle, #calendar_events_current_cycle, #create_birth_event, #create_calving_event, #create_dryoff_event, #create_heat_event, #create_insemination_event, #create_keep_open_event, #create_pregnancy_check_event, #delete_calendar_event, #update_birth_event, #update_calving_event, #update_dryoff_event, #update_heat_event, #update_insemination_event, #update_keep_open_event, #update_pregnancy_check_event
Methods included from Api::Animals
#animal, #animal_with_life_number, #animal_with_number, #animal_with_responder, #animals, #create_animal, #delete_animal, #update_animal
Methods included from Api::Installations
Methods included from Api::Applications
#get_access_token, #get_access_tokens
Constructor Details
#initialize(options = {}) ⇒ Client
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.
40 41 42 43 44 45 46 47 |
# File 'lib/business_insight_api_client/client.rb', line 40 def initialize( = {}) @options = @options[:api_url] ||= BusinessInsightApiClient.api_url @options[:authorization_url] ||= BusinessInsightApiClient. @options[:content_type] ||= BusinessInsightApiClient.default_content_type @options[:client_id] ||= BusinessInsightApiClient.client_id @options[:client_secret] ||= BusinessInsightApiClient.client_secret end |
Instance Attribute Details
#options ⇒ Object (readonly)
Lists all options that are set for the client.
27 28 29 |
# File 'lib/business_insight_api_client/client.rb', line 27 def @options end |
Instance Method Details
#access_token=(token) ⇒ Object
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!
65 66 67 68 |
# File 'lib/business_insight_api_client/client.rb', line 65 def access_token=(token) # TODO: fail when not access token class. .current_token = token end |
#authorization ⇒ BusinessInsightApiClient::Helpers::Authorization
Creates new or returns an existing Authorization helper. The helper can be used to retrieve OAuth Tokens from the Authorization server. The helper passes default options as configured with the client.
54 55 56 |
# File 'lib/business_insight_api_client/client.rb', line 54 def @authorization ||= BusinessInsightApiClient::Helpers::Authorization.new() end |