Class: ElephantInTheRoom::TheOneApiSdk::TheOne
- Inherits:
-
Object
- Object
- ElephantInTheRoom::TheOneApiSdk::TheOne
- Includes:
- ApiPaths::AllPaths, Modifiers, Pipeline::PipelineModifiers
- Defined in:
- lib/elephant_in_the_room/the_one_api_sdk.rb
Overview
Entry point into the SDK
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://the-one-api.dev/v2"
Instance Method Summary collapse
-
#initialize(access_token, base_url: DEFAULT_BASE_URL, default_retry_strategy: ElephantInTheRoom::TheOneApiSdk::RetryStrategy::OneTry.new) ⇒ TheOne
constructor
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
Methods included from Modifiers
#paginated, #with_retry_strategy
Methods included from ApiPaths::AllPaths
Methods included from Pipeline::PipelineModifiers
#replace_existing_stage, #with_filters, #with_pagination, #with_path
Constructor Details
#initialize(access_token, base_url: DEFAULT_BASE_URL, default_retry_strategy: ElephantInTheRoom::TheOneApiSdk::RetryStrategy::OneTry.new) ⇒ TheOne
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/elephant_in_the_room/the_one_api_sdk.rb', line 28 def initialize( access_token, base_url: DEFAULT_BASE_URL, default_retry_strategy: ElephantInTheRoom::TheOneApiSdk::RetryStrategy::OneTry.new ) raise "Access token must be given as a string" unless access_token.is_a? String @default_pipeline = lambda { { paginate: ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::Paginate.new(next_stage) }, filter: ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::Filters.new(next_stage, []) }, json: ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::Json.new(next_stage) }, response_body: ->(next_stage) { ElephantInTheRoom::TheOneApiSdk::Pipeline::ResponseBody.new(next_stage) }, set_path: ->(next_stage) {}, retry: lambda { |next_stage| ElephantInTheRoom::TheOneApiSdk::Pipeline::Retry.new(next_stage, default_retry_strategy) }, raise_http_errors: lambda { |next_stage| ElephantInTheRoom::TheOneApiSdk::Pipeline::RaiseHttpErrors.new(next_stage) }, get_request: -> { ElephantInTheRoom::TheOneApiSdk::Pipeline::GetRequest.new(base_url, access_token) }, stages: %i[paginate filter json response_body set_path retry raise_http_errors get_request], } } @pipeline = @default_pipeline end |