Class: VitableConnect::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- VitableConnect::Client
- Defined in:
- lib/vitable_connect/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- ENVIRONMENTS =
rubocop:disable Style/MutableConstant
{production: "https://api.vitablehealth.com", environment_1: "https://api.uat.vitablehealth.com"}
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
API Key or Access Token authentication using Bearer token in Authorization header.
-
#auth ⇒ VitableConnect::Resources::Auth
readonly
Issue short-lived access tokens for scoped API access.
-
#benefit_eligibility_policies ⇒ VitableConnect::Resources::BenefitEligibilityPolicies
readonly
Define rules that determine which employees qualify for benefits.
- #employees ⇒ VitableConnect::Resources::Employees readonly
- #employers ⇒ VitableConnect::Resources::Employers readonly
-
#enrollments ⇒ VitableConnect::Resources::Enrollments
readonly
Manage benefit enrollments and elections for employees.
- #webhook_events ⇒ VitableConnect::Resources::WebhookEvents 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(api_key: ENV["VITABLE_CONNECT_API_KEY"], environment: nil, base_url: ENV["VITABLE_CONNECT_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["VITABLE_CONNECT_API_KEY"], environment: nil, base_url: ENV["VITABLE_CONNECT_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.
header. API keys use the vit*apk* prefix, access tokens use the vit*at* prefix. Defaults to ‘ENV`
Each environment maps to a different base URL:
-
‘production` corresponds to `api.vitablehealth.com`
-
‘environment_1` corresponds to `api.uat.vitablehealth.com`
‘“api.example.com/v2/”`. Defaults to `ENV`
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/vitable_connect/client.rb', line 82 def initialize( api_key: ENV["VITABLE_CONNECT_API_KEY"], environment: nil, base_url: ENV["VITABLE_CONNECT_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 ||= VitableConnect::Client::ENVIRONMENTS.fetch(environment&.to_sym || :production) do = "environment must be one of #{VitableConnect::Client::ENVIRONMENTS.keys}, got #{environment}" raise ArgumentError.new() end if api_key.nil? raise ArgumentError.new("api_key is required, and can be set via environ: \"VITABLE_CONNECT_API_KEY\"") 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 ) @auth = VitableConnect::Resources::Auth.new(client: self) @benefit_eligibility_policies = VitableConnect::Resources::BenefitEligibilityPolicies.new(client: self) @employees = VitableConnect::Resources::Employees.new(client: self) @employers = VitableConnect::Resources::Employers.new(client: self) @enrollments = VitableConnect::Resources::Enrollments.new(client: self) @webhook_events = VitableConnect::Resources::WebhookEvents.new(client: self) end |
Instance Attribute Details
#api_key ⇒ String (readonly)
API Key or Access Token authentication using Bearer token in Authorization header. API keys use the vit*apk* prefix, access tokens use the vit*at* prefix.
27 28 29 |
# File 'lib/vitable_connect/client.rb', line 27 def api_key @api_key end |
#auth ⇒ VitableConnect::Resources::Auth (readonly)
Issue short-lived access tokens for scoped API access
31 32 33 |
# File 'lib/vitable_connect/client.rb', line 31 def auth @auth end |
#benefit_eligibility_policies ⇒ VitableConnect::Resources::BenefitEligibilityPolicies (readonly)
Define rules that determine which employees qualify for benefits
35 36 37 |
# File 'lib/vitable_connect/client.rb', line 35 def benefit_eligibility_policies @benefit_eligibility_policies end |
#employees ⇒ VitableConnect::Resources::Employees (readonly)
38 39 40 |
# File 'lib/vitable_connect/client.rb', line 38 def employees @employees end |
#employers ⇒ VitableConnect::Resources::Employers (readonly)
41 42 43 |
# File 'lib/vitable_connect/client.rb', line 41 def employers @employers end |
#enrollments ⇒ VitableConnect::Resources::Enrollments (readonly)
Manage benefit enrollments and elections for employees
45 46 47 |
# File 'lib/vitable_connect/client.rb', line 45 def enrollments @enrollments end |
#webhook_events ⇒ VitableConnect::Resources::WebhookEvents (readonly)
48 49 50 |
# File 'lib/vitable_connect/client.rb', line 48 def webhook_events @webhook_events end |