Module: Dinie

Defined in:
lib/dinie/generated/api_version.rb,
lib/dinie/version.rb,
lib/dinie/runtime/http.rb,
lib/dinie/runtime/model.rb,
lib/dinie/runtime/retry.rb,
lib/dinie/runtime/errors.rb,
lib/dinie/runtime/logger.rb,
lib/dinie/generated/client.rb,
lib/dinie/runtime/webhooks.rb,
lib/dinie/runtime/multipart.rb,
lib/dinie/runtime/paginator.rb,
lib/dinie/runtime/rate_limit.rb,
lib/dinie/generated/types/ids.rb,
lib/dinie/generated/types/kyc.rb,
lib/dinie/runtime/idempotency.rb,
lib/dinie/generated/types/bank.rb,
lib/dinie/generated/types/loan.rb,
lib/dinie/generated/events/base.rb,
lib/dinie/generated/types/money.rb,
lib/dinie/runtime/token_manager.rb,
lib/dinie/runtime/request_options.rb,
lib/dinie/generated/types/customer.rb,
lib/dinie/generated/errors/registry.rb,
lib/dinie/generated/resources/banks.rb,
lib/dinie/generated/resources/loans.rb,
lib/dinie/generated/types/credential.rb,
lib/dinie/generated/types/simulation.rb,
lib/dinie/generated/types/transaction.rb,
lib/dinie/generated/events/loan_active.rb,
lib/dinie/generated/events/loan_status.rb,
lib/dinie/generated/types/credit_offer.rb,
lib/dinie/generated/events/credit_offer.rb,
lib/dinie/generated/events/loan_created.rb,
lib/dinie/generated/resources/customers.rb,
lib/dinie/generated/events/deserializers.rb,
lib/dinie/generated/resources/biometrics.rb,
lib/dinie/generated/resources/credentials.rb,
lib/dinie/generated/events/customer_denied.rb,
lib/dinie/generated/events/customer_status.rb,
lib/dinie/generated/events/loan_processing.rb,
lib/dinie/generated/types/webhook_endpoint.rb,
lib/dinie/generated/events/customer_created.rb,
lib/dinie/generated/resources/credit_offers.rb,
lib/dinie/generated/types/biometrics_session.rb,
lib/dinie/generated/events/customer_kyc_updated.rb,
lib/dinie/generated/resources/webhook_endpoints.rb,
lib/dinie/generated/types/customer_bank_account.rb,
lib/dinie/generated/events/loan_payment_received.rb,
lib/dinie/generated/types/kyc_attachment_response.rb,
lib/dinie/generated/types/webhook_secret_rotation.rb,
lib/dinie/generated/events/loan_signature_received.rb,
lib/dinie/generated/types/biometrics_session_exchange_response.rb

Overview

generated — do not edit

Defined Under Namespace

Modules: BiometricsSessionExchangeResponseTokenType, CredentialStatus, CreditOffer, CustomerBankAccountKind, CustomerStatus, Events, Generated, Internal, KycSubjectType, LoanStatus, Resources, ReviewStatus, TransactionStatus, TransactionType, WebhookEndpointStatus, Webhooks Classes: APIConnectionError, APIError, APIStatusError, APITimeoutError, ArticlesOfAssociationAttachment, ArticlesOfAssociationRequirement, ArticlesOfAssociationSubmitted, AuthError, BadRequestError, Bank, BiometricsSession, BiometricsSessionExchangeResponse, Client, CompanyDocumentAttachment, CompanyDocumentRequirement, CompanyDocumentSubmitted, ConflictError, Credential, CredentialWithSecret, Customer, CustomerBankAccount, EiMeiDocumentsAttachment, EiMeiDocumentsRequirement, EiMeiDocumentsSubmitted, EireliIncorporationStatementAttachment, EireliIncorporationStatementRequirement, EireliIncorporationStatementSubmitted, EmailAttachment, EmailRequirement, EmailSubmitted, Error, FixedInstallmentCreditOffer, IdentityCnhAttachment, IdentityCnhSubmitted, IdentityRequirement, IdentityRgAttachment, IdentityRgSubmitted, IncomeStatementAttachment, IncomeStatementRequirement, IncomeStatementSubmitted, KycAttachmentResponse, KycRequirement, KycSubject, KycUploadForm, Loan, NotFoundError, OAuthError, Page, PermissionDeniedError, ProofOfAddressAttachment, ProofOfAddressRequirement, ProofOfAddressSubmitted, RangeInstallmentCreditOffer, RateLimit, RateLimitError, SelfieAttachment, SelfieRequirement, SelfieSubmitted, ServerError, SessionTokenExpiredError, Simulation, Transaction, UnknownWebhookEventError, ValidationError, WebhookEndpoint, WebhookEndpointWithSecret, WebhookSecretRotation, WebhookSignatureError, WebhookTimestampError

Constant Summary collapse

VERSION =

The gem version (semver). Surfaced in the ‘User-Agent` (`Dinie-SDK-Ruby/<VERSION>`) and the `X-Dinie-Sdk-Version` header. Generator-sourced in V0.5.

"1.1.0"
RETRY_AFTER_CAP_SECONDS =

Maximum honored ‘Retry-After`, in seconds (architecture §10 — verbatim from the V0.2 freeze).

60
KYC_FILE_UPLOAD_EVIDENCE_TYPES =
%w[
  cnh rg selfie proof_of_address ccmei ei_mei income_statement articles_of_association eireli_incorporation_statement
].freeze

Class Method Summary collapse

Class Method Details

.deserialize_identity_submitted(raw) ⇒ Object



278
279
280
281
282
283
284
# File 'lib/dinie/generated/types/kyc.rb', line 278

def self.(raw)
  case raw[:evidence_type]
  when "cnh" then IdentityCnhSubmitted.deserialize(raw)
  when "rg" then IdentityRgSubmitted.deserialize(raw)
  else raise kyc_dispatch_error("IdentitySubmitted", "evidence_type", raw[:evidence_type])
  end
end

.deserialize_kyc_requirement(raw) ⇒ Object



419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/dinie/generated/types/kyc.rb', line 419

def self.deserialize_kyc_requirement(raw)
  case raw[:requirement_type]
  when "identity" then IdentityRequirement.deserialize(raw)
  when "selfie" then SelfieRequirement.deserialize(raw)
  when "proof_of_address" then ProofOfAddressRequirement.deserialize(raw)
  when "company_document" then CompanyDocumentRequirement.deserialize(raw)
  when "ei_mei_documents" then EiMeiDocumentsRequirement.deserialize(raw)
  when "income_statement" then IncomeStatementRequirement.deserialize(raw)
  when "articles_of_association" then ArticlesOfAssociationRequirement.deserialize(raw)
  when "eireli_incorporation_statement" then EireliIncorporationStatementRequirement.deserialize(raw)
  when "email" then EmailRequirement.deserialize(raw)
  else raise kyc_dispatch_error("KycRequirement", "requirement_type", raw[:requirement_type])
  end
end

.kyc_dispatch_error(union, discriminator, value) ⇒ Object



141
142
143
144
145
146
# File 'lib/dinie/generated/types/kyc.rb', line 141

def self.kyc_dispatch_error(union, discriminator, value)
  Dinie::Error.new(
    "Unknown #{union} #{discriminator}: #{value.inspect}. This discriminator value is not " \
    "declared in the openapi oneOf mapping — the SDK and contract are out of sync."
  )
end

.parse_retry_after(retry_after = nil, retry_after_ms: nil) ⇒ Float?

Parse a ‘Retry-After` value to seconds, capped at 60 (architecture §7/§10).

Precedence mirrors the retry loop: a ‘Retry-After-Ms` value (milliseconds) wins, then `Retry-After` as delta-seconds, then `Retry-After` as an HTTP-date (delta from now). Each argument accepts a String or an Array (the first element is used, for repeated headers). A past HTTP-date clamps to 0; an abusive value clamps to 60. Returns the wait in seconds (Float) or `nil` when nothing parseable was given.

Public runtime helper, consumed by the transport’s retry loop (story 003) and usable in custom post-‘RateLimitError` logic.

Parameters:

  • retry_after (String, Array<String>, nil) (defaults to: nil)

    the ‘Retry-After` header value

  • retry_after_ms (String, Array<String>, nil) (defaults to: nil)

    the ‘Retry-After-Ms` header value

Returns:

  • (Float, nil)

    seconds to wait (0..60), or nil



162
163
164
165
166
167
# File 'lib/dinie/runtime/errors.rb', line 162

def self.parse_retry_after(retry_after = nil, retry_after_ms: nil)
  seconds = retry_after_ms_seconds(retry_after_ms) || retry_after_seconds(retry_after)
  return nil if seconds.nil?

  seconds.clamp(0.0, RETRY_AFTER_CAP_SECONDS.to_f)
end

.serialize_kyc_upload(evidence_type:, requirement_id:, attachment_type:, file: Internal::OMIT, value: Internal::OMIT) ⇒ Object



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/dinie/generated/types/kyc.rb', line 440

def self.serialize_kyc_upload(evidence_type:, requirement_id:, attachment_type:, file: Internal::OMIT,
                              value: Internal::OMIT)
  fields = { attachment_type:, evidence_type:, requirement_id: }
  case evidence_type
  when *KYC_FILE_UPLOAD_EVIDENCE_TYPES
    if Internal.omitted?(file)
      raise Dinie::Error, "KYC upload evidence_type=#{evidence_type.inspect} requires a `file:`"
    end

    KycUploadForm.new(fields:, file:)
  when "email"
    raise Dinie::Error, "KYC upload evidence_type=\"email\" requires a `value:`" if Internal.omitted?(value)

    KycUploadForm.new(fields: fields.merge(value:), file: nil)
  else
    raise kyc_dispatch_error("KycUpload", "evidence_type", evidence_type)
  end
end