finch-api 0.1.0.pre.alpha.4 → 0.1.0.pre.alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -8
- data/lib/finch-api/client.rb +1 -1
- data/lib/finch-api/individuals_page.rb +4 -4
- data/lib/finch-api/models/access_token_create_params.rb +1 -1
- data/lib/finch-api/models/account_disconnect_params.rb +1 -1
- data/lib/finch-api/models/account_introspect_params.rb +1 -1
- data/lib/finch-api/models/connect/session_new_params.rb +1 -1
- data/lib/finch-api/models/connect/session_reauthenticate_params.rb +1 -1
- data/lib/finch-api/models/hris/benefit_create_params.rb +1 -1
- data/lib/finch-api/models/hris/benefit_list_params.rb +1 -1
- data/lib/finch-api/models/hris/benefit_list_supported_benefits_params.rb +1 -1
- data/lib/finch-api/models/hris/benefit_retrieve_params.rb +1 -1
- data/lib/finch-api/models/hris/benefit_update_params.rb +1 -1
- data/lib/finch-api/models/hris/benefits/individual_enroll_many_params.rb +1 -1
- data/lib/finch-api/models/hris/benefits/individual_enrolled_ids_params.rb +1 -1
- data/lib/finch-api/models/hris/benefits/individual_retrieve_many_benefits_params.rb +1 -1
- data/lib/finch-api/models/hris/benefits/individual_unenroll_many_params.rb +1 -1
- data/lib/finch-api/models/hris/company_retrieve_params.rb +1 -1
- data/lib/finch-api/models/hris/directory_list_individuals_params.rb +1 -1
- data/lib/finch-api/models/hris/directory_list_params.rb +1 -1
- data/lib/finch-api/models/hris/document_list_params.rb +1 -1
- data/lib/finch-api/models/hris/document_retreive_params.rb +1 -1
- data/lib/finch-api/models/hris/employment_retrieve_many_params.rb +1 -1
- data/lib/finch-api/models/hris/individual_retrieve_many_params.rb +1 -1
- data/lib/finch-api/models/hris/pay_statement_retrieve_many_params.rb +1 -1
- data/lib/finch-api/models/hris/payment_list_params.rb +1 -1
- data/lib/finch-api/models/jobs/automated_create_params.rb +1 -1
- data/lib/finch-api/models/jobs/automated_list_params.rb +1 -1
- data/lib/finch-api/models/jobs/automated_retrieve_params.rb +1 -1
- data/lib/finch-api/models/jobs/manual_retrieve_params.rb +1 -1
- data/lib/finch-api/models/payroll/pay_group_list_params.rb +1 -1
- data/lib/finch-api/models/payroll/pay_group_retrieve_params.rb +1 -1
- data/lib/finch-api/models/provider_list_params.rb +1 -1
- data/lib/finch-api/models/request_forwarding_forward_params.rb +1 -1
- data/lib/finch-api/models/sandbox/company_update_params.rb +1 -1
- data/lib/finch-api/models/sandbox/connection_create_params.rb +1 -1
- data/lib/finch-api/models/sandbox/connections/account_create_params.rb +1 -1
- data/lib/finch-api/models/sandbox/connections/account_update_params.rb +1 -1
- data/lib/finch-api/models/sandbox/directory_create_params.rb +1 -1
- data/lib/finch-api/models/sandbox/employment_update_params.rb +1 -1
- data/lib/finch-api/models/sandbox/individual_update_params.rb +1 -1
- data/lib/finch-api/models/sandbox/job_create_params.rb +1 -1
- data/lib/finch-api/models/sandbox/jobs/configuration_retrieve_params.rb +1 -1
- data/lib/finch-api/models/sandbox/jobs/configuration_update_params.rb +1 -1
- data/lib/finch-api/models/sandbox/payment_create_params.rb +1 -1
- data/lib/finch-api/page.rb +4 -4
- data/lib/finch-api/request_options.rb +0 -33
- data/lib/finch-api/responses_page.rb +3 -3
- data/lib/finch-api/single_page.rb +3 -3
- data/lib/finch-api/transport/base_client.rb +459 -0
- data/lib/finch-api/transport/pooled_net_requester.rb +182 -0
- data/lib/finch-api/type/array_of.rb +110 -0
- data/lib/finch-api/type/base_model.rb +355 -0
- data/lib/finch-api/type/base_page.rb +61 -0
- data/lib/finch-api/type/boolean_model.rb +52 -0
- data/lib/finch-api/type/converter.rb +211 -0
- data/lib/finch-api/type/enum.rb +105 -0
- data/lib/finch-api/type/hash_of.rb +136 -0
- data/lib/finch-api/type/request_parameters.rb +38 -0
- data/lib/finch-api/type/union.rb +204 -0
- data/lib/finch-api/type/unknown.rb +56 -0
- data/lib/finch-api/type.rb +23 -0
- data/lib/finch-api/version.rb +1 -1
- data/lib/finch-api.rb +13 -4
- data/rbi/lib/finch-api/client.rbi +1 -1
- data/rbi/lib/finch-api/individuals_page.rbi +1 -1
- data/rbi/lib/finch-api/models/access_token_create_params.rbi +1 -1
- data/rbi/lib/finch-api/models/account_disconnect_params.rbi +1 -1
- data/rbi/lib/finch-api/models/account_introspect_params.rbi +1 -1
- data/rbi/lib/finch-api/models/connect/session_new_params.rbi +1 -1
- data/rbi/lib/finch-api/models/connect/session_reauthenticate_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefit_create_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefit_list_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefit_list_supported_benefits_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefit_retrieve_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefit_update_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefits/individual_enroll_many_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefits/individual_enrolled_ids_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefits/individual_retrieve_many_benefits_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/benefits/individual_unenroll_many_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/company_retrieve_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/directory_list_individuals_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/directory_list_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/document_list_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/document_retreive_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/employment_retrieve_many_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/individual_retrieve_many_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/pay_statement_retrieve_many_params.rbi +1 -1
- data/rbi/lib/finch-api/models/hris/payment_list_params.rbi +1 -1
- data/rbi/lib/finch-api/models/jobs/automated_create_params.rbi +1 -1
- data/rbi/lib/finch-api/models/jobs/automated_list_params.rbi +1 -1
- data/rbi/lib/finch-api/models/jobs/automated_retrieve_params.rbi +1 -1
- data/rbi/lib/finch-api/models/jobs/manual_retrieve_params.rbi +1 -1
- data/rbi/lib/finch-api/models/payroll/pay_group_list_params.rbi +1 -1
- data/rbi/lib/finch-api/models/payroll/pay_group_retrieve_params.rbi +1 -1
- data/rbi/lib/finch-api/models/provider_list_params.rbi +1 -1
- data/rbi/lib/finch-api/models/request_forwarding_forward_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/company_update_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/connection_create_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/connections/account_create_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/connections/account_update_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/directory_create_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/directory_create_response.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/employment_update_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/individual_update_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/job_create_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/jobs/configuration_retrieve_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/jobs/configuration_retrieve_response.rbi +4 -1
- data/rbi/lib/finch-api/models/sandbox/jobs/configuration_update_params.rbi +1 -1
- data/rbi/lib/finch-api/models/sandbox/payment_create_params.rbi +1 -1
- data/rbi/lib/finch-api/page.rbi +1 -1
- data/rbi/lib/finch-api/request_options.rbi +0 -15
- data/rbi/lib/finch-api/responses_page.rbi +1 -1
- data/rbi/lib/finch-api/single_page.rbi +1 -1
- data/rbi/lib/finch-api/transport/base_client.rbi +204 -0
- data/rbi/lib/finch-api/transport/pooled_net_requester.rbi +64 -0
- data/rbi/lib/finch-api/type/array_of.rbi +82 -0
- data/rbi/lib/finch-api/type/base_model.rbi +191 -0
- data/rbi/lib/finch-api/type/base_page.rbi +38 -0
- data/rbi/lib/finch-api/type/boolean_model.rbi +41 -0
- data/rbi/lib/finch-api/type/converter.rbi +101 -0
- data/rbi/lib/finch-api/type/enum.rbi +58 -0
- data/rbi/lib/finch-api/type/hash_of.rbi +86 -0
- data/rbi/lib/finch-api/type/request_parameters.rbi +20 -0
- data/rbi/lib/finch-api/type/union.rbi +66 -0
- data/rbi/lib/finch-api/type/unknown.rbi +37 -0
- data/rbi/lib/finch-api/type.rbi +23 -0
- data/rbi/lib/finch-api/version.rbi +1 -1
- data/sig/finch-api/client.rbs +1 -1
- data/sig/finch-api/individuals_page.rbs +1 -1
- data/sig/finch-api/models/access_token_create_params.rbs +1 -1
- data/sig/finch-api/models/account_disconnect_params.rbs +1 -1
- data/sig/finch-api/models/account_introspect_params.rbs +1 -1
- data/sig/finch-api/models/connect/session_new_params.rbs +1 -1
- data/sig/finch-api/models/connect/session_reauthenticate_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefit_create_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefit_list_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefit_list_supported_benefits_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefit_retrieve_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefit_update_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefits/individual_enroll_many_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefits/individual_enrolled_ids_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefits/individual_retrieve_many_benefits_params.rbs +1 -1
- data/sig/finch-api/models/hris/benefits/individual_unenroll_many_params.rbs +1 -1
- data/sig/finch-api/models/hris/company_retrieve_params.rbs +1 -1
- data/sig/finch-api/models/hris/directory_list_individuals_params.rbs +1 -1
- data/sig/finch-api/models/hris/directory_list_params.rbs +1 -1
- data/sig/finch-api/models/hris/document_list_params.rbs +1 -1
- data/sig/finch-api/models/hris/document_retreive_params.rbs +1 -1
- data/sig/finch-api/models/hris/employment_retrieve_many_params.rbs +1 -1
- data/sig/finch-api/models/hris/individual_retrieve_many_params.rbs +1 -1
- data/sig/finch-api/models/hris/pay_statement_retrieve_many_params.rbs +1 -1
- data/sig/finch-api/models/hris/payment_list_params.rbs +1 -1
- data/sig/finch-api/models/jobs/automated_create_params.rbs +1 -1
- data/sig/finch-api/models/jobs/automated_list_params.rbs +1 -1
- data/sig/finch-api/models/jobs/automated_retrieve_params.rbs +1 -1
- data/sig/finch-api/models/jobs/manual_retrieve_params.rbs +1 -1
- data/sig/finch-api/models/payroll/pay_group_list_params.rbs +1 -1
- data/sig/finch-api/models/payroll/pay_group_retrieve_params.rbs +1 -1
- data/sig/finch-api/models/provider_list_params.rbs +1 -1
- data/sig/finch-api/models/request_forwarding_forward_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/company_update_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/connection_create_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/connections/account_create_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/connections/account_update_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/directory_create_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/employment_update_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/individual_update_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/job_create_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/jobs/configuration_retrieve_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/jobs/configuration_update_params.rbs +1 -1
- data/sig/finch-api/models/sandbox/payment_create_params.rbs +1 -1
- data/sig/finch-api/page.rbs +1 -1
- data/sig/finch-api/request_options.rbs +0 -10
- data/sig/finch-api/responses_page.rbs +1 -1
- data/sig/finch-api/single_page.rbs +1 -1
- data/sig/finch-api/transport/base_client.rbs +110 -0
- data/sig/finch-api/transport/pooled_net_requester.rbs +39 -0
- data/sig/finch-api/type/array_of.rbs +36 -0
- data/sig/finch-api/type/base_model.rbs +73 -0
- data/sig/finch-api/type/base_page.rbs +22 -0
- data/sig/finch-api/type/boolean_model.rbs +18 -0
- data/sig/finch-api/type/converter.rbs +36 -0
- data/sig/finch-api/type/enum.rbs +22 -0
- data/sig/finch-api/type/hash_of.rbs +36 -0
- data/sig/finch-api/type/request_parameters.rbs +13 -0
- data/sig/finch-api/type/union.rbs +37 -0
- data/sig/finch-api/type/unknown.rbs +18 -0
- data/sig/finch-api/type.rbs +22 -0
- data/sig/finch-api/version.rbs +1 -1
- metadata +40 -13
- data/lib/finch-api/base_client.rb +0 -457
- data/lib/finch-api/base_model.rb +0 -1174
- data/lib/finch-api/base_page.rb +0 -59
- data/lib/finch-api/pooled_net_requester.rb +0 -180
- data/rbi/lib/finch-api/base_client.rbi +0 -196
- data/rbi/lib/finch-api/base_model.rbi +0 -609
- data/rbi/lib/finch-api/base_page.rbi +0 -36
- data/rbi/lib/finch-api/pooled_net_requester.rbi +0 -59
- data/sig/finch-api/base_client.rbs +0 -106
- data/sig/finch-api/base_model.rbs +0 -248
- data/sig/finch-api/base_page.rbs +0 -20
- data/sig/finch-api/pooled_net_requester.rbs +0 -37
@@ -0,0 +1,37 @@
|
|
1
|
+
module FinchAPI
|
2
|
+
module Type
|
3
|
+
module Union
|
4
|
+
include FinchAPI::Type::Converter
|
5
|
+
|
6
|
+
private def self.known_variants: -> ::Array[[Symbol?, (^-> FinchAPI::Type::Converter::input)]]
|
7
|
+
|
8
|
+
def self.derefed_variants: -> ::Array[[Symbol?, top]]
|
9
|
+
|
10
|
+
def self.variants: -> ::Array[top]
|
11
|
+
|
12
|
+
private def self.discriminator: (Symbol property) -> void
|
13
|
+
|
14
|
+
private def self.variant: (
|
15
|
+
Symbol
|
16
|
+
| ::Hash[Symbol, top]
|
17
|
+
| ^-> FinchAPI::Type::Converter::input
|
18
|
+
| FinchAPI::Type::Converter::input key,
|
19
|
+
?::Hash[Symbol, top]
|
20
|
+
| ^-> FinchAPI::Type::Converter::input
|
21
|
+
| FinchAPI::Type::Converter::input spec
|
22
|
+
) -> void
|
23
|
+
|
24
|
+
private def self.resolve_variant: (
|
25
|
+
top value
|
26
|
+
) -> FinchAPI::Type::Converter::input?
|
27
|
+
|
28
|
+
def ===: (top other) -> bool
|
29
|
+
|
30
|
+
def ==: (top other) -> bool
|
31
|
+
|
32
|
+
def coerce: (top value, state: FinchAPI::Type::Converter::state) -> top
|
33
|
+
|
34
|
+
def dump: (top value) -> top
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module FinchAPI
|
2
|
+
module Type
|
3
|
+
class Unknown
|
4
|
+
extend FinchAPI::Type::Converter
|
5
|
+
|
6
|
+
def self.===: (top other) -> bool
|
7
|
+
|
8
|
+
def self.==: (top other) -> bool
|
9
|
+
|
10
|
+
def self.coerce: (
|
11
|
+
top value,
|
12
|
+
state: FinchAPI::Type::Converter::state
|
13
|
+
) -> top
|
14
|
+
|
15
|
+
def self.dump: (top value) -> top
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module FinchAPI
|
2
|
+
class Unknown = FinchAPI::Type::Unknown
|
3
|
+
|
4
|
+
class BooleanModel = FinchAPI::Type::BooleanModel
|
5
|
+
|
6
|
+
module Enum = FinchAPI::Type::Enum
|
7
|
+
|
8
|
+
module Union = FinchAPI::Type::Union
|
9
|
+
|
10
|
+
class ArrayOf = FinchAPI::Type::ArrayOf
|
11
|
+
|
12
|
+
class HashOf = FinchAPI::Type::HashOf
|
13
|
+
|
14
|
+
class BaseModel = FinchAPI::Type::BaseModel
|
15
|
+
|
16
|
+
type request_parameters = FinchAPI::Type::request_parameters
|
17
|
+
|
18
|
+
module RequestParameters = FinchAPI::Type::RequestParameters
|
19
|
+
|
20
|
+
module Type
|
21
|
+
end
|
22
|
+
end
|
data/sig/finch-api/version.rbs
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finch-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.alpha.
|
4
|
+
version: 0.1.0.pre.alpha.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finch
|
@@ -33,9 +33,6 @@ extra_rdoc_files:
|
|
33
33
|
files:
|
34
34
|
- README.md
|
35
35
|
- lib/finch-api.rb
|
36
|
-
- lib/finch-api/base_client.rb
|
37
|
-
- lib/finch-api/base_model.rb
|
38
|
-
- lib/finch-api/base_page.rb
|
39
36
|
- lib/finch-api/client.rb
|
40
37
|
- lib/finch-api/errors.rb
|
41
38
|
- lib/finch-api/individuals_page.rb
|
@@ -153,7 +150,6 @@ files:
|
|
153
150
|
- lib/finch-api/models/sandbox/payment_create_response.rb
|
154
151
|
- lib/finch-api/models/webhook_event.rb
|
155
152
|
- lib/finch-api/page.rb
|
156
|
-
- lib/finch-api/pooled_net_requester.rb
|
157
153
|
- lib/finch-api/request_options.rb
|
158
154
|
- lib/finch-api/resources/access_tokens.rb
|
159
155
|
- lib/finch-api/resources/account.rb
|
@@ -189,12 +185,22 @@ files:
|
|
189
185
|
- lib/finch-api/resources/webhooks.rb
|
190
186
|
- lib/finch-api/responses_page.rb
|
191
187
|
- lib/finch-api/single_page.rb
|
188
|
+
- lib/finch-api/transport/base_client.rb
|
189
|
+
- lib/finch-api/transport/pooled_net_requester.rb
|
190
|
+
- lib/finch-api/type.rb
|
191
|
+
- lib/finch-api/type/array_of.rb
|
192
|
+
- lib/finch-api/type/base_model.rb
|
193
|
+
- lib/finch-api/type/base_page.rb
|
194
|
+
- lib/finch-api/type/boolean_model.rb
|
195
|
+
- lib/finch-api/type/converter.rb
|
196
|
+
- lib/finch-api/type/enum.rb
|
197
|
+
- lib/finch-api/type/hash_of.rb
|
198
|
+
- lib/finch-api/type/request_parameters.rb
|
199
|
+
- lib/finch-api/type/union.rb
|
200
|
+
- lib/finch-api/type/unknown.rb
|
192
201
|
- lib/finch-api/util.rb
|
193
202
|
- lib/finch-api/version.rb
|
194
203
|
- manifest.yaml
|
195
|
-
- rbi/lib/finch-api/base_client.rbi
|
196
|
-
- rbi/lib/finch-api/base_model.rbi
|
197
|
-
- rbi/lib/finch-api/base_page.rbi
|
198
204
|
- rbi/lib/finch-api/client.rbi
|
199
205
|
- rbi/lib/finch-api/errors.rbi
|
200
206
|
- rbi/lib/finch-api/individuals_page.rbi
|
@@ -312,7 +318,6 @@ files:
|
|
312
318
|
- rbi/lib/finch-api/models/sandbox/payment_create_response.rbi
|
313
319
|
- rbi/lib/finch-api/models/webhook_event.rbi
|
314
320
|
- rbi/lib/finch-api/page.rbi
|
315
|
-
- rbi/lib/finch-api/pooled_net_requester.rbi
|
316
321
|
- rbi/lib/finch-api/request_options.rbi
|
317
322
|
- rbi/lib/finch-api/resources/access_tokens.rbi
|
318
323
|
- rbi/lib/finch-api/resources/account.rbi
|
@@ -348,11 +353,21 @@ files:
|
|
348
353
|
- rbi/lib/finch-api/resources/webhooks.rbi
|
349
354
|
- rbi/lib/finch-api/responses_page.rbi
|
350
355
|
- rbi/lib/finch-api/single_page.rbi
|
356
|
+
- rbi/lib/finch-api/transport/base_client.rbi
|
357
|
+
- rbi/lib/finch-api/transport/pooled_net_requester.rbi
|
358
|
+
- rbi/lib/finch-api/type.rbi
|
359
|
+
- rbi/lib/finch-api/type/array_of.rbi
|
360
|
+
- rbi/lib/finch-api/type/base_model.rbi
|
361
|
+
- rbi/lib/finch-api/type/base_page.rbi
|
362
|
+
- rbi/lib/finch-api/type/boolean_model.rbi
|
363
|
+
- rbi/lib/finch-api/type/converter.rbi
|
364
|
+
- rbi/lib/finch-api/type/enum.rbi
|
365
|
+
- rbi/lib/finch-api/type/hash_of.rbi
|
366
|
+
- rbi/lib/finch-api/type/request_parameters.rbi
|
367
|
+
- rbi/lib/finch-api/type/union.rbi
|
368
|
+
- rbi/lib/finch-api/type/unknown.rbi
|
351
369
|
- rbi/lib/finch-api/util.rbi
|
352
370
|
- rbi/lib/finch-api/version.rbi
|
353
|
-
- sig/finch-api/base_client.rbs
|
354
|
-
- sig/finch-api/base_model.rbs
|
355
|
-
- sig/finch-api/base_page.rbs
|
356
371
|
- sig/finch-api/client.rbs
|
357
372
|
- sig/finch-api/errors.rbs
|
358
373
|
- sig/finch-api/individuals_page.rbs
|
@@ -470,7 +485,6 @@ files:
|
|
470
485
|
- sig/finch-api/models/sandbox/payment_create_response.rbs
|
471
486
|
- sig/finch-api/models/webhook_event.rbs
|
472
487
|
- sig/finch-api/page.rbs
|
473
|
-
- sig/finch-api/pooled_net_requester.rbs
|
474
488
|
- sig/finch-api/request_options.rbs
|
475
489
|
- sig/finch-api/resources/access_tokens.rbs
|
476
490
|
- sig/finch-api/resources/account.rbs
|
@@ -506,6 +520,19 @@ files:
|
|
506
520
|
- sig/finch-api/resources/webhooks.rbs
|
507
521
|
- sig/finch-api/responses_page.rbs
|
508
522
|
- sig/finch-api/single_page.rbs
|
523
|
+
- sig/finch-api/transport/base_client.rbs
|
524
|
+
- sig/finch-api/transport/pooled_net_requester.rbs
|
525
|
+
- sig/finch-api/type.rbs
|
526
|
+
- sig/finch-api/type/array_of.rbs
|
527
|
+
- sig/finch-api/type/base_model.rbs
|
528
|
+
- sig/finch-api/type/base_page.rbs
|
529
|
+
- sig/finch-api/type/boolean_model.rbs
|
530
|
+
- sig/finch-api/type/converter.rbs
|
531
|
+
- sig/finch-api/type/enum.rbs
|
532
|
+
- sig/finch-api/type/hash_of.rbs
|
533
|
+
- sig/finch-api/type/request_parameters.rbs
|
534
|
+
- sig/finch-api/type/union.rbs
|
535
|
+
- sig/finch-api/type/unknown.rbs
|
509
536
|
- sig/finch-api/util.rbs
|
510
537
|
- sig/finch-api/version.rbs
|
511
538
|
homepage: https://gemdocs.org/gems/finch-api
|
@@ -1,457 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FinchAPI
|
4
|
-
# @api private
|
5
|
-
#
|
6
|
-
# @abstract
|
7
|
-
class BaseClient
|
8
|
-
# from whatwg fetch spec
|
9
|
-
MAX_REDIRECTS = 20
|
10
|
-
|
11
|
-
# rubocop:disable Style/MutableConstant
|
12
|
-
PLATFORM_HEADERS =
|
13
|
-
{
|
14
|
-
"x-stainless-arch" => FinchAPI::Util.arch,
|
15
|
-
"x-stainless-lang" => "ruby",
|
16
|
-
"x-stainless-os" => FinchAPI::Util.os,
|
17
|
-
"x-stainless-package-version" => FinchAPI::VERSION,
|
18
|
-
"x-stainless-runtime" => ::RUBY_ENGINE,
|
19
|
-
"x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
|
20
|
-
}
|
21
|
-
# rubocop:enable Style/MutableConstant
|
22
|
-
|
23
|
-
class << self
|
24
|
-
# @api private
|
25
|
-
#
|
26
|
-
# @param req [Hash{Symbol=>Object}]
|
27
|
-
#
|
28
|
-
# @raise [ArgumentError]
|
29
|
-
def validate!(req)
|
30
|
-
keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :stream, :model, :options]
|
31
|
-
case req
|
32
|
-
in Hash
|
33
|
-
req.each_key do |k|
|
34
|
-
unless keys.include?(k)
|
35
|
-
raise ArgumentError.new("Request `req` keys must be one of #{keys}, got #{k.inspect}")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
else
|
39
|
-
raise ArgumentError.new("Request `req` must be a Hash or RequestOptions, got #{req.inspect}")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# @api private
|
44
|
-
#
|
45
|
-
# @param status [Integer]
|
46
|
-
# @param headers [Hash{String=>String}, Net::HTTPHeader]
|
47
|
-
#
|
48
|
-
# @return [Boolean]
|
49
|
-
def should_retry?(status, headers:)
|
50
|
-
coerced = FinchAPI::Util.coerce_boolean(headers["x-should-retry"])
|
51
|
-
case [coerced, status]
|
52
|
-
in [true | false, _]
|
53
|
-
coerced
|
54
|
-
in [_, 408 | 409 | 429 | (500..)]
|
55
|
-
# retry on:
|
56
|
-
# 408: timeouts
|
57
|
-
# 409: locks
|
58
|
-
# 429: rate limits
|
59
|
-
# 500+: unknown errors
|
60
|
-
true
|
61
|
-
else
|
62
|
-
false
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# @api private
|
67
|
-
#
|
68
|
-
# @param request [Hash{Symbol=>Object}] .
|
69
|
-
#
|
70
|
-
# @option request [Symbol] :method
|
71
|
-
#
|
72
|
-
# @option request [URI::Generic] :url
|
73
|
-
#
|
74
|
-
# @option request [Hash{String=>String}] :headers
|
75
|
-
#
|
76
|
-
# @option request [Object] :body
|
77
|
-
#
|
78
|
-
# @option request [Integer] :max_retries
|
79
|
-
#
|
80
|
-
# @option request [Float] :timeout
|
81
|
-
#
|
82
|
-
# @param status [Integer]
|
83
|
-
#
|
84
|
-
# @param response_headers [Hash{String=>String}, Net::HTTPHeader]
|
85
|
-
#
|
86
|
-
# @return [Hash{Symbol=>Object}]
|
87
|
-
def follow_redirect(request, status:, response_headers:)
|
88
|
-
method, url, headers = request.fetch_values(:method, :url, :headers)
|
89
|
-
location =
|
90
|
-
Kernel.then do
|
91
|
-
URI.join(url, response_headers["location"])
|
92
|
-
rescue ArgumentError
|
93
|
-
message = "Server responded with status #{status} but no valid location header."
|
94
|
-
raise FinchAPI::APIConnectionError.new(url: url, message: message)
|
95
|
-
end
|
96
|
-
|
97
|
-
request = {**request, url: location}
|
98
|
-
|
99
|
-
case [url.scheme, location.scheme]
|
100
|
-
in ["https", "http"]
|
101
|
-
message = "Tried to redirect to a insecure URL"
|
102
|
-
raise FinchAPI::APIConnectionError.new(url: url, message: message)
|
103
|
-
else
|
104
|
-
nil
|
105
|
-
end
|
106
|
-
|
107
|
-
# from whatwg fetch spec
|
108
|
-
case [status, method]
|
109
|
-
in [301 | 302, :post] | [303, _]
|
110
|
-
drop = %w[content-encoding content-language content-length content-location content-type]
|
111
|
-
request = {
|
112
|
-
**request,
|
113
|
-
method: method == :head ? :head : :get,
|
114
|
-
headers: headers.except(*drop),
|
115
|
-
body: nil
|
116
|
-
}
|
117
|
-
else
|
118
|
-
end
|
119
|
-
|
120
|
-
# from undici
|
121
|
-
if FinchAPI::Util.uri_origin(url) != FinchAPI::Util.uri_origin(location)
|
122
|
-
drop = %w[authorization cookie host proxy-authorization]
|
123
|
-
request = {**request, headers: request.fetch(:headers).except(*drop)}
|
124
|
-
end
|
125
|
-
|
126
|
-
request
|
127
|
-
end
|
128
|
-
|
129
|
-
# @api private
|
130
|
-
#
|
131
|
-
# @param status [Integer, FinchAPI::APIConnectionError]
|
132
|
-
# @param stream [Enumerable, nil]
|
133
|
-
def reap_connection!(status, stream:)
|
134
|
-
case status
|
135
|
-
in (..199) | (300..499)
|
136
|
-
stream&.each { next }
|
137
|
-
in FinchAPI::APIConnectionError | (500..)
|
138
|
-
FinchAPI::Util.close_fused!(stream)
|
139
|
-
else
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
# @api private
|
145
|
-
# @return [FinchAPI::PooledNetRequester]
|
146
|
-
attr_accessor :requester
|
147
|
-
|
148
|
-
# @api private
|
149
|
-
#
|
150
|
-
# @param base_url [String]
|
151
|
-
# @param timeout [Float]
|
152
|
-
# @param max_retries [Integer]
|
153
|
-
# @param initial_retry_delay [Float]
|
154
|
-
# @param max_retry_delay [Float]
|
155
|
-
# @param headers [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}]
|
156
|
-
# @param idempotency_header [String, nil]
|
157
|
-
def initialize(
|
158
|
-
base_url:,
|
159
|
-
timeout: 0.0,
|
160
|
-
max_retries: 0,
|
161
|
-
initial_retry_delay: 0.0,
|
162
|
-
max_retry_delay: 0.0,
|
163
|
-
headers: {},
|
164
|
-
idempotency_header: nil
|
165
|
-
)
|
166
|
-
@requester = FinchAPI::PooledNetRequester.new
|
167
|
-
@headers = FinchAPI::Util.normalized_headers(
|
168
|
-
self.class::PLATFORM_HEADERS,
|
169
|
-
{
|
170
|
-
"accept" => "application/json",
|
171
|
-
"content-type" => "application/json"
|
172
|
-
},
|
173
|
-
headers
|
174
|
-
)
|
175
|
-
@base_url = FinchAPI::Util.parse_uri(base_url)
|
176
|
-
@idempotency_header = idempotency_header&.to_s&.downcase
|
177
|
-
@max_retries = max_retries
|
178
|
-
@timeout = timeout
|
179
|
-
@initial_retry_delay = initial_retry_delay
|
180
|
-
@max_retry_delay = max_retry_delay
|
181
|
-
end
|
182
|
-
|
183
|
-
# @api private
|
184
|
-
#
|
185
|
-
# @return [Hash{String=>String}]
|
186
|
-
private def auth_headers = {}
|
187
|
-
|
188
|
-
# @api private
|
189
|
-
#
|
190
|
-
# @return [String]
|
191
|
-
private def generate_idempotency_key = "stainless-ruby-retry-#{SecureRandom.uuid}"
|
192
|
-
|
193
|
-
# @api private
|
194
|
-
#
|
195
|
-
# @param req [Hash{Symbol=>Object}] .
|
196
|
-
#
|
197
|
-
# @option req [Symbol] :method
|
198
|
-
#
|
199
|
-
# @option req [String, Array<String>] :path
|
200
|
-
#
|
201
|
-
# @option req [Hash{String=>Array<String>, String, nil}, nil] :query
|
202
|
-
#
|
203
|
-
# @option req [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}, nil] :headers
|
204
|
-
#
|
205
|
-
# @option req [Object, nil] :body
|
206
|
-
#
|
207
|
-
# @option req [Symbol, nil] :unwrap
|
208
|
-
#
|
209
|
-
# @option req [Class, nil] :page
|
210
|
-
#
|
211
|
-
# @option req [Class, nil] :stream
|
212
|
-
#
|
213
|
-
# @option req [FinchAPI::Converter, Class, nil] :model
|
214
|
-
#
|
215
|
-
# @param opts [Hash{Symbol=>Object}] .
|
216
|
-
#
|
217
|
-
# @option opts [String, nil] :idempotency_key
|
218
|
-
#
|
219
|
-
# @option opts [Hash{String=>Array<String>, String, nil}, nil] :extra_query
|
220
|
-
#
|
221
|
-
# @option opts [Hash{String=>String, nil}, nil] :extra_headers
|
222
|
-
#
|
223
|
-
# @option opts [Object, nil] :extra_body
|
224
|
-
#
|
225
|
-
# @option opts [Integer, nil] :max_retries
|
226
|
-
#
|
227
|
-
# @option opts [Float, nil] :timeout
|
228
|
-
#
|
229
|
-
# @return [Hash{Symbol=>Object}]
|
230
|
-
private def build_request(req, opts)
|
231
|
-
method, uninterpolated_path = req.fetch_values(:method, :path)
|
232
|
-
|
233
|
-
path = FinchAPI::Util.interpolate_path(uninterpolated_path)
|
234
|
-
|
235
|
-
query = FinchAPI::Util.deep_merge(req[:query].to_h, opts[:extra_query].to_h)
|
236
|
-
|
237
|
-
headers = FinchAPI::Util.normalized_headers(
|
238
|
-
@headers,
|
239
|
-
auth_headers,
|
240
|
-
req[:headers].to_h,
|
241
|
-
opts[:extra_headers].to_h
|
242
|
-
)
|
243
|
-
|
244
|
-
if @idempotency_header &&
|
245
|
-
!headers.key?(@idempotency_header) &&
|
246
|
-
!Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase)
|
247
|
-
headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key }
|
248
|
-
end
|
249
|
-
|
250
|
-
unless headers.key?("x-stainless-retry-count")
|
251
|
-
headers["x-stainless-retry-count"] = "0"
|
252
|
-
end
|
253
|
-
|
254
|
-
timeout = opts.fetch(:timeout, @timeout).to_f.clamp((0..))
|
255
|
-
unless headers.key?("x-stainless-timeout") || timeout.zero?
|
256
|
-
headers["x-stainless-timeout"] = timeout.to_s
|
257
|
-
end
|
258
|
-
|
259
|
-
headers.reject! { |_, v| v.to_s.empty? }
|
260
|
-
|
261
|
-
body =
|
262
|
-
case method
|
263
|
-
in :get | :head | :options | :trace
|
264
|
-
nil
|
265
|
-
else
|
266
|
-
FinchAPI::Util.deep_merge(*[req[:body], opts[:extra_body]].compact)
|
267
|
-
end
|
268
|
-
|
269
|
-
headers, encoded = FinchAPI::Util.encode_content(headers, body)
|
270
|
-
{
|
271
|
-
method: method,
|
272
|
-
url: FinchAPI::Util.join_parsed_uri(@base_url, {**req, path: path, query: query}),
|
273
|
-
headers: headers,
|
274
|
-
body: encoded,
|
275
|
-
max_retries: opts.fetch(:max_retries, @max_retries),
|
276
|
-
timeout: timeout
|
277
|
-
}
|
278
|
-
end
|
279
|
-
|
280
|
-
# @api private
|
281
|
-
#
|
282
|
-
# @param headers [Hash{String=>String}]
|
283
|
-
# @param retry_count [Integer]
|
284
|
-
#
|
285
|
-
# @return [Float]
|
286
|
-
private def retry_delay(headers, retry_count:)
|
287
|
-
# Non-standard extension
|
288
|
-
span = Float(headers["retry-after-ms"], exception: false)&.then { _1 / 1000 }
|
289
|
-
return span if span
|
290
|
-
|
291
|
-
retry_header = headers["retry-after"]
|
292
|
-
return span if (span = Float(retry_header, exception: false))
|
293
|
-
|
294
|
-
span = retry_header&.then do
|
295
|
-
Time.httpdate(_1) - Time.now
|
296
|
-
rescue ArgumentError
|
297
|
-
nil
|
298
|
-
end
|
299
|
-
return span if span
|
300
|
-
|
301
|
-
scale = retry_count**2
|
302
|
-
jitter = 1 - (0.25 * rand)
|
303
|
-
(@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay)
|
304
|
-
end
|
305
|
-
|
306
|
-
# @api private
|
307
|
-
#
|
308
|
-
# @param request [Hash{Symbol=>Object}] .
|
309
|
-
#
|
310
|
-
# @option request [Symbol] :method
|
311
|
-
#
|
312
|
-
# @option request [URI::Generic] :url
|
313
|
-
#
|
314
|
-
# @option request [Hash{String=>String}] :headers
|
315
|
-
#
|
316
|
-
# @option request [Object] :body
|
317
|
-
#
|
318
|
-
# @option request [Integer] :max_retries
|
319
|
-
#
|
320
|
-
# @option request [Float] :timeout
|
321
|
-
#
|
322
|
-
# @param redirect_count [Integer]
|
323
|
-
#
|
324
|
-
# @param retry_count [Integer]
|
325
|
-
#
|
326
|
-
# @param send_retry_header [Boolean]
|
327
|
-
#
|
328
|
-
# @raise [FinchAPI::APIError]
|
329
|
-
# @return [Array(Integer, Net::HTTPResponse, Enumerable)]
|
330
|
-
private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
|
331
|
-
url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
|
332
|
-
input = {**request.except(:timeout), deadline: FinchAPI::Util.monotonic_secs + timeout}
|
333
|
-
|
334
|
-
if send_retry_header
|
335
|
-
headers["x-stainless-retry-count"] = retry_count.to_s
|
336
|
-
end
|
337
|
-
|
338
|
-
begin
|
339
|
-
status, response, stream = @requester.execute(input)
|
340
|
-
rescue FinchAPI::APIConnectionError => e
|
341
|
-
status = e
|
342
|
-
end
|
343
|
-
|
344
|
-
case status
|
345
|
-
in ..299
|
346
|
-
[status, response, stream]
|
347
|
-
in 300..399 if redirect_count >= self.class::MAX_REDIRECTS
|
348
|
-
self.class.reap_connection!(status, stream: stream)
|
349
|
-
|
350
|
-
message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects."
|
351
|
-
raise FinchAPI::APIConnectionError.new(url: url, message: message)
|
352
|
-
in 300..399
|
353
|
-
self.class.reap_connection!(status, stream: stream)
|
354
|
-
|
355
|
-
request = self.class.follow_redirect(request, status: status, response_headers: response)
|
356
|
-
send_request(
|
357
|
-
request,
|
358
|
-
redirect_count: redirect_count + 1,
|
359
|
-
retry_count: retry_count,
|
360
|
-
send_retry_header: send_retry_header
|
361
|
-
)
|
362
|
-
in FinchAPI::APIConnectionError if retry_count >= max_retries
|
363
|
-
raise status
|
364
|
-
in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: response)
|
365
|
-
decoded = Kernel.then do
|
366
|
-
FinchAPI::Util.decode_content(response, stream: stream, suppress_error: true)
|
367
|
-
ensure
|
368
|
-
self.class.reap_connection!(status, stream: stream)
|
369
|
-
end
|
370
|
-
|
371
|
-
raise FinchAPI::APIStatusError.for(
|
372
|
-
url: url,
|
373
|
-
status: status,
|
374
|
-
body: decoded,
|
375
|
-
request: nil,
|
376
|
-
response: response
|
377
|
-
)
|
378
|
-
in (400..) | FinchAPI::APIConnectionError
|
379
|
-
self.class.reap_connection!(status, stream: stream)
|
380
|
-
|
381
|
-
delay = retry_delay(response, retry_count: retry_count)
|
382
|
-
sleep(delay)
|
383
|
-
|
384
|
-
send_request(
|
385
|
-
request,
|
386
|
-
redirect_count: redirect_count,
|
387
|
-
retry_count: retry_count + 1,
|
388
|
-
send_retry_header: send_retry_header
|
389
|
-
)
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
# Execute the request specified by `req`. This is the method that all resource
|
394
|
-
# methods call into.
|
395
|
-
#
|
396
|
-
# @param req [Hash{Symbol=>Object}] .
|
397
|
-
#
|
398
|
-
# @option req [Symbol] :method
|
399
|
-
#
|
400
|
-
# @option req [String, Array<String>] :path
|
401
|
-
#
|
402
|
-
# @option req [Hash{String=>Array<String>, String, nil}, nil] :query
|
403
|
-
#
|
404
|
-
# @option req [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}, nil] :headers
|
405
|
-
#
|
406
|
-
# @option req [Object, nil] :body
|
407
|
-
#
|
408
|
-
# @option req [Symbol, nil] :unwrap
|
409
|
-
#
|
410
|
-
# @option req [Class, nil] :page
|
411
|
-
#
|
412
|
-
# @option req [Class, nil] :stream
|
413
|
-
#
|
414
|
-
# @option req [FinchAPI::Converter, Class, nil] :model
|
415
|
-
#
|
416
|
-
# @option req [FinchAPI::RequestOptions, Hash{Symbol=>Object}, nil] :options
|
417
|
-
#
|
418
|
-
# @raise [FinchAPI::APIError]
|
419
|
-
# @return [Object]
|
420
|
-
def request(req)
|
421
|
-
self.class.validate!(req)
|
422
|
-
model = req.fetch(:model) { FinchAPI::Unknown }
|
423
|
-
opts = req[:options].to_h
|
424
|
-
FinchAPI::RequestOptions.validate!(opts)
|
425
|
-
request = build_request(req.except(:options), opts)
|
426
|
-
url = request.fetch(:url)
|
427
|
-
|
428
|
-
# Don't send the current retry count in the headers if the caller modified the header defaults.
|
429
|
-
send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0"
|
430
|
-
status, response, stream = send_request(
|
431
|
-
request,
|
432
|
-
redirect_count: 0,
|
433
|
-
retry_count: 0,
|
434
|
-
send_retry_header: send_retry_header
|
435
|
-
)
|
436
|
-
|
437
|
-
decoded = FinchAPI::Util.decode_content(response, stream: stream)
|
438
|
-
case req
|
439
|
-
in { stream: Class => st }
|
440
|
-
st.new(model: model, url: url, status: status, response: response, stream: decoded)
|
441
|
-
in { page: Class => page }
|
442
|
-
page.new(client: self, req: req, headers: response, page_data: decoded)
|
443
|
-
else
|
444
|
-
unwrapped = FinchAPI::Util.dig(decoded, req[:unwrap])
|
445
|
-
FinchAPI::Converter.coerce(model, unwrapped)
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
# @return [String]
|
450
|
-
def inspect
|
451
|
-
# rubocop:disable Layout/LineLength
|
452
|
-
base_url = FinchAPI::Util.unparse_uri(@base_url)
|
453
|
-
"#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{base_url} max_retries=#{@max_retries} timeout=#{@timeout}>"
|
454
|
-
# rubocop:enable Layout/LineLength
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|