diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 859ebd32..76293726 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.42" + ".": "0.1.0-alpha.43" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index b15bfab0..072a0a86 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 46 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-46f433f34d440aa1dfcc48cc8d822c598571b68be2f723ec99e1b4fba6c13b1e.yml openapi_spec_hash: 5b5cd728776723ac773900f7e8a32c05 -config_hash: 0892e2e0eeb0343a022afa62e9080dd1 +config_hash: ccdf6a5b4aaa2a0897c89ac8685d8eb0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 25e9d9dd..de2d2011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 0.1.0-alpha.43 (2026-01-26) + +Full Changelog: [v0.1.0-alpha.42...v0.1.0-alpha.43](https://github.com/Finch-API/finch-api-ruby/compare/v0.1.0-alpha.42...v0.1.0-alpha.43) + +### Features + +* **api:** add per endpoint security ([ac937c1](https://github.com/Finch-API/finch-api-ruby/commit/ac937c138291704137a33d18cea1571d2e6f96ca)) + + +### Bug Fixes + +* **tests:** skip broken date validation test ([2ee41c8](https://github.com/Finch-API/finch-api-ruby/commit/2ee41c81ef9707aa7180723a283789a5bbaa041d)) + + +### Chores + +* **internal:** codegen related update ([a021ffb](https://github.com/Finch-API/finch-api-ruby/commit/a021ffb4eec64de459cb22c27b4c7c4592003d21)) + ## 0.1.0-alpha.42 (2026-01-16) Full Changelog: [v0.1.0-alpha.41...v0.1.0-alpha.42](https://github.com/Finch-API/finch-api-ruby/compare/v0.1.0-alpha.41...v0.1.0-alpha.42) diff --git a/Gemfile.lock b/Gemfile.lock index 01a79a1a..86f1478c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - finch-api (0.1.0.pre.alpha.42) + finch-api (0.1.0.pre.alpha.43) cgi connection_pool diff --git a/README.md b/README.md index 8085e54e..2fca0f5e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "finch-api", "~> 0.1.0.pre.alpha.42" +gem "finch-api", "~> 0.1.0.pre.alpha.43" ``` diff --git a/lib/finch_api/client.rb b/lib/finch_api/client.rb index f3330ed8..04735b96 100644 --- a/lib/finch_api/client.rb +++ b/lib/finch_api/client.rb @@ -56,11 +56,11 @@ class Client < FinchAPI::Internal::Transport::BaseClient # @api private # + # @param security [Hash{Symbol=>Boolean}] + # # @return [Hash{String=>String}] - private def auth_headers - return bearer_auth unless bearer_auth.empty? - return basic_auth unless basic_auth.empty? - {} + private def auth_headers(security:) + {bearer_auth:, basic_auth:}.slice(*security.keys).values.reduce({}, :merge) end # @api private diff --git a/lib/finch_api/internal/transport/base_client.rb b/lib/finch_api/internal/transport/base_client.rb index af133bbc..4b00c2be 100644 --- a/lib/finch_api/internal/transport/base_client.rb +++ b/lib/finch_api/internal/transport/base_client.rb @@ -31,7 +31,19 @@ class << self # # @raise [ArgumentError] def validate!(req) - keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :stream, :model, :options] + keys = [ + :method, + :path, + :query, + :headers, + :body, + :unwrap, + :page, + :stream, + :model, + :security, + :options + ] case req in Hash req.each_key do |k| @@ -252,6 +264,8 @@ def initialize( # # @option req [FinchAPI::Internal::Type::Converter, Class, nil] :model # + # @option req [Hash{Symbol=>Boolean}, nil] :security + # # @param opts [Hash{Symbol=>Object}] . # # @option opts [String, nil] :idempotency_key @@ -276,7 +290,12 @@ def initialize( headers = FinchAPI::Internal::Util.normalized_headers( @headers, - auth_headers, + auth_headers( + security: req.fetch( + :security, + {bearer_auth: true, basic_auth: true} + ) + ), req[:headers].to_h, opts[:extra_headers].to_h ) @@ -439,7 +458,7 @@ def send_request(request, redirect_count:, retry_count:, send_retry_header:) # Execute the request specified by `req`. This is the method that all resource # methods call into. # - # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: FinchAPI::Internal::Type::Unknown, options: {}) + # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: FinchAPI::Internal::Type::Unknown, security: {bearer_auth: true, basic_auth: true}, options: {}) # # @param method [Symbol] # @@ -459,6 +478,8 @@ def send_request(request, redirect_count:, retry_count:, send_retry_header:) # # @param model [FinchAPI::Internal::Type::Converter, Class, nil] # + # @param security [Hash{Symbol=>Boolean}, nil] + # # @param options [FinchAPI::RequestOptions, Hash{Symbol=>Object}, nil] . # # @option options [String, nil] :idempotency_key @@ -551,6 +572,7 @@ def inspect page: T.nilable(T::Class[FinchAPI::Internal::Type::BasePage[FinchAPI::Internal::Type::BaseModel]]), stream: T.nilable(T::Class[T.anything]), model: T.nilable(FinchAPI::Internal::Type::Converter::Input), + security: T.nilable({bearer_auth: T::Boolean, basic_auth: T::Boolean}), options: T.nilable(FinchAPI::RequestOptions::OrHash) } end diff --git a/lib/finch_api/resources/access_tokens.rb b/lib/finch_api/resources/access_tokens.rb index 9efb267d..a3898776 100644 --- a/lib/finch_api/resources/access_tokens.rb +++ b/lib/finch_api/resources/access_tokens.rb @@ -27,6 +27,7 @@ def create(params) path: "auth/token", body: parsed, model: FinchAPI::CreateAccessTokenResponse, + security: {}, options: options ) end diff --git a/lib/finch_api/resources/account.rb b/lib/finch_api/resources/account.rb index 0a8ec282..ebaa9431 100644 --- a/lib/finch_api/resources/account.rb +++ b/lib/finch_api/resources/account.rb @@ -17,6 +17,7 @@ def disconnect(params = {}) method: :post, path: "disconnect", model: FinchAPI::DisconnectResponse, + security: {bearer_auth: true}, options: params[:request_options] ) end @@ -35,6 +36,7 @@ def introspect(params = {}) method: :get, path: "introspect", model: FinchAPI::Introspection, + security: {bearer_auth: true}, options: params[:request_options] ) end diff --git a/lib/finch_api/resources/connect/sessions.rb b/lib/finch_api/resources/connect/sessions.rb index 3d850a1f..625186cd 100644 --- a/lib/finch_api/resources/connect/sessions.rb +++ b/lib/finch_api/resources/connect/sessions.rb @@ -41,6 +41,7 @@ def new(params) path: "connect/sessions", body: parsed, model: FinchAPI::Models::Connect::SessionNewResponse, + security: {basic_auth: true}, options: options ) end @@ -72,6 +73,7 @@ def reauthenticate(params) path: "connect/sessions/reauthenticate", body: parsed, model: FinchAPI::Models::Connect::SessionReauthenticateResponse, + security: {basic_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/benefits.rb b/lib/finch_api/resources/hris/benefits.rb index 9f72a62d..c9e0ed4a 100644 --- a/lib/finch_api/resources/hris/benefits.rb +++ b/lib/finch_api/resources/hris/benefits.rb @@ -39,6 +39,7 @@ def create(params = {}) query: parsed.slice(*query_params), body: parsed.except(*query_params), model: FinchAPI::HRIS::CreateCompanyBenefitsResponse, + security: {bearer_auth: true}, options: options ) end @@ -63,6 +64,7 @@ def retrieve(benefit_id, params = {}) path: ["employer/benefits/%1$s", benefit_id], query: parsed, model: FinchAPI::HRIS::CompanyBenefit, + security: {bearer_auth: true}, options: options ) end @@ -91,6 +93,7 @@ def update(benefit_id, params = {}) query: parsed.slice(*query_params), body: parsed.except(*query_params), model: FinchAPI::HRIS::UpdateCompanyBenefitResponse, + security: {bearer_auth: true}, options: options ) end @@ -114,6 +117,7 @@ def list(params = {}) query: parsed, page: FinchAPI::Internal::SinglePage, model: FinchAPI::HRIS::CompanyBenefit, + security: {bearer_auth: true}, options: options ) end @@ -137,6 +141,7 @@ def list_supported_benefits(params = {}) query: parsed, page: FinchAPI::Internal::SinglePage, model: FinchAPI::HRIS::SupportedBenefit, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/benefits/individuals.rb b/lib/finch_api/resources/hris/benefits/individuals.rb index 8ec78fa6..5ca102e3 100644 --- a/lib/finch_api/resources/hris/benefits/individuals.rb +++ b/lib/finch_api/resources/hris/benefits/individuals.rb @@ -31,6 +31,7 @@ def enroll_many(benefit_id, params = {}) query: parsed.except(:individuals), body: parsed[:individuals], model: FinchAPI::HRIS::Benefits::EnrolledIndividualBenefitResponse, + security: {bearer_auth: true}, options: options ) end @@ -55,6 +56,7 @@ def enrolled_ids(benefit_id, params = {}) path: ["employer/benefits/%1$s/enrolled", benefit_id], query: parsed, model: FinchAPI::Models::HRIS::Benefits::IndividualEnrolledIDsResponse, + security: {bearer_auth: true}, options: options ) end @@ -86,6 +88,7 @@ def retrieve_many_benefits(benefit_id, params = {}) query: parsed, page: FinchAPI::Internal::SinglePage, model: FinchAPI::HRIS::Benefits::IndividualBenefit, + security: {bearer_auth: true}, options: options ) end @@ -114,6 +117,7 @@ def unenroll_many(benefit_id, params = {}) query: parsed.slice(*query_params), body: parsed.except(*query_params), model: FinchAPI::HRIS::Benefits::UnenrolledIndividualBenefitResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/company.rb b/lib/finch_api/resources/hris/company.rb index 6a93f9fb..11309297 100644 --- a/lib/finch_api/resources/hris/company.rb +++ b/lib/finch_api/resources/hris/company.rb @@ -25,6 +25,7 @@ def retrieve(params = {}) path: "employer/company", query: parsed, model: FinchAPI::HRIS::HRISCompany, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/company/pay_statement_item.rb b/lib/finch_api/resources/hris/company/pay_statement_item.rb index 26bb84ca..88b048b1 100644 --- a/lib/finch_api/resources/hris/company/pay_statement_item.rb +++ b/lib/finch_api/resources/hris/company/pay_statement_item.rb @@ -41,6 +41,7 @@ def list(params = {}) query: parsed, page: FinchAPI::Internal::ResponsesPage, model: FinchAPI::Models::HRIS::Company::PayStatementItemListResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/company/pay_statement_item/rules.rb b/lib/finch_api/resources/hris/company/pay_statement_item/rules.rb index c7085069..597bcc19 100644 --- a/lib/finch_api/resources/hris/company/pay_statement_item/rules.rb +++ b/lib/finch_api/resources/hris/company/pay_statement_item/rules.rb @@ -43,6 +43,7 @@ def create(params = {}) query: parsed.slice(*query_params), body: parsed.except(*query_params), model: FinchAPI::Models::HRIS::Company::PayStatementItem::RuleCreateResponse, + security: {bearer_auth: true}, options: options ) end @@ -71,6 +72,7 @@ def update(rule_id, params = {}) query: parsed.slice(*query_params), body: parsed.except(*query_params), model: FinchAPI::Models::HRIS::Company::PayStatementItem::RuleUpdateResponse, + security: {bearer_auth: true}, options: options ) end @@ -94,6 +96,7 @@ def list(params = {}) query: parsed, page: FinchAPI::Internal::ResponsesPage, model: FinchAPI::Models::HRIS::Company::PayStatementItem::RuleListResponse, + security: {bearer_auth: true}, options: options ) end @@ -118,6 +121,7 @@ def delete(rule_id, params = {}) path: ["employer/pay-statement-item/rule/%1$s", rule_id], query: parsed, model: FinchAPI::Models::HRIS::Company::PayStatementItem::RuleDeleteResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/directory.rb b/lib/finch_api/resources/hris/directory.rb index d04b348e..d46ee225 100644 --- a/lib/finch_api/resources/hris/directory.rb +++ b/lib/finch_api/resources/hris/directory.rb @@ -27,6 +27,7 @@ def list(params = {}) query: parsed, page: FinchAPI::Internal::IndividualsPage, model: FinchAPI::HRIS::IndividualInDirectory, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/documents.rb b/lib/finch_api/resources/hris/documents.rb index 02ac3131..4b9f78c6 100644 --- a/lib/finch_api/resources/hris/documents.rb +++ b/lib/finch_api/resources/hris/documents.rb @@ -34,6 +34,7 @@ def list(params = {}) path: "employer/documents", query: parsed, model: FinchAPI::Models::HRIS::DocumentListResponse, + security: {bearer_auth: true}, options: options ) end @@ -59,6 +60,7 @@ def retreive(document_id, params = {}) path: ["employer/documents/%1$s", document_id], query: parsed, model: FinchAPI::Models::HRIS::DocumentRetreiveResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/employments.rb b/lib/finch_api/resources/hris/employments.rb index 6609de72..8c04e613 100644 --- a/lib/finch_api/resources/hris/employments.rb +++ b/lib/finch_api/resources/hris/employments.rb @@ -27,6 +27,7 @@ def retrieve_many(params) body: parsed.except(*query_params), page: FinchAPI::Internal::ResponsesPage, model: FinchAPI::HRIS::EmploymentDataResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/individuals.rb b/lib/finch_api/resources/hris/individuals.rb index 9f9182f6..20455946 100644 --- a/lib/finch_api/resources/hris/individuals.rb +++ b/lib/finch_api/resources/hris/individuals.rb @@ -29,6 +29,7 @@ def retrieve_many(params = {}) body: parsed.except(*query_params), page: FinchAPI::Internal::ResponsesPage, model: FinchAPI::HRIS::IndividualResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/pay_statements.rb b/lib/finch_api/resources/hris/pay_statements.rb index 40b48832..53fac6aa 100644 --- a/lib/finch_api/resources/hris/pay_statements.rb +++ b/lib/finch_api/resources/hris/pay_statements.rb @@ -30,6 +30,7 @@ def retrieve_many(params) body: parsed.except(*query_params), page: FinchAPI::Internal::ResponsesPage, model: FinchAPI::HRIS::PayStatementResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/hris/payments.rb b/lib/finch_api/resources/hris/payments.rb index 1079291c..489d73a6 100644 --- a/lib/finch_api/resources/hris/payments.rb +++ b/lib/finch_api/resources/hris/payments.rb @@ -30,6 +30,7 @@ def list(params) query: parsed, page: FinchAPI::Internal::SinglePage, model: FinchAPI::HRIS::Payment, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/jobs/automated.rb b/lib/finch_api/resources/jobs/automated.rb index 08853dd8..4e483b59 100644 --- a/lib/finch_api/resources/jobs/automated.rb +++ b/lib/finch_api/resources/jobs/automated.rb @@ -37,6 +37,7 @@ def create(params) path: "jobs/automated", body: parsed, model: FinchAPI::Models::Jobs::AutomatedCreateResponse, + security: {bearer_auth: true}, options: options ) end @@ -56,6 +57,7 @@ def retrieve(job_id, params = {}) method: :get, path: ["jobs/automated/%1$s", job_id], model: FinchAPI::Jobs::AutomatedAsyncJob, + security: {bearer_auth: true}, options: params[:request_options] ) end @@ -82,6 +84,7 @@ def list(params = {}) path: "jobs/automated", query: parsed, model: FinchAPI::Models::Jobs::AutomatedListResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/jobs/manual.rb b/lib/finch_api/resources/jobs/manual.rb index fa482da0..a0cafef7 100644 --- a/lib/finch_api/resources/jobs/manual.rb +++ b/lib/finch_api/resources/jobs/manual.rb @@ -20,6 +20,7 @@ def retrieve(job_id, params = {}) method: :get, path: ["jobs/manual/%1$s", job_id], model: FinchAPI::Jobs::ManualAsyncJob, + security: {bearer_auth: true}, options: params[:request_options] ) end diff --git a/lib/finch_api/resources/payroll/pay_groups.rb b/lib/finch_api/resources/payroll/pay_groups.rb index da14ff13..2db05d98 100644 --- a/lib/finch_api/resources/payroll/pay_groups.rb +++ b/lib/finch_api/resources/payroll/pay_groups.rb @@ -24,6 +24,7 @@ def retrieve(pay_group_id, params = {}) path: ["employer/pay-groups/%1$s", pay_group_id], query: parsed, model: FinchAPI::Models::Payroll::PayGroupRetrieveResponse, + security: {bearer_auth: true}, options: options ) end @@ -51,6 +52,7 @@ def list(params = {}) query: parsed, page: FinchAPI::Internal::SinglePage, model: FinchAPI::Models::Payroll::PayGroupListResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/providers.rb b/lib/finch_api/resources/providers.rb index 7c278011..d4bf5071 100644 --- a/lib/finch_api/resources/providers.rb +++ b/lib/finch_api/resources/providers.rb @@ -18,6 +18,7 @@ def list(params = {}) path: "providers", page: FinchAPI::Internal::SinglePage, model: FinchAPI::Models::ProviderListResponse, + security: {bearer_auth: true}, options: params[:request_options] ) end diff --git a/lib/finch_api/resources/request_forwarding.rb b/lib/finch_api/resources/request_forwarding.rb index 44222145..715a0a8d 100644 --- a/lib/finch_api/resources/request_forwarding.rb +++ b/lib/finch_api/resources/request_forwarding.rb @@ -35,6 +35,7 @@ def forward(params) path: "forward", body: parsed, model: FinchAPI::Models::RequestForwardingForwardResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/company.rb b/lib/finch_api/resources/sandbox/company.rb index 34f959df..68431a86 100644 --- a/lib/finch_api/resources/sandbox/company.rb +++ b/lib/finch_api/resources/sandbox/company.rb @@ -39,6 +39,7 @@ def update(params) path: "sandbox/company", body: parsed, model: FinchAPI::Models::Sandbox::CompanyUpdateResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/connections.rb b/lib/finch_api/resources/sandbox/connections.rb index a6c7389f..f8653157 100644 --- a/lib/finch_api/resources/sandbox/connections.rb +++ b/lib/finch_api/resources/sandbox/connections.rb @@ -34,6 +34,7 @@ def create(params) path: "sandbox/connections", body: parsed, model: FinchAPI::Models::Sandbox::ConnectionCreateResponse, + security: {basic_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/connections/accounts.rb b/lib/finch_api/resources/sandbox/connections/accounts.rb index e769c1dc..4b5e7028 100644 --- a/lib/finch_api/resources/sandbox/connections/accounts.rb +++ b/lib/finch_api/resources/sandbox/connections/accounts.rb @@ -32,6 +32,7 @@ def create(params) path: "sandbox/connections/accounts", body: parsed, model: FinchAPI::Models::Sandbox::Connections::AccountCreateResponse, + security: {basic_auth: true}, options: options ) end @@ -54,6 +55,7 @@ def update(params = {}) path: "sandbox/connections/accounts", body: parsed, model: FinchAPI::Models::Sandbox::Connections::AccountUpdateResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/directory.rb b/lib/finch_api/resources/sandbox/directory.rb index 1589a91f..d046b784 100644 --- a/lib/finch_api/resources/sandbox/directory.rb +++ b/lib/finch_api/resources/sandbox/directory.rb @@ -25,6 +25,7 @@ def create(params = {}) path: "sandbox/directory", body: parsed[:body], model: FinchAPI::Internal::Type::ArrayOf[FinchAPI::Internal::Type::Unknown], + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/employment.rb b/lib/finch_api/resources/sandbox/employment.rb index 2a6b351c..efed725d 100644 --- a/lib/finch_api/resources/sandbox/employment.rb +++ b/lib/finch_api/resources/sandbox/employment.rb @@ -61,6 +61,7 @@ def update(individual_id, params = {}) path: ["sandbox/employment/%1$s", individual_id], body: parsed, model: FinchAPI::Models::Sandbox::EmploymentUpdateResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/individual.rb b/lib/finch_api/resources/sandbox/individual.rb index 37b0ab55..d7cf1b0c 100644 --- a/lib/finch_api/resources/sandbox/individual.rb +++ b/lib/finch_api/resources/sandbox/individual.rb @@ -49,6 +49,7 @@ def update(individual_id, params = {}) path: ["sandbox/individual/%1$s", individual_id], body: parsed, model: FinchAPI::Models::Sandbox::IndividualUpdateResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/jobs.rb b/lib/finch_api/resources/sandbox/jobs.rb index ee2b236f..0d7de510 100644 --- a/lib/finch_api/resources/sandbox/jobs.rb +++ b/lib/finch_api/resources/sandbox/jobs.rb @@ -25,6 +25,7 @@ def create(params) path: "sandbox/jobs", body: parsed, model: FinchAPI::Models::Sandbox::JobCreateResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/jobs/configuration.rb b/lib/finch_api/resources/sandbox/jobs/configuration.rb index 6e21c45e..c9a5800c 100644 --- a/lib/finch_api/resources/sandbox/jobs/configuration.rb +++ b/lib/finch_api/resources/sandbox/jobs/configuration.rb @@ -19,6 +19,7 @@ def retrieve(params = {}) method: :get, path: "sandbox/jobs/configuration", model: FinchAPI::Internal::Type::ArrayOf[FinchAPI::Sandbox::Jobs::SandboxJobConfiguration], + security: {bearer_auth: true}, options: params[:request_options] ) end @@ -41,6 +42,7 @@ def update(params) path: "sandbox/jobs/configuration", body: parsed, model: FinchAPI::Sandbox::Jobs::SandboxJobConfiguration, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/resources/sandbox/payment.rb b/lib/finch_api/resources/sandbox/payment.rb index ab0edb7d..e6e97027 100644 --- a/lib/finch_api/resources/sandbox/payment.rb +++ b/lib/finch_api/resources/sandbox/payment.rb @@ -26,6 +26,7 @@ def create(params = {}) path: "sandbox/payment", body: parsed, model: FinchAPI::Models::Sandbox::PaymentCreateResponse, + security: {bearer_auth: true}, options: options ) end diff --git a/lib/finch_api/version.rb b/lib/finch_api/version.rb index b6329508..d0a78b57 100644 --- a/lib/finch_api/version.rb +++ b/lib/finch_api/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module FinchAPI - VERSION = "0.1.0.pre.alpha.42" + VERSION = "0.1.0.pre.alpha.43" end diff --git a/rbi/finch_api/client.rbi b/rbi/finch_api/client.rbi index 4c795423..d72ce814 100644 --- a/rbi/finch_api/client.rbi +++ b/rbi/finch_api/client.rbi @@ -50,8 +50,12 @@ module FinchAPI attr_reader :connect # @api private - sig { override.returns(T::Hash[String, String]) } - private def auth_headers + sig do + override + .params(security: { bearer_auth: T::Boolean, basic_auth: T::Boolean }) + .returns(T::Hash[String, String]) + end + private def auth_headers(security:) end # @api private diff --git a/rbi/finch_api/internal/transport/base_client.rbi b/rbi/finch_api/internal/transport/base_client.rbi index 3f33b2f5..4f5573a1 100644 --- a/rbi/finch_api/internal/transport/base_client.rbi +++ b/rbi/finch_api/internal/transport/base_client.rbi @@ -51,6 +51,8 @@ module FinchAPI ), stream: T.nilable(T::Class[T.anything]), model: T.nilable(FinchAPI::Internal::Type::Converter::Input), + security: + T.nilable({ bearer_auth: T::Boolean, basic_auth: T::Boolean }), options: T.nilable(FinchAPI::RequestOptions::OrHash) } end @@ -228,7 +230,7 @@ module FinchAPI # Execute the request specified by `req`. This is the method that all resource # methods call into. # - # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: FinchAPI::Internal::Type::Unknown, options: {}) + # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: FinchAPI::Internal::Type::Unknown, security: {bearer_auth: true, basic_auth: true}, options: {}) sig do params( method: Symbol, @@ -270,6 +272,8 @@ module FinchAPI ), stream: T.nilable(T::Class[T.anything]), model: T.nilable(FinchAPI::Internal::Type::Converter::Input), + security: + T.nilable({ bearer_auth: T::Boolean, basic_auth: T::Boolean }), options: T.nilable(FinchAPI::RequestOptions::OrHash) ).returns(T.anything) end @@ -283,6 +287,7 @@ module FinchAPI page: nil, stream: nil, model: FinchAPI::Internal::Type::Unknown, + security: { bearer_auth: true, basic_auth: true }, options: {} ) end diff --git a/sig/finch_api/client.rbs b/sig/finch_api/client.rbs index f7350df8..5935a270 100644 --- a/sig/finch_api/client.rbs +++ b/sig/finch_api/client.rbs @@ -34,7 +34,9 @@ module FinchAPI attr_reader connect: FinchAPI::Resources::Connect - private def auth_headers: -> ::Hash[String, String] + private def auth_headers: ( + security: { bearer_auth: bool, basic_auth: bool } + ) -> ::Hash[String, String] private def bearer_auth: -> ::Hash[String, String] diff --git a/sig/finch_api/internal/transport/base_client.rbs b/sig/finch_api/internal/transport/base_client.rbs index 70cd492e..ac0445bf 100644 --- a/sig/finch_api/internal/transport/base_client.rbs +++ b/sig/finch_api/internal/transport/base_client.rbs @@ -20,6 +20,7 @@ module FinchAPI page: Class?, stream: Class?, model: FinchAPI::Internal::Type::Converter::input?, + security: { bearer_auth: bool, basic_auth: bool }?, options: FinchAPI::request_opts? } type request_input = @@ -123,6 +124,7 @@ module FinchAPI ?page: Class?, ?stream: Class?, ?model: FinchAPI::Internal::Type::Converter::input?, + ?security: { bearer_auth: bool, basic_auth: bool }?, ?options: FinchAPI::request_opts? ) -> top diff --git a/test/finch_api/client_test.rb b/test/finch_api/client_test.rb index 5208163f..63e0a612 100644 --- a/test/finch_api/client_test.rb +++ b/test/finch_api/client_test.rb @@ -30,7 +30,13 @@ def after_all def test_client_default_request_default_retry_attempts stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 500, body: {}) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list @@ -43,7 +49,13 @@ def test_client_given_request_default_retry_attempts stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 500, body: {}) finch = - FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token", max_retries: 3) + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret", + max_retries: 3 + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list @@ -55,7 +67,13 @@ def test_client_given_request_default_retry_attempts def test_client_default_request_given_retry_attempts stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 500, body: {}) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list(request_options: {max_retries: 3}) @@ -68,7 +86,13 @@ def test_client_given_request_given_retry_attempts stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 500, body: {}) finch = - FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token", max_retries: 3) + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret", + max_retries: 3 + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list(request_options: {max_retries: 4}) @@ -85,7 +109,13 @@ def test_client_retry_after_seconds ) finch = - FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token", max_retries: 1) + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret", + max_retries: 1 + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list @@ -103,7 +133,13 @@ def test_client_retry_after_date ) finch = - FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token", max_retries: 1) + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret", + max_retries: 1 + ) assert_raises(FinchAPI::Errors::InternalServerError) do Thread.current.thread_variable_set(:time_now, Time.now) @@ -123,7 +159,13 @@ def test_client_retry_after_ms ) finch = - FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token", max_retries: 1) + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret", + max_retries: 1 + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list @@ -136,7 +178,13 @@ def test_client_retry_after_ms def test_retry_count_header stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 500, body: {}) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list @@ -150,7 +198,13 @@ def test_retry_count_header def test_omit_retry_count_header stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 500, body: {}) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list(request_options: {extra_headers: {"x-stainless-retry-count" => nil}}) @@ -164,7 +218,13 @@ def test_omit_retry_count_header def test_overwrite_retry_count_header stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 500, body: {}) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::InternalServerError) do finch.hris.directory.list(request_options: {extra_headers: {"x-stainless-retry-count" => "42"}}) @@ -184,7 +244,13 @@ def test_client_redirect_307 headers: {"location" => "/redirected"} ) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::APIConnectionError) do finch.hris.directory.list(request_options: {extra_headers: {}}) @@ -213,7 +279,13 @@ def test_client_redirect_303 headers: {"location" => "/redirected"} ) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::APIConnectionError) do finch.hris.directory.list(request_options: {extra_headers: {}}) @@ -237,7 +309,13 @@ def test_client_redirect_auth_keep_same_origin headers: {"location" => "/redirected"} ) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::APIConnectionError) do finch.hris.directory.list(request_options: {extra_headers: {"authorization" => "Bearer xyz"}}) @@ -264,7 +342,13 @@ def test_client_redirect_auth_strip_cross_origin headers: {"location" => "https://example.com/redirected"} ) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) assert_raises(FinchAPI::Errors::APIConnectionError) do finch.hris.directory.list(request_options: {extra_headers: {"authorization" => "Bearer xyz"}}) @@ -279,7 +363,13 @@ def test_client_redirect_auth_strip_cross_origin def test_default_headers stub_request(:get, "http://localhost/employer/directory").to_return_json(status: 200, body: {}) - finch = FinchAPI::Client.new(base_url: "http://localhost", access_token: "My Access Token") + finch = + FinchAPI::Client.new( + base_url: "http://localhost", + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) finch.hris.directory.list diff --git a/test/finch_api/resources/access_tokens_test.rb b/test/finch_api/resources/access_tokens_test.rb index ecc07d83..e57c33f9 100644 --- a/test/finch_api/resources/access_tokens_test.rb +++ b/test/finch_api/resources/access_tokens_test.rb @@ -4,6 +4,8 @@ class FinchAPI::Test::Resources::AccessTokensTest < FinchAPI::Test::ResourceTest def test_create_required_params + skip("prism doesnt like the format for the API-Version header") + response = @finch.access_tokens.create(code: "code") assert_pattern do diff --git a/test/finch_api/resources/hris/directory_test.rb b/test/finch_api/resources/hris/directory_test.rb index 07b3310d..95bbda88 100644 --- a/test/finch_api/resources/hris/directory_test.rb +++ b/test/finch_api/resources/hris/directory_test.rb @@ -34,25 +34,13 @@ def test_list_individuals response = @finch.hris.directory.list_individuals assert_pattern do - response => FinchAPI::Internal::IndividualsPage - end - - row = response.to_enum.first - return if row.nil? - - assert_pattern do - row => FinchAPI::HRIS::IndividualInDirectory + response => FinchAPI::UnnamedTypeWithNoPropertyInfoOrParent0 end assert_pattern do - row => { - id: String, - department: FinchAPI::HRIS::IndividualInDirectory::Department | nil, - first_name: String | nil, - is_active: FinchAPI::Internal::Type::Boolean | nil, - last_name: String | nil, - manager: FinchAPI::HRIS::IndividualInDirectory::Manager | nil, - middle_name: String | nil + response => { + individuals: ^(FinchAPI::Internal::Type::ArrayOf[FinchAPI::HRIS::IndividualInDirectory]), + paging: FinchAPI::Paging } end end diff --git a/test/finch_api/test_helper.rb b/test/finch_api/test_helper.rb index 2f623e3b..825bb0cf 100644 --- a/test/finch_api/test_helper.rb +++ b/test/finch_api/test_helper.rb @@ -48,7 +48,12 @@ class FinchAPI::Test::SingletonClient < FinchAPI::Client TEST_API_BASE_URL = ENV.fetch("TEST_API_BASE_URL", "http://localhost:4010") def initialize - super(base_url: FinchAPI::Test::SingletonClient::TEST_API_BASE_URL, access_token: "My Access Token") + super( + base_url: FinchAPI::Test::SingletonClient::TEST_API_BASE_URL, + access_token: "My Access Token", + client_id: "4ab15e51-11ad-49f4-acae-f343b7794375", + client_secret: "My Client Secret" + ) end end