Class: Believe::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Believe::Client
- Defined in:
- lib/believe/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
- #api_key ⇒ String readonly
-
#believe ⇒ ::Believe::Resources::Believe
readonly
Interactive endpoints for motivation and guidance.
-
#biscuits ⇒ ::Believe::Resources::Biscuits
readonly
Interactive endpoints for motivation and guidance.
-
#characters ⇒ ::Believe::Resources::Characters
readonly
Operations related to Ted Lasso characters.
- #client_ ⇒ ::Believe::Resources::Client readonly
- #coaching ⇒ ::Believe::Resources::Coaching readonly
-
#conflicts ⇒ ::Believe::Resources::Conflicts
readonly
Interactive endpoints for motivation and guidance.
-
#episodes ⇒ ::Believe::Resources::Episodes
readonly
Operations related to TV episodes.
- #health ⇒ ::Believe::Resources::Health readonly
- #matches ⇒ ::Believe::Resources::Matches readonly
-
#pep_talk ⇒ ::Believe::Resources::PepTalk
readonly
Server-Sent Events (SSE) streaming endpoints.
-
#press ⇒ ::Believe::Resources::Press
readonly
Interactive endpoints for motivation and guidance.
-
#quotes ⇒ ::Believe::Resources::Quotes
readonly
Memorable quotes from the show.
-
#reframe ⇒ ::Believe::Resources::Reframe
readonly
Interactive endpoints for motivation and guidance.
-
#stream ⇒ ::Believe::Resources::Stream
readonly
Server-Sent Events (SSE) streaming endpoints.
-
#team_members ⇒ ::Believe::Resources::TeamMembers
readonly
Team members with union types (oneOf) - Players, Coaches, Medical Staff, Equipment Managers.
-
#teams ⇒ ::Believe::Resources::Teams
readonly
Operations related to football teams.
-
#ticket_sales ⇒ ::Believe::Resources::TicketSales
readonly
Ticket sales with 300 records for practicing pagination, filtering, and financial data.
- #version ⇒ ::Believe::Resources::Version readonly
-
#webhooks ⇒ ::Believe::Resources::Webhooks
readonly
Register webhook endpoints and trigger events for testing.
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#get_welcome(request_options: {}) ⇒ Object
Get a warm welcome and overview of available endpoints.
-
#initialize(api_key: ENV["BELIEVE_API_KEY"], base_url: ENV["BELIEVE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["BELIEVE_API_KEY"], base_url: ENV["BELIEVE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/believe/client.rb', line 135 def initialize( api_key: ENV["BELIEVE_API_KEY"], base_url: ENV["BELIEVE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://believe.cjav.dev" if api_key.nil? raise ArgumentError.new("api_key is required, and can be set via environ: \"BELIEVE_API_KEY\"") end headers = {} custom_headers_env = ENV["BELIEVE_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env.split("\n").each do |line| colon = line.index(":") unless colon.nil? parsed[line[0...colon].strip] = line[(colon + 1)..].strip end end headers = parsed.merge(headers) end @api_key = api_key.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, headers: headers ) @characters = ::Believe::Resources::Characters.new(client: self) @teams = ::Believe::Resources::Teams.new(client: self) @matches = ::Believe::Resources::Matches.new(client: self) @episodes = ::Believe::Resources::Episodes.new(client: self) @quotes = ::Believe::Resources::Quotes.new(client: self) @believe = ::Believe::Resources::Believe.new(client: self) @conflicts = ::Believe::Resources::Conflicts.new(client: self) @reframe = ::Believe::Resources::Reframe.new(client: self) @press = ::Believe::Resources::Press.new(client: self) @coaching = ::Believe::Resources::Coaching.new(client: self) @biscuits = ::Believe::Resources::Biscuits.new(client: self) @pep_talk = ::Believe::Resources::PepTalk.new(client: self) @stream = ::Believe::Resources::Stream.new(client: self) @team_members = ::Believe::Resources::TeamMembers.new(client: self) @webhooks = ::Believe::Resources::Webhooks.new(client: self) @ticket_sales = ::Believe::Resources::TicketSales.new(client: self) @health = ::Believe::Resources::Health.new(client: self) @version = ::Believe::Resources::Version.new(client: self) @client_ = ::Believe::Resources::Client.new(client: self) end |
Instance Attribute Details
#api_key ⇒ String (readonly)
19 20 21 |
# File 'lib/believe/client.rb', line 19 def api_key @api_key end |
#believe ⇒ ::Believe::Resources::Believe (readonly)
Interactive endpoints for motivation and guidance
42 43 44 |
# File 'lib/believe/client.rb', line 42 def believe @believe end |
#biscuits ⇒ ::Believe::Resources::Biscuits (readonly)
Interactive endpoints for motivation and guidance
61 62 63 |
# File 'lib/believe/client.rb', line 61 def biscuits @biscuits end |
#characters ⇒ ::Believe::Resources::Characters (readonly)
Operations related to Ted Lasso characters
23 24 25 |
# File 'lib/believe/client.rb', line 23 def characters @characters end |
#client_ ⇒ ::Believe::Resources::Client (readonly)
92 93 94 |
# File 'lib/believe/client.rb', line 92 def client_ @client_ end |
#coaching ⇒ ::Believe::Resources::Coaching (readonly)
57 58 59 |
# File 'lib/believe/client.rb', line 57 def coaching @coaching end |
#conflicts ⇒ ::Believe::Resources::Conflicts (readonly)
Interactive endpoints for motivation and guidance
46 47 48 |
# File 'lib/believe/client.rb', line 46 def conflicts @conflicts end |
#episodes ⇒ ::Believe::Resources::Episodes (readonly)
Operations related to TV episodes
34 35 36 |
# File 'lib/believe/client.rb', line 34 def episodes @episodes end |
#health ⇒ ::Believe::Resources::Health (readonly)
86 87 88 |
# File 'lib/believe/client.rb', line 86 def health @health end |
#matches ⇒ ::Believe::Resources::Matches (readonly)
30 31 32 |
# File 'lib/believe/client.rb', line 30 def matches @matches end |
#pep_talk ⇒ ::Believe::Resources::PepTalk (readonly)
Server-Sent Events (SSE) streaming endpoints
65 66 67 |
# File 'lib/believe/client.rb', line 65 def pep_talk @pep_talk end |
#press ⇒ ::Believe::Resources::Press (readonly)
Interactive endpoints for motivation and guidance
54 55 56 |
# File 'lib/believe/client.rb', line 54 def press @press end |
#quotes ⇒ ::Believe::Resources::Quotes (readonly)
Memorable quotes from the show
38 39 40 |
# File 'lib/believe/client.rb', line 38 def quotes @quotes end |
#reframe ⇒ ::Believe::Resources::Reframe (readonly)
Interactive endpoints for motivation and guidance
50 51 52 |
# File 'lib/believe/client.rb', line 50 def reframe @reframe end |
#stream ⇒ ::Believe::Resources::Stream (readonly)
Server-Sent Events (SSE) streaming endpoints
69 70 71 |
# File 'lib/believe/client.rb', line 69 def stream @stream end |
#team_members ⇒ ::Believe::Resources::TeamMembers (readonly)
Team members with union types (oneOf) - Players, Coaches, Medical Staff, Equipment Managers
74 75 76 |
# File 'lib/believe/client.rb', line 74 def team_members @team_members end |
#teams ⇒ ::Believe::Resources::Teams (readonly)
Operations related to football teams
27 28 29 |
# File 'lib/believe/client.rb', line 27 def teams @teams end |
#ticket_sales ⇒ ::Believe::Resources::TicketSales (readonly)
Ticket sales with 300 records for practicing pagination, filtering, and financial data
83 84 85 |
# File 'lib/believe/client.rb', line 83 def ticket_sales @ticket_sales end |
#version ⇒ ::Believe::Resources::Version (readonly)
89 90 91 |
# File 'lib/believe/client.rb', line 89 def version @version end |
#webhooks ⇒ ::Believe::Resources::Webhooks (readonly)
Register webhook endpoints and trigger events for testing
78 79 80 |
# File 'lib/believe/client.rb', line 78 def webhooks @webhooks end |
Instance Method Details
#get_welcome(request_options: {}) ⇒ Object
Get a warm welcome and overview of available endpoints.
103 104 105 106 107 108 109 110 |
# File 'lib/believe/client.rb', line 103 def get_welcome(params = {}) request( method: :get, path: "", model: ::Believe::Internal::Type::Unknown, options: params[:request_options] ) end |