Module: Dinie::Internal

Defined in:
lib/dinie/runtime/model.rb,
lib/dinie/runtime/http.rb,
lib/dinie/runtime/retry.rb,
lib/dinie/runtime/errors.rb,
lib/dinie/runtime/logger.rb,
lib/dinie/runtime/multipart.rb,
lib/dinie/runtime/rate_limit.rb,
lib/dinie/generated/types/ids.rb,
lib/dinie/runtime/idempotency.rb,
lib/dinie/runtime/token_manager.rb,
lib/dinie/runtime/request_options.rb,
lib/dinie/generated/errors/registry.rb

Overview

‘Internal::` holds everything that is NOT part of the frozen public surface: the transport, the token manager, the error registry, the model base, and the `OMIT` sentinel. It is the Ruby equivalent of “not re-exported by the barrel” in `sdk-js` (architecture §3.1). The generated layer (V0.4) emits subclasses of Model; the hand-written runtime references `Dinie::Internal::*`.

Defined Under Namespace

Modules: Errors, Idempotency, LogRedaction, Middleware, Retry Classes: HttpClient, Model, Multipart, RateLimitTracker, RequestOptions, RuntimeLogger, TokenManager

Constant Summary collapse

OMIT =

The sentinel for “this optional argument was not provided” (RB5, architecture §6.2).

Ruby collapses “absent” and ‘nil`; `OMIT` recovers the distinction TypeScript keeps via `exactOptionalPropertyTypes`. Request serializers default optional keyword arguments to `OMIT` and drop any key still equal to it, so an omitted field never reaches the wire — while an explicit `nil` is sent as JSON `null` (a required-nullable field). Compare by identity: `value.equal?(Dinie::Internal::OMIT)` or the omitted? helper. There is exactly one instance and it is frozen.

Object.new
ID_PATTERNS =
{
  api_client: /\Adinie_ci_(live|test)_[A-Za-z0-9]+\z/,
  bank_account: /\Aba_[0-9a-f]{32}\z/,
  credit_offer: /\Aco_[0-9a-f]{32}\z/,
  customer: /\Acust_[0-9a-f]{32}\z/,
  event: /\Aevt_[0-9a-f]{32}\z/,
  loan: /\Aln_[0-9a-f]{32}\z/,
  simulation: /\Asim_[0-9a-f]{32}\z/,
  transaction: /\Atx_[0-9a-f]{32}\z/,
  webhook_delivery: /\Adlv_[0-9a-f]{32}\z/,
  webhook_endpoint: /\Awe_[0-9a-f]{32}\z/
}.freeze
ERROR_REGISTRY =
{
  by_type: {
    "https://docs.dinie.com/errors/invalid-request" => Dinie::BadRequestError,
    "https://docs.dinie.com/errors/authentication-failed" => Dinie::AuthError,
    "https://docs.dinie.com/errors/forbidden" => Dinie::PermissionDeniedError,
    "https://docs.dinie.com/errors/not-found" => Dinie::NotFoundError,
    "https://docs.dinie.com/errors/conflict" => Dinie::ConflictError,
    "https://docs.dinie.com/errors/validation-failed" => Dinie::ValidationError,
    "https://docs.dinie.com/errors/rate-limit-exceeded" => Dinie::RateLimitError,
    "https://docs.dinie.com/errors/internal" => Dinie::ServerError
  }.freeze,
  by_status: {
    400 => Dinie::BadRequestError,
    401 => Dinie::AuthError,
    403 => Dinie::PermissionDeniedError,
    404 => Dinie::NotFoundError,
    409 => Dinie::ConflictError,
    422 => Dinie::ValidationError,
    429 => Dinie::RateLimitError,
    500 => Dinie::ServerError
  }.freeze,
  fallback_5xx: Dinie::ServerError
}.freeze

Class Method Summary collapse

Class Method Details

.omitted?(value) ⇒ Boolean

Identity check for the OMIT sentinel.

Parameters:

  • value (Object)

    any value

Returns:

  • (Boolean)

    true only when ‘value` IS the OMIT sentinel



32
33
34
# File 'lib/dinie/runtime/model.rb', line 32

def self.omitted?(value)
  value.equal?(OMIT)
end