Class: DemoApiScalarGalaxy::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- DemoApiScalarGalaxy::Client
- Defined in:
- lib/amritk-galaxy-staging/client.rb,
sig/amritk-galaxy-staging/client.rbs
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- ENVIRONMENTS =
rubocop:disable Style/MutableConstant
{ production: "https://galaxy.scalar.com", responds_with_your_request_data: "https://void.scalar.com/{path}" }
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::DemoApiScalarGalaxy, Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
-
#api_key_cookie ⇒ String?
readonly
API key browser cookie.
-
#api_key_header ⇒ String?
readonly
API key request header.
-
#api_key_query ⇒ String?
readonly
API key query parameter.
-
#authentication ⇒ DemoApiScalarGalaxy::Resources::Authentication
readonly
Some endpoints are public, but some require authentication.
- #basic_auth_password ⇒ String? readonly
- #basic_auth_username ⇒ String? readonly
-
#bearer_auth ⇒ String?
readonly
JWT Bearer token authentication.
-
#celestial_bodies ⇒ DemoApiScalarGalaxy::Resources::CelestialBodies
readonly
Celestial bodies are the planets and satellites in the Scalar Galaxy.
-
#o_auth2 ⇒ String?
readonly
OAuth 2.0 authentication.
-
#open_id_connect ⇒ String?
readonly
OpenID Connect Authentication.
-
#planets ⇒ DemoApiScalarGalaxy::Resources::Planets
readonly
Everything about planets.
-
#webhook_secret ⇒ String?
readonly
Secret used to verify incoming webhook signatures.
- #webhooks ⇒ DemoApiScalarGalaxy::Resources::Webhooks readonly
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
-
#initialize(bearer_auth: , basic_auth_username: , basic_auth_password: , api_key_header: , api_key_query: , api_key_cookie: , o_auth2: , open_id_connect: , webhook_secret: , environment: nil, 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(bearer_auth: , basic_auth_username: , basic_auth_password: , api_key_header: , api_key_query: , api_key_cookie: , o_auth2: , open_id_connect: , webhook_secret: , environment: nil, 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.
ENV["OFFICIAL_GALAXY_TESTING_WEBHOOK_SECRET"]
Each environment maps to a different base URL:
productioncorresponds tohttps://galaxy.scalar.comresponds_with_your_request_datacorresponds tohttps://void.scalar.com/{path}
"https://api.example.com/v2/". Defaults to
ENV["OFFICIAL_GALAXY_TESTING_BASE_URL"]
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/amritk-galaxy-staging/client.rb', line 176 def initialize( bearer_auth: ENV["BEARER_AUTH"], basic_auth_username: ENV["BASIC_AUTH_USERNAME"], basic_auth_password: ENV["BASIC_AUTH_PASSWORD"], api_key_header: ENV["API_KEY_HEADER"], api_key_query: ENV["API_KEY_QUERY"], api_key_cookie: ENV["API_KEY_COOKIE"], o_auth2: ENV["O_AUTH2"], open_id_connect: ENV["OPEN_ID_CONNECT"], webhook_secret: ENV["OFFICIAL_GALAXY_TESTING_WEBHOOK_SECRET"], environment: nil, base_url: ENV["OFFICIAL_GALAXY_TESTING_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 ||= DemoApiScalarGalaxy::Client::ENVIRONMENTS.fetch(environment&.to_sym || :production) do = "environment must be one of #{DemoApiScalarGalaxy::Client::ENVIRONMENTS.keys}, got #{environment}" raise ArgumentError.new() end headers = {} custom_headers_env = ENV["OFFICIAL_GALAXY_TESTING_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env .split("\n") .each do |line| colon = line.index(":") parsed[line[0...colon].strip] = line[(colon + 1)..].strip unless colon.nil? end headers = parsed.merge(headers) end @bearer_auth = bearer_auth&.to_s @basic_auth_username = basic_auth_username&.to_s @basic_auth_password = basic_auth_password&.to_s @api_key_header = api_key_header&.to_s @api_key_query = api_key_query&.to_s @api_key_cookie = &.to_s @o_auth2 = o_auth2&.to_s @open_id_connect = open_id_connect&.to_s @webhook_secret = webhook_secret&.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 ) @planets = DemoApiScalarGalaxy::Resources::Planets.new(client: self) @celestial_bodies = DemoApiScalarGalaxy::Resources::CelestialBodies.new(client: self) @authentication = DemoApiScalarGalaxy::Resources::Authentication.new(client: self) @webhooks = DemoApiScalarGalaxy::Resources::Webhooks.new(client: self) end |
Instance Attribute Details
#api_key_cookie ⇒ String? (readonly)
API key browser cookie
46 47 48 |
# File 'lib/amritk-galaxy-staging/client.rb', line 46 def @api_key_cookie end |
#api_key_header ⇒ String? (readonly)
API key request header
38 39 40 |
# File 'lib/amritk-galaxy-staging/client.rb', line 38 def api_key_header @api_key_header end |
#api_key_query ⇒ String? (readonly)
API key query parameter
42 43 44 |
# File 'lib/amritk-galaxy-staging/client.rb', line 42 def api_key_query @api_key_query end |
#authentication ⇒ DemoApiScalarGalaxy::Resources::Authentication (readonly)
Some endpoints are public, but some require authentication. We provide all the required endpoints to create an account and authorize yourself.
71 72 73 |
# File 'lib/amritk-galaxy-staging/client.rb', line 71 def authentication @authentication end |
#basic_auth_password ⇒ String? (readonly)
34 35 36 |
# File 'lib/amritk-galaxy-staging/client.rb', line 34 def basic_auth_password @basic_auth_password end |
#basic_auth_username ⇒ String? (readonly)
31 32 33 |
# File 'lib/amritk-galaxy-staging/client.rb', line 31 def basic_auth_username @basic_auth_username end |
#bearer_auth ⇒ String? (readonly)
JWT Bearer token authentication
28 29 30 |
# File 'lib/amritk-galaxy-staging/client.rb', line 28 def bearer_auth @bearer_auth end |
#celestial_bodies ⇒ DemoApiScalarGalaxy::Resources::CelestialBodies (readonly)
Celestial bodies are the planets and satellites in the Scalar Galaxy.
66 67 68 |
# File 'lib/amritk-galaxy-staging/client.rb', line 66 def celestial_bodies @celestial_bodies end |
#o_auth2 ⇒ String? (readonly)
OAuth 2.0 authentication
50 51 52 |
# File 'lib/amritk-galaxy-staging/client.rb', line 50 def o_auth2 @o_auth2 end |
#open_id_connect ⇒ String? (readonly)
OpenID Connect Authentication
54 55 56 |
# File 'lib/amritk-galaxy-staging/client.rb', line 54 def open_id_connect @open_id_connect end |
#planets ⇒ DemoApiScalarGalaxy::Resources::Planets (readonly)
Everything about planets
62 63 64 |
# File 'lib/amritk-galaxy-staging/client.rb', line 62 def planets @planets end |
#webhook_secret ⇒ String? (readonly)
Secret used to verify incoming webhook signatures.
58 59 60 |
# File 'lib/amritk-galaxy-staging/client.rb', line 58 def webhook_secret @webhook_secret end |
#webhooks ⇒ DemoApiScalarGalaxy::Resources::Webhooks (readonly)
74 75 76 |
# File 'lib/amritk-galaxy-staging/client.rb', line 74 def webhooks @webhooks end |