Class: Bloomy::Client
- Inherits:
-
Object
- Object
- Bloomy::Client
- Defined in:
- lib/bloomy/client.rb
Overview
The Client class is the main entry point for interacting with the Bloomy API. It provides methods for managing Bloom Growth features.
Constant Summary collapse
- DEFAULT_RETRY_OPTIONS =
Default retry options for transient failures
{ max: 3, interval: 0.5, interval_randomness: 0.5, backoff_factor: 2, retry_statuses: [429, 502, 503, 504], exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed] }.freeze
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#goal ⇒ Object
readonly
Returns the value of attribute goal.
-
#headline ⇒ Object
readonly
Returns the value of attribute headline.
-
#issue ⇒ Object
readonly
Returns the value of attribute issue.
-
#meeting ⇒ Object
readonly
Returns the value of attribute meeting.
-
#scorecard ⇒ Object
readonly
Returns the value of attribute scorecard.
-
#todo ⇒ Object
readonly
Returns the value of attribute todo.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(api_key = nil, open_timeout: 10, read_timeout: 30, retry_options: {}) ⇒ Client
constructor
Initializes a new Client instance.
-
#user_id ⇒ Integer
Returns the current user’s ID.
Constructor Details
#initialize(api_key = nil, open_timeout: 10, read_timeout: 30, retry_options: {}) ⇒ Client
Initializes a new Client instance
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/bloomy/client.rb', line 56 def initialize(api_key = nil, open_timeout: 10, read_timeout: 30, retry_options: {}) @configuration = Configuration.new unless api_key @api_key = api_key || @configuration.api_key raise ArgumentError, "No API key provided. Set it in configuration or pass it directly." unless @api_key @base_url = "https://app.bloomgrowth.com/api/v1/" = DEFAULT_RETRY_OPTIONS.merge() @conn = Faraday.new(url: @base_url) do |faraday| faraday.request :retry, faraday.response :json faraday.adapter Faraday.default_adapter faraday.headers["Accept"] = "*/*" faraday.headers["Content-Type"] = "application/json" faraday.headers["Authorization"] = "Bearer #{@api_key}" faraday..open_timeout = open_timeout faraday..timeout = read_timeout end @user = User.new(@conn) @todo = Todo.new(@conn) @goal = Goal.new(@conn) @meeting = Meeting.new(@conn) @scorecard = Scorecard.new(@conn) @issue = Issue.new(@conn) @headline = Headline.new(@conn) end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def configuration @configuration end |
#goal ⇒ Object (readonly)
Returns the value of attribute goal.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def goal @goal end |
#headline ⇒ Object (readonly)
Returns the value of attribute headline.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def headline @headline end |
#issue ⇒ Object (readonly)
Returns the value of attribute issue.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def issue @issue end |
#meeting ⇒ Object (readonly)
Returns the value of attribute meeting.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def meeting @meeting end |
#scorecard ⇒ Object (readonly)
Returns the value of attribute scorecard.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def scorecard @scorecard end |
#todo ⇒ Object (readonly)
Returns the value of attribute todo.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def todo @todo end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
28 29 30 |
# File 'lib/bloomy/client.rb', line 28 def user @user end |
Instance Method Details
#user_id ⇒ Integer
Returns the current user’s ID
36 37 38 |
# File 'lib/bloomy/client.rb', line 36 def user_id @user_id ||= @user.user_id end |