dinie-sdk 1.0.0

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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +12 -0
  3. data/LICENSE +21 -0
  4. data/README.md +280 -0
  5. data/lib/dinie/generated/api_version.rb +8 -0
  6. data/lib/dinie/generated/client.rb +96 -0
  7. data/lib/dinie/generated/errors/registry.rb +40 -0
  8. data/lib/dinie/generated/events/base.rb +11 -0
  9. data/lib/dinie/generated/events/credit_offer.rb +56 -0
  10. data/lib/dinie/generated/events/customer_created.rb +42 -0
  11. data/lib/dinie/generated/events/customer_denied.rb +39 -0
  12. data/lib/dinie/generated/events/customer_kyc_updated.rb +36 -0
  13. data/lib/dinie/generated/events/customer_status.rb +48 -0
  14. data/lib/dinie/generated/events/deserializers.rb +35 -0
  15. data/lib/dinie/generated/events/loan_active.rb +35 -0
  16. data/lib/dinie/generated/events/loan_created.rb +38 -0
  17. data/lib/dinie/generated/events/loan_payment_received.rb +46 -0
  18. data/lib/dinie/generated/events/loan_processing.rb +37 -0
  19. data/lib/dinie/generated/events/loan_signature_received.rb +48 -0
  20. data/lib/dinie/generated/events/loan_status.rb +73 -0
  21. data/lib/dinie/generated/events.rb +4 -0
  22. data/lib/dinie/generated/resources/banks.rb +25 -0
  23. data/lib/dinie/generated/resources/biometrics.rb +27 -0
  24. data/lib/dinie/generated/resources/credentials.rb +56 -0
  25. data/lib/dinie/generated/resources/credit_offers.rb +59 -0
  26. data/lib/dinie/generated/resources/customers.rb +200 -0
  27. data/lib/dinie/generated/resources/loans.rb +70 -0
  28. data/lib/dinie/generated/resources/webhook_endpoints.rb +97 -0
  29. data/lib/dinie/generated/resources.rb +9 -0
  30. data/lib/dinie/generated/types/bank.rb +17 -0
  31. data/lib/dinie/generated/types/biometrics_session.rb +16 -0
  32. data/lib/dinie/generated/types/biometrics_session_exchange_response.rb +23 -0
  33. data/lib/dinie/generated/types/credential.rb +50 -0
  34. data/lib/dinie/generated/types/credit_offer.rb +62 -0
  35. data/lib/dinie/generated/types/customer.rb +45 -0
  36. data/lib/dinie/generated/types/customer_bank_account.rb +33 -0
  37. data/lib/dinie/generated/types/ids.rb +18 -0
  38. data/lib/dinie/generated/types/kyc.rb +458 -0
  39. data/lib/dinie/generated/types/kyc_attachment_response.rb +16 -0
  40. data/lib/dinie/generated/types/loan.rb +51 -0
  41. data/lib/dinie/generated/types/money.rb +4 -0
  42. data/lib/dinie/generated/types/simulation.rb +35 -0
  43. data/lib/dinie/generated/types/transaction.rb +43 -0
  44. data/lib/dinie/generated/types/webhook_endpoint.rb +52 -0
  45. data/lib/dinie/generated/types/webhook_secret_rotation.rb +17 -0
  46. data/lib/dinie/generated/types.rb +18 -0
  47. data/lib/dinie/runtime/errors.rb +295 -0
  48. data/lib/dinie/runtime/http.rb +325 -0
  49. data/lib/dinie/runtime/idempotency.rb +34 -0
  50. data/lib/dinie/runtime/logger.rb +326 -0
  51. data/lib/dinie/runtime/model.rb +162 -0
  52. data/lib/dinie/runtime/multipart.rb +77 -0
  53. data/lib/dinie/runtime/paginator.rb +164 -0
  54. data/lib/dinie/runtime/rate_limit.rb +150 -0
  55. data/lib/dinie/runtime/request_options.rb +112 -0
  56. data/lib/dinie/runtime/retry.rb +74 -0
  57. data/lib/dinie/runtime/token_manager.rb +341 -0
  58. data/lib/dinie/runtime/webhooks.rb +194 -0
  59. data/lib/dinie/version.rb +7 -0
  60. data/lib/dinie.rb +36 -0
  61. data/sig/_external/faraday.rbs +44 -0
  62. data/sig/dinie/generated/client.rbs +45 -0
  63. data/sig/dinie/generated/errors/registry.rbs +40 -0
  64. data/sig/dinie/generated/events/base.rbs +17 -0
  65. data/sig/dinie/generated/events/credit_offer.rbs +33 -0
  66. data/sig/dinie/generated/events/customer_created.rbs +27 -0
  67. data/sig/dinie/generated/events/customer_denied.rbs +25 -0
  68. data/sig/dinie/generated/events/customer_kyc_updated.rbs +21 -0
  69. data/sig/dinie/generated/events/customer_status.rbs +26 -0
  70. data/sig/dinie/generated/events/deserializers.rbs +9 -0
  71. data/sig/dinie/generated/events/loan_active.rbs +20 -0
  72. data/sig/dinie/generated/events/loan_created.rbs +23 -0
  73. data/sig/dinie/generated/events/loan_payment_received.rbs +28 -0
  74. data/sig/dinie/generated/events/loan_processing.rbs +23 -0
  75. data/sig/dinie/generated/events/loan_signature_received.rbs +30 -0
  76. data/sig/dinie/generated/events/loan_status.rbs +40 -0
  77. data/sig/dinie/generated/resources/banks.rbs +15 -0
  78. data/sig/dinie/generated/resources/credentials.rbs +21 -0
  79. data/sig/dinie/generated/resources/credit_offers.rbs +19 -0
  80. data/sig/dinie/generated/resources/customers.rbs +58 -0
  81. data/sig/dinie/generated/resources/loans.rbs +26 -0
  82. data/sig/dinie/generated/resources/webhook_endpoints.rbs +35 -0
  83. data/sig/dinie/generated/types/bank.rbs +12 -0
  84. data/sig/dinie/generated/types/biometrics_session.rbs +11 -0
  85. data/sig/dinie/generated/types/credential.rbs +26 -0
  86. data/sig/dinie/generated/types/credit_offer.rbs +24 -0
  87. data/sig/dinie/generated/types/customer.rbs +25 -0
  88. data/sig/dinie/generated/types/customer_bank_account.rbs +26 -0
  89. data/sig/dinie/generated/types/enums.rbs +66 -0
  90. data/sig/dinie/generated/types/ids.rbs +21 -0
  91. data/sig/dinie/generated/types/kyc/attachment.rbs +14 -0
  92. data/sig/dinie/generated/types/kyc/common.rbs +42 -0
  93. data/sig/dinie/generated/types/kyc/requirements.rbs +117 -0
  94. data/sig/dinie/generated/types/kyc/submitted.rbs +21 -0
  95. data/sig/dinie/generated/types/kyc/uploads.rbs +24 -0
  96. data/sig/dinie/generated/types/loan.rbs +32 -0
  97. data/sig/dinie/generated/types/money.rbs +6 -0
  98. data/sig/dinie/generated/types/simulation.rbs +28 -0
  99. data/sig/dinie/generated/types/transaction.rbs +24 -0
  100. data/sig/dinie/generated/types/webhook_endpoint.rbs +38 -0
  101. data/sig/dinie/runtime/errors.rbs +106 -0
  102. data/sig/dinie/runtime/http.rbs +59 -0
  103. data/sig/dinie/runtime/idempotency.rbs +15 -0
  104. data/sig/dinie/runtime/logger.rbs +89 -0
  105. data/sig/dinie/runtime/model.rbs +51 -0
  106. data/sig/dinie/runtime/multipart.rbs +25 -0
  107. data/sig/dinie/runtime/paginator.rbs +50 -0
  108. data/sig/dinie/runtime/rate_limit.rbs +46 -0
  109. data/sig/dinie/runtime/request_options.rbs +35 -0
  110. data/sig/dinie/runtime/retry.rbs +29 -0
  111. data/sig/dinie/runtime/token_manager.rbs +51 -0
  112. data/sig/dinie/runtime/webhooks.rbs +31 -0
  113. data/sig/dinie/version.rbs +7 -0
  114. metadata +316 -0
@@ -0,0 +1,26 @@
1
+ # `CustomerBankAccount` + the `CustomerBankAccountKind` enum module (architecture §3.3, §6).
2
+ # Mirrors `lib/dinie/generated/types/customer_bank_account.rb`.
3
+
4
+ module Dinie
5
+ module CustomerBankAccountKind
6
+ CHECKING: String
7
+ SAVING: String
8
+ PAYMENT: String
9
+ ALL: Array[String]
10
+ end
11
+
12
+ class CustomerBankAccount < Internal::Model
13
+ attr_reader bank_id: String
14
+ attr_reader bank_name: String
15
+ attr_reader branch: String
16
+ attr_reader digit: String
17
+ attr_reader id: bank_account_id
18
+ attr_reader kind: customer_bank_account_kind
19
+ attr_reader number: String
20
+ attr_reader updated_at: Integer
21
+
22
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> CustomerBankAccount
23
+
24
+ def self.serialize_upsert: (bank_id: String, branch: String, digit: String, kind: String, number: String) -> Hash[Symbol, untyped]
25
+ end
26
+ end
@@ -0,0 +1,66 @@
1
+ # Enum literal-union aliases + the named-constant modules (architecture §3.3). The wire value
2
+ # surfaces as a plain `String`; RBS carries the literal union (the type TS encodes natively), and
3
+ # the frozen constant modules name the values for discoverability. Aliases are doc-only (any
4
+ # `String` is assignable); the unions document the closed set.
5
+
6
+ module Dinie
7
+ type customer_status = "creating" | "pending_kyc" | "under_review" | "active" | "denied"
8
+ type credential_status = "active" | "revoked"
9
+ type credit_offer_status = "available" | "accepted" | "expired"
10
+ type loan_status = "awaiting_signatures" | "processing" | "active" | "finished" | "cancelled" | "error"
11
+ type transaction_status = "pending" | "paid" | "overdue" | "partially_paid"
12
+ type transaction_type = "installment"
13
+ type webhook_endpoint_status = "active" | "disabled"
14
+ type customer_bank_account_kind = "checking" | "saving" | "payment"
15
+
16
+ module CustomerStatus
17
+ CREATING: String
18
+ PENDING_KYC: String
19
+ UNDER_REVIEW: String
20
+ ACTIVE: String
21
+ DENIED: String
22
+ ALL: Array[String]
23
+ end
24
+
25
+ module CredentialStatus
26
+ ACTIVE: String
27
+ REVOKED: String
28
+ ALL: Array[String]
29
+ end
30
+
31
+ module CreditOfferStatus
32
+ AVAILABLE: String
33
+ ACCEPTED: String
34
+ EXPIRED: String
35
+ ALL: Array[String]
36
+ end
37
+
38
+ module LoanStatus
39
+ AWAITING_SIGNATURES: String
40
+ PROCESSING: String
41
+ ACTIVE: String
42
+ FINISHED: String
43
+ CANCELLED: String
44
+ ERROR: String
45
+ ALL: Array[String]
46
+ end
47
+
48
+ module TransactionStatus
49
+ PENDING: String
50
+ PAID: String
51
+ OVERDUE: String
52
+ PARTIALLY_PAID: String
53
+ ALL: Array[String]
54
+ end
55
+
56
+ module TransactionType
57
+ INSTALLMENT: String
58
+ ALL: Array[String]
59
+ end
60
+
61
+ module WebhookEndpointStatus
62
+ ACTIVE: String
63
+ DISABLED: String
64
+ ALL: Array[String]
65
+ end
66
+ end
@@ -0,0 +1,21 @@
1
+ # Resource ID aliases (architecture §3.3). Ruby has no zero-cost nominal typing, so each prefixed
2
+ # id is a plain `String`; the prefix/pattern lives in the contract + the conformance harness, and
3
+ # here as a doc-only RBS alias (the `comparison.md` "nominal typing available" axis). `ID_PATTERNS`
4
+ # is `Internal::` (not the frozen surface).
5
+
6
+ module Dinie
7
+ # Doc-only id aliases (each resolves to `String`). The prefix is documented; not enforced by type.
8
+ type api_client_id = String # `dinie_ci_…`
9
+ type bank_account_id = String # `ba_…`
10
+ type credit_offer_id = String # `co_…`
11
+ type customer_id = String # `cust_…` (NOT `cus_`)
12
+ type event_id = String # `evt_…`
13
+ type loan_id = String # `ln_…`
14
+ type simulation_id = String # `sim_…`
15
+ type transaction_id = String # `tx_…`
16
+ type webhook_endpoint_id = String # `we_…`
17
+
18
+ module Internal
19
+ ID_PATTERNS: Hash[Symbol, Regexp]
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # `Kyc::AttachmentResponse` — the `POST /customers/{id}/kyc-attachments` response body
2
+ # (architecture §6.3). Mirrors `lib/dinie/generated/types/kyc/attachment.rb`. Read-only.
3
+
4
+ module Dinie
5
+ module Kyc
6
+ class AttachmentResponse < Internal::Model
7
+ attr_reader id: String
8
+ attr_reader requirement: Requirement
9
+ attr_reader uploaded_at: Integer
10
+
11
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> AttachmentResponse
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,42 @@
1
+ # KYC shared leaf types + the dispatch error (architecture §6.3). Mirrors
2
+ # `lib/dinie/generated/types/kyc/common.rb`. `Dinie::Kyc` is the complexity hotspot (~41 types).
3
+
4
+ module Dinie
5
+ module Kyc
6
+ type kyc_review_status = "pending" | "accepted" | "rejected"
7
+ type kyc_subject_type = "applicant" | "co_owner"
8
+
9
+ module ReviewStatus
10
+ PENDING: String
11
+ ACCEPTED: String
12
+ REJECTED: String
13
+ ALL: Array[String]
14
+ end
15
+
16
+ module SubjectType
17
+ APPLICANT: String
18
+ CO_OWNER: String
19
+ ALL: Array[String]
20
+ end
21
+
22
+ # Identifies who a person-specific requirement is about (applicant or company co-owner).
23
+ class Subject < Internal::Model
24
+ attr_reader id: String
25
+ attr_reader name: String
26
+ attr_reader subject_type: kyc_subject_type
27
+
28
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> Subject
29
+ end
30
+
31
+ # One uploaded-evidence slot (`{attachment_type, submitted_at}`).
32
+ class Attachment < Internal::Model
33
+ attr_reader attachment_type: String
34
+ attr_reader submitted_at: Integer?
35
+
36
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> Attachment
37
+ end
38
+
39
+ # The shared error for an unknown discriminator value (never a silent `nil`).
40
+ def self.dispatch_error: (String union, String discriminator, untyped value) -> Dinie::Error
41
+ end
42
+ end
@@ -0,0 +1,117 @@
1
+ # KYC requirement types + the `KycRequirement` discriminated union (DS-DISCRIMINATED — the
2
+ # headline rule). Mirrors `lib/dinie/generated/types/kyc/requirements.rb`. Base + nine subclasses;
3
+ # partners discriminate by CLASS (`case requirement; when Dinie::Kyc::IdentityRequirement`).
4
+
5
+ module Dinie
6
+ module Kyc
7
+ # Abstract base for the nine requirement variants. Declares no attributes; never instantiated.
8
+ class Requirement < Internal::Model
9
+ end
10
+
11
+ # Identity-document requirement (CNH or RG). Person-specific (carries a `Subject`).
12
+ class IdentityRequirement < Requirement
13
+ attr_reader label: String
14
+ attr_reader mandatory: bool
15
+ attr_reader requirement_id: String
16
+ attr_reader requirement_type: String
17
+ attr_reader subject: Subject
18
+ attr_reader submitted: Submitted?
19
+
20
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> IdentityRequirement
21
+ end
22
+
23
+ # Selfie requirement. Person-specific.
24
+ class SelfieRequirement < Requirement
25
+ attr_reader label: String
26
+ attr_reader mandatory: bool
27
+ attr_reader requirement_id: String
28
+ attr_reader requirement_type: String
29
+ attr_reader subject: Subject
30
+ attr_reader submitted: Submitted?
31
+
32
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> SelfieRequirement
33
+ end
34
+
35
+ # Proof-of-address requirement. Person-specific.
36
+ class ProofOfAddressRequirement < Requirement
37
+ attr_reader label: String
38
+ attr_reader mandatory: bool
39
+ attr_reader requirement_id: String
40
+ attr_reader requirement_type: String
41
+ attr_reader subject: Subject
42
+ attr_reader submitted: Submitted?
43
+
44
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> ProofOfAddressRequirement
45
+ end
46
+
47
+ # Company-document (CCMEI) requirement. Company-wide — no subject.
48
+ class CompanyDocumentRequirement < Requirement
49
+ attr_reader label: String
50
+ attr_reader mandatory: bool
51
+ attr_reader requirement_id: String
52
+ attr_reader requirement_type: String
53
+ attr_reader submitted: Submitted?
54
+
55
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> CompanyDocumentRequirement
56
+ end
57
+
58
+ # EI/MEI documents requirement. Company-wide.
59
+ class EiMeiDocumentsRequirement < Requirement
60
+ attr_reader label: String
61
+ attr_reader mandatory: bool
62
+ attr_reader requirement_id: String
63
+ attr_reader requirement_type: String
64
+ attr_reader submitted: Submitted?
65
+
66
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> EiMeiDocumentsRequirement
67
+ end
68
+
69
+ # Income-statement (DRE) requirement. Company-wide.
70
+ class IncomeStatementRequirement < Requirement
71
+ attr_reader label: String
72
+ attr_reader mandatory: bool
73
+ attr_reader requirement_id: String
74
+ attr_reader requirement_type: String
75
+ attr_reader submitted: Submitted?
76
+
77
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> IncomeStatementRequirement
78
+ end
79
+
80
+ # Articles-of-association (contrato social) requirement. Company-wide.
81
+ class ArticlesOfAssociationRequirement < Requirement
82
+ attr_reader label: String
83
+ attr_reader mandatory: bool
84
+ attr_reader requirement_id: String
85
+ attr_reader requirement_type: String
86
+ attr_reader submitted: Submitted?
87
+
88
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> ArticlesOfAssociationRequirement
89
+ end
90
+
91
+ # EIRELI incorporation-statement requirement. Company-wide.
92
+ class EireliIncorporationStatementRequirement < Requirement
93
+ attr_reader label: String
94
+ attr_reader mandatory: bool
95
+ attr_reader requirement_id: String
96
+ attr_reader requirement_type: String
97
+ attr_reader submitted: Submitted?
98
+
99
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> EireliIncorporationStatementRequirement
100
+ end
101
+
102
+ # Co-owner email-collection requirement (for CCB digital signature). Person-specific.
103
+ class EmailRequirement < Requirement
104
+ attr_reader label: String
105
+ attr_reader mandatory: bool
106
+ attr_reader requirement_id: String
107
+ attr_reader requirement_type: String
108
+ attr_reader subject: Subject
109
+ attr_reader submitted: Submitted?
110
+
111
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> EmailRequirement
112
+ end
113
+
114
+ # Hydrate any wire requirement by dispatching on the explicit `requirement_type` discriminator.
115
+ def self.deserialize_requirement: (Hash[Symbol, untyped] raw) -> Requirement
116
+ end
117
+ end
@@ -0,0 +1,21 @@
1
+ # KYC submitted-evidence family (DS-FAMILY — one model for all ten variants) + the implicit
2
+ # identity CNH|RG dispatch (DS-IMPLICIT). Mirrors `lib/dinie/generated/types/kyc/submitted.rb`.
3
+
4
+ module Dinie
5
+ module Kyc
6
+ class Submitted < Internal::Model
7
+ attr_reader attachments: Array[Attachment]
8
+ attr_reader evidence_type: String
9
+ attr_reader review_reason: String?
10
+ attr_reader review_status: kyc_review_status
11
+
12
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> Submitted
13
+ end
14
+
15
+ # Hydrate any non-identity `*Submitted` (the uniform DS-FAMILY path).
16
+ def self.deserialize_submitted: (Hash[Symbol, untyped] raw) -> Submitted
17
+
18
+ # Hydrate the identity `submitted` oneOf by dispatching on the const `evidence_type`.
19
+ def self.deserialize_identity_submitted: (Hash[Symbol, untyped] raw) -> Submitted
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ # KYC upload request serialization + the `KycUpload` discriminated union (DS-DISCRIMINATED-REQUEST,
2
+ # DS-MULTIPART). Mirrors `lib/dinie/generated/types/kyc/uploads.rb`. `serialize_upload` returns an
3
+ # `UploadForm` (a keyword-init `Struct`).
4
+
5
+ module Dinie
6
+ module Kyc
7
+ FILE_UPLOAD_EVIDENCE_TYPES: Array[String]
8
+
9
+ # The deterministic multipart representation of a KYC upload (a keyword-init `Struct`): the
10
+ # ordered scalar `fields` plus the optional binary `file`.
11
+ class UploadForm
12
+ attr_accessor fields: Hash[Symbol, untyped]
13
+ attr_accessor file: untyped
14
+
15
+ def self.new: (?fields: Hash[Symbol, untyped], ?file: untyped) -> UploadForm
16
+ def initialize: (?fields: Hash[Symbol, untyped], ?file: untyped) -> void
17
+ end
18
+
19
+ # Serialize a KYC upload to its `UploadForm` (the scalar field-map + optional binary `file`) by
20
+ # dispatching on the explicit `evidence_type` discriminator. (Called from the customers resource
21
+ # via a `**upload` splat — see the §21.3 note on the splat idiom + Steep's static keyword check.)
22
+ def self.serialize_upload: (evidence_type: String, requirement_id: String, attachment_type: String, ?file: untyped, ?value: String) -> UploadForm
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ # `Loan` + its `CreateLoanRequest` dump — a contracted loan (`ln_…`) (architecture §3.3, §6).
2
+ # Mirrors `lib/dinie/generated/types/loan.rb`. Read model AND request body.
3
+
4
+ module Dinie
5
+ class Loan < Internal::Model
6
+ attr_reader annual_cet_rate: Float
7
+ attr_reader annual_interest_rate: Float
8
+ attr_reader ccb_number: String?
9
+ attr_reader created_at: Integer
10
+ attr_reader credit_offer_id: credit_offer_id
11
+ attr_reader customer_id: customer_id
12
+ attr_reader disbursement_method: String?
13
+ attr_reader first_due_date: String
14
+ attr_reader id: loan_id
15
+ attr_reader installment_amount: money
16
+ attr_reader installment_count: Integer
17
+ attr_reader iof_amount: Float?
18
+ attr_reader monthly_cet_rate: Float
19
+ attr_reader monthly_interest_rate: Float
20
+ attr_reader principal_amount: Float?
21
+ attr_reader requested_amount: money
22
+ attr_reader signing_url: String?
23
+ attr_reader simulation_id: simulation_id
24
+ attr_reader status: loan_status
25
+ attr_reader total_amount: money
26
+ attr_reader updated_at: Integer
27
+
28
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> Loan
29
+
30
+ def self.serialize_create: (credit_offer_id: String, simulation_id: String, installment_count: Integer, installment_amount: Float, first_due_date: String) -> Hash[Symbol, untyped]
31
+ end
32
+ end
@@ -0,0 +1,6 @@
1
+ # `Money` is a plain `Float` (BRL), doc-only (architecture §3.3, §21.2). No runtime class —
2
+ # the value IS a `Float` (mirrors the TS `type Money = number`).
3
+
4
+ module Dinie
5
+ type money = Float
6
+ end
@@ -0,0 +1,28 @@
1
+ # `Simulation` + its `CreateSimulationRequest` dump — credit-offer pricing (`sim_…`)
2
+ # (architecture §3.3, §6). Mirrors `lib/dinie/generated/types/simulation.rb`. Read model AND
3
+ # request body; every field required (no optional members).
4
+
5
+ module Dinie
6
+ class Simulation < Internal::Model
7
+ attr_reader annual_cet_rate: Float
8
+ attr_reader annual_interest_rate: Float
9
+ attr_reader created_at: Integer
10
+ attr_reader credit_offer_id: credit_offer_id
11
+ attr_reader fee_amount: money
12
+ attr_reader first_due_date: String
13
+ attr_reader id: simulation_id
14
+ attr_reader installment_amount: money
15
+ attr_reader installment_count: Integer
16
+ attr_reader interest_amount: money
17
+ attr_reader iof_amount: money
18
+ attr_reader monthly_cet_rate: Float
19
+ attr_reader monthly_interest_rate: Float
20
+ attr_reader principal_amount: money
21
+ attr_reader requested_amount: money
22
+ attr_reader total_amount: money
23
+
24
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> Simulation
25
+
26
+ def self.serialize_create: (installment_count: Integer, requested_amount: Float) -> Hash[Symbol, untyped]
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ # `Transaction` — one installment of a loan (`tx_…`), read-only (architecture §3.3, §6).
2
+ # Mirrors `lib/dinie/generated/types/transaction.rb`.
3
+
4
+ module Dinie
5
+ class Transaction < Internal::Model
6
+ attr_reader amount_due: money
7
+ attr_reader amount_paid: money
8
+ attr_reader amount_remaining: money
9
+ attr_reader created_at: Integer
10
+ attr_reader days_overdue: Integer
11
+ attr_reader due_date: String
12
+ attr_reader fees: money
13
+ attr_reader id: transaction_id
14
+ attr_reader interest: money
15
+ attr_reader loan_id: loan_id
16
+ attr_reader paid_at: Integer?
17
+ attr_reader principal: money
18
+ attr_reader status: transaction_status
19
+ attr_reader type: transaction_type
20
+ attr_reader updated_at: Integer
21
+
22
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> Transaction
23
+ end
24
+ end
@@ -0,0 +1,38 @@
1
+ # `WebhookEndpoint` family — REST management types (architecture §3.2, §3.3, §6). Mirrors
2
+ # `lib/dinie/generated/types/webhook_endpoint.rb`. NOT the webhook runtime (that is `Events::*`).
3
+
4
+ module Dinie
5
+ class WebhookEndpoint < Internal::Model
6
+ attr_reader created_at: Integer
7
+ attr_reader description: String
8
+ attr_reader events: Array[String]
9
+ attr_reader id: webhook_endpoint_id
10
+ attr_reader status: webhook_endpoint_status
11
+ attr_reader updated_at: Integer
12
+ attr_reader url: String
13
+
14
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> WebhookEndpoint
15
+
16
+ def self.serialize_create: (url: String, ?events: Array[String], ?description: String) -> Hash[Symbol, untyped]
17
+
18
+ def self.serialize_update: (?url: String, ?events: Array[String], ?description: String, ?status: String) -> Hash[Symbol, untyped]
19
+ end
20
+
21
+ # The creation-only endpoint — `WebhookEndpoint` plus `secret` (the contract's allOf).
22
+ class WebhookEndpointWithSecret < WebhookEndpoint
23
+ attr_reader secret: String
24
+
25
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> WebhookEndpointWithSecret
26
+ end
27
+
28
+ # The result of `webhook_endpoints.rotate_secret` — the new signing secret + old-secret deadline.
29
+ class WebhookSecretRotation < Internal::Model
30
+ attr_reader id: webhook_endpoint_id
31
+ attr_reader previous_secret_expires_at: Integer
32
+ attr_reader secret: String
33
+
34
+ def self.deserialize: (Hash[Symbol, untyped] raw) -> WebhookSecretRotation
35
+
36
+ def self.serialize_rotate_secret: (?expire_current_in: Integer) -> Hash[Symbol, untyped]
37
+ end
38
+ end
@@ -0,0 +1,106 @@
1
+ # Error hierarchy + the `from_response` dispatcher + `parse_retry_after` (architecture §7, §10).
2
+ # Mirrors `lib/dinie/runtime/errors.rb`. The 8 server-response markers are empty subclasses of
3
+ # `APIStatusError` declared in `generated/errors/registry.rbs`.
4
+
5
+ module Dinie
6
+ # Root of every error the SDK raises.
7
+ class Error < StandardError
8
+ end
9
+
10
+ # Base for everything that originates from talking to the Dinie API. `code` / `request_id`
11
+ # are first-class on every API error.
12
+ class APIError < Error
13
+ attr_reader code: String?
14
+ attr_reader request_id: String?
15
+
16
+ def initialize: (?String? message, ?code: String?, ?request_id: String?) -> void
17
+ end
18
+
19
+ # A request never produced a response (DNS failure, socket reset, timeout). Client-side.
20
+ class APIConnectionError < APIError
21
+ def initialize: (?String message) -> void
22
+ end
23
+
24
+ # The request exceeded the configured timeout.
25
+ class APITimeoutError < APIConnectionError
26
+ def initialize: (?String message) -> void
27
+ end
28
+
29
+ # The API returned a non-2xx response. Base of the openapi-mirrored marker catalog.
30
+ class APIStatusError < APIError
31
+ attr_reader status: Integer
32
+ attr_reader headers: Hash[untyped, untyped]
33
+ attr_reader body: (Hash[Symbol, untyped] | String | nil)
34
+ attr_reader type: String?
35
+ attr_reader title: String?
36
+ attr_reader detail: String?
37
+ attr_reader instance: String?
38
+
39
+ def initialize: (status: Integer, body: (Hash[Symbol, untyped] | String | nil), headers: Hash[untyped, untyped], ?request_id: String?) -> void
40
+
41
+ def self.build_message: (Integer status, untyped body, String? request_id) -> String
42
+ def self.message_summary: (untyped body) -> String?
43
+
44
+ private
45
+
46
+ def string_field: (Hash[Symbol, untyped]? problem, Symbol key) -> String?
47
+ end
48
+
49
+ # OAuth2 client-credentials token acquisition/refresh failed (client-side).
50
+ class OAuthError < Error
51
+ end
52
+
53
+ # A session-mode token was successfully exchanged once but has since expired.
54
+ class SessionTokenExpiredError < Error
55
+ end
56
+
57
+ # A webhook payload failed HMAC signature verification.
58
+ class WebhookSignatureError < Error
59
+ end
60
+
61
+ # A webhook timestamp fell outside the tolerance window.
62
+ class WebhookTimestampError < Error
63
+ end
64
+
65
+ # A webhook signature verified, but the payload's `type` is not in the openapi catalog.
66
+ class UnknownWebhookEventError < Error
67
+ attr_reader event_type: String
68
+
69
+ def initialize: (String event_type) -> void
70
+ end
71
+
72
+ # Maximum honored `Retry-After`, in seconds.
73
+ RETRY_AFTER_CAP_SECONDS: Integer
74
+
75
+ # Parse a `Retry-After` value to seconds, capped at 60. Each argument accepts a String or an
76
+ # Array (first element used). Returns the wait in seconds, or `nil` when nothing parseable.
77
+ def self.parse_retry_after: (?(String | Array[String])? retry_after, ?retry_after_ms: (String | Array[String])?) -> Float?
78
+
79
+ def self.retry_after_ms_seconds: (untyped value) -> Float?
80
+ def self.retry_after_seconds: (untyped value) -> Float?
81
+ def self.http_date_delta: (String raw) -> Float?
82
+ def self.first_header_value: (untyped value) -> String?
83
+
84
+ module Internal
85
+ # The transport-agnostic error dispatcher (the controlled runtime → generated seam, §4).
86
+ # `module_function`: methods are declared as instance methods (Steep types `self` as the module
87
+ # inside them) and are also callable on the module (`Errors.from_response`).
88
+ module Errors
89
+ REQUEST_ID_HEADER: String
90
+
91
+ # Build the typed error for an HTTP error response: dispatch by Problem Details `type` URL,
92
+ # then HTTP status, then the ≥500 band fallback.
93
+ def from_response: (status: Integer, ?headers: Hash[untyped, untyped], ?body: String?, ?force: untyped) -> Dinie::APIStatusError
94
+ def dispatch: (String? type_url, Integer status) -> untyped
95
+ def fallback_ctor: (Integer status) -> untyped
96
+ def parse_problem: (untyped body) -> Hash[Symbol, untyped]?
97
+ def presentable_body: (untyped body) -> String?
98
+ def header_request_id: (untyped headers) -> untyped
99
+ def header_lookup: (untyped headers, String name) -> untyped
100
+ def string_value: (Hash[Symbol, untyped]? record, Symbol key) -> String?
101
+
102
+ # Module-function alias (callable as `Errors.from_response`).
103
+ def self.from_response: (status: Integer, ?headers: Hash[untyped, untyped], ?body: String?, ?force: untyped) -> Dinie::APIStatusError
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,59 @@
1
+ # `HttpClient` — request-lifecycle orchestrator (architecture §10, RB15). Mirrors
2
+ # `lib/dinie/runtime/http.rb`. Runtime-internal: constructed/called by `Dinie::Client` + resources.
3
+ # Faraday objects (connection, response, env) are `untyped` — `faraday` ships no bundled RBS
4
+ # (the documented informative-gate gap, story 013 / §21.3).
5
+
6
+ module Dinie
7
+ module Internal
8
+ class HttpClient
9
+ DEFAULT_BASE_URL: String
10
+ DEFAULT_TIMEOUT_SECONDS: Integer
11
+ DEFAULT_MAX_RETRIES: Integer
12
+ API_VERSION: String
13
+ JSON_CONTENT_TYPE: String
14
+ AUTO_IDEMPOTENT_METHODS: Array[Symbol]
15
+ USER_AGENT: String
16
+
17
+ # Per-call request descriptor threaded through the retry loop (a private keyword-init Struct).
18
+ class PreparedRequest
19
+ attr_accessor http_method: Symbol
20
+ attr_accessor url: String
21
+ attr_accessor body: untyped
22
+ attr_accessor content_type: String?
23
+ attr_accessor idempotency_key: String?
24
+ attr_accessor max_retries: Integer
25
+ attr_accessor timeout: Numeric
26
+ attr_accessor header_overrides: Hash[String, String?]?
27
+
28
+ def self.new: (**untyped) -> PreparedRequest
29
+ def initialize: (**untyped) -> void
30
+ end
31
+
32
+ def initialize: (token_manager: untyped, ?base_url: String?, ?timeout: Numeric, ?max_retries: Integer, ?idempotency: bool, ?adapter: Symbol?, ?connection: untyped, ?sleeper: untyped) -> void
33
+
34
+ # Latest rate-limit snapshot (read by `client.rate_limit`).
35
+ def rate_limit: () -> Dinie::RateLimit?
36
+
37
+ # Run one logical request end-to-end and return the parsed body (resources deserialize it).
38
+ def request: (method: (Symbol | String), path: String, ?query: Hash[untyped, untyped]?, ?body: untyped, ?idempotent: bool?, ?request_options: (Dinie::Internal::RequestOptions | Hash[untyped, untyped] | nil)) -> untyped
39
+
40
+ private
41
+
42
+ def execute: (untyped prepared) -> untyped
43
+ def dispatch: (untyped prepared, Hash[String, untyped] headers) -> untyped
44
+ def build_headers: (untyped prepared, String token, Integer attempt) -> Hash[String, untyped]
45
+ def base_headers: (String token) -> Hash[String, String]
46
+ def apply_header_overrides: (Hash[String, untyped] headers, Hash[String, String?]? overrides) -> Hash[String, untyped]
47
+ def resolve_idempotency_key: (bool? idempotent, Symbol method, Dinie::Internal::RequestOptions options) -> String?
48
+ def serialize_body: (untyped body) -> [ untyped, String? ]
49
+ def parse_body: (untyped response) -> untyped
50
+ def build_full_url: (String path, Hash[untyped, untyped]? query) -> String
51
+ def encode_query: (Hash[untyped, untyped]? query) -> String
52
+ def header: (untyped response, String name) -> untyped
53
+ def build_error: (untyped response, ?force: Class?) -> Dinie::APIStatusError
54
+ def translate_network_error: (untyped error) -> Dinie::APIError
55
+ def sleep_for: (Numeric seconds) -> untyped
56
+ def build_connection: (Symbol? adapter) -> untyped
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,15 @@
1
+ # Idempotency-Key generation (architecture §10, RB15). Mirrors `lib/dinie/runtime/idempotency.rb`.
2
+ # Runtime-internal: consumed by `HttpClient`, not part of the public surface.
3
+
4
+ module Dinie
5
+ module Internal
6
+ module Idempotency
7
+ KEY_PREFIX: String
8
+
9
+ # `module_function`: instance method + singleton alias (called as `Idempotency.generate_key`).
10
+ # A fresh auto-generated Idempotency-Key: `dinie-sdk-retry-<uuid v4>`.
11
+ def generate_key: () -> String
12
+ def self.generate_key: () -> String
13
+ end
14
+ end
15
+ end