Module: ModernTreasury::Internal::Type::Enum Private
- Includes:
- Converter, Util::SorbetRuntimeSupport
- Included in:
- Models::AccountCollectionFlow::PaymentType, Models::AccountCollectionFlow::ReceivingCountry, Models::AccountCollectionFlow::Status, Models::AccountCollectionFlowCreateParams::ReceivingCountry, Models::AccountCollectionFlowUpdateParams::Status, Models::AccountDetail::AccountNumberType, Models::AccountDetailCreateParams::AccountNumberType, Models::AccountDetailCreateParams::AccountsType, Models::AccountDetailDeleteParams::AccountsType, Models::AccountsType, Models::BulkRequest::ActionType, Models::BulkRequest::ResourceType, Models::BulkRequest::Status, Models::BulkRequestCreateParams::ActionType, Models::BulkRequestCreateParams::Resource::ExpectedPaymentCreateRequest::Direction, Models::BulkRequestCreateParams::Resource::ExpectedPaymentUpdateRequestWithID::Direction, Models::BulkRequestCreateParams::Resource::ExpectedPaymentUpdateRequestWithID::Status, Models::BulkRequestCreateParams::Resource::LedgerTransactionUpdateRequestWithID::LedgerableType, Models::BulkRequestCreateParams::Resource::LedgerTransactionUpdateRequestWithID::Status, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ChargeBearer, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::Direction, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::FallbackType, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ForeignExchangeIndicator, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::Priority, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReceivingAccount::AccountDetail::AccountNumberType, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReceivingAccount::PartyType, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReceivingAccount::RoutingDetail::PaymentType, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReceivingAccount::RoutingDetail::RoutingNumberType, Models::BulkRequestCreateParams::Resource::PaymentOrderAsyncCreateRequest::ReconciliationStatus, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ChargeBearer, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::Direction, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::FallbackType, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ForeignExchangeIndicator, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::Priority, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReceivingAccount::AccountDetail::AccountNumberType, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReceivingAccount::PartyType, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReceivingAccount::RoutingDetail::PaymentType, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReceivingAccount::RoutingDetail::RoutingNumberType, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::ReconciliationStatus, Models::BulkRequestCreateParams::Resource::PaymentOrderUpdateRequestWithID::Status, Models::BulkRequestCreateParams::Resource::TransactionCreateRequest::Type, Models::BulkRequestCreateParams::ResourceType, Models::BulkRequestListParams::ActionType, Models::BulkRequestListParams::ResourceType, Models::BulkRequestListParams::Status, Models::BulkResult::EntityType, Models::BulkResult::RequestType, Models::BulkResult::Status, Models::BulkResultListParams::EntityType, Models::BulkResultListParams::RequestType, Models::BulkResultListParams::Status, Models::ChildLegalEntityCreate::LegalEntityType, Models::ChildLegalEntityCreate::LegalStructure, Models::ChildLegalEntityCreate::RiskRating, Models::ConnectionLegalEntity::Status, Models::ConnectionLegalEntityCreateParams::LegalEntity::LegalEntityAssociation::RelationshipType, Models::ConnectionLegalEntityCreateParams::LegalEntity::LegalEntityType, Models::ConnectionLegalEntityCreateParams::LegalEntity::LegalStructure, Models::ConnectionLegalEntityCreateParams::LegalEntity::RiskRating, Models::ConnectionLegalEntityListParams::Status, Models::ConnectionLegalEntityUpdateParams::Status, Models::ContactDetail::ContactIdentifierType, Models::ContactDetailCreateRequest::ContactIdentifierType, Models::Counterparty::Account::PartyType, Models::Counterparty::Account::VerificationSource, Models::Counterparty::Account::VerificationStatus, Models::CounterpartyCollectAccountParams::Field, Models::CounterpartyCreateParams::Account::AccountDetail::AccountNumberType, Models::CounterpartyCreateParams::Account::PartyType, Models::CounterpartyCreateParams::Account::RoutingDetail::PaymentType, Models::CounterpartyCreateParams::Account::RoutingDetail::RoutingNumberType, Models::CounterpartyCreateParams::Accounting::Type, Models::CounterpartyCreateParams::LedgerType, Models::CounterpartyCreateParams::LegalEntity::LegalEntityAssociation::RelationshipType, Models::CounterpartyCreateParams::LegalEntity::LegalEntityType, Models::CounterpartyCreateParams::LegalEntity::LegalStructure, Models::CounterpartyCreateParams::LegalEntity::RiskRating, Models::Currency, Models::Document::DocumentableType, Models::DocumentCreateParams::DocumentableType, Models::DocumentListParams::DocumentableType, Models::ExpectedPayment::Direction, Models::ExpectedPayment::ReconciliationMethod, Models::ExpectedPayment::Status, Models::ExpectedPaymentCreateParams::Direction, Models::ExpectedPaymentListParams::Status, Models::ExpectedPaymentListParams::Type, Models::ExpectedPaymentType, Models::ExpectedPaymentUpdateParams::Direction, Models::ExpectedPaymentUpdateParams::Status, Models::ExternalAccount::PartyType, Models::ExternalAccount::VerificationSource, Models::ExternalAccount::VerificationStatus, Models::ExternalAccountCreateParams::AccountDetail::AccountNumberType, Models::ExternalAccountCreateParams::PartyType, Models::ExternalAccountCreateParams::RoutingDetail::PaymentType, Models::ExternalAccountCreateParams::RoutingDetail::RoutingNumberType, Models::ExternalAccountType, Models::ExternalAccountUpdateParams::PartyType, Models::ExternalAccountVerifyParams::FallbackType, Models::ExternalAccountVerifyParams::PaymentType, Models::ExternalAccountVerifyParams::Priority, Models::ExternalAccountVerifyResponse::ExternalAccountVerificationAttempt::PaymentType, Models::ExternalAccountVerifyResponse::ExternalAccountVerificationAttempt::Priority, Models::ExternalAccountVerifyResponse::ExternalAccountVerificationAttempt::Status, Models::HoldCreateParams::Status, Models::HoldCreateParams::TargetType, Models::HoldCreateResponse::Object, Models::HoldCreateResponse::Status, Models::HoldCreateResponse::TargetType, Models::HoldListParams::Status, Models::HoldListParams::TargetType, Models::HoldListResponse::Object, Models::HoldListResponse::Status, Models::HoldListResponse::TargetType, Models::HoldRetrieveResponse::Object, Models::HoldRetrieveResponse::Status, Models::HoldRetrieveResponse::TargetType, Models::HoldUpdateParams::Status, Models::HoldUpdateResponse::Object, Models::HoldUpdateResponse::Status, Models::HoldUpdateResponse::TargetType, Models::IdentificationCreateRequest::IDType, Models::IncomingPaymentDetail::OriginatingAccountNumberType, Models::IncomingPaymentDetail::OriginatingRoutingNumberType, Models::IncomingPaymentDetail::ReconciliationStatus, Models::IncomingPaymentDetail::Status, Models::IncomingPaymentDetail::Type, Models::IncomingPaymentDetailCreateAsyncParams::Direction, Models::IncomingPaymentDetailCreateAsyncParams::Type, Models::IncomingPaymentDetailListParams::Status, Models::IncomingPaymentDetailListParams::Type, Models::InternalAccount::AccountCapability::PaymentType, Models::InternalAccount::AccountType, Models::InternalAccount::PartyType, Models::InternalAccount::Status, Models::InternalAccountCreateParams::AccountCapability::PaymentType, Models::InternalAccountCreateParams::AccountType, Models::InternalAccountCreateParams::Currency, Models::InternalAccountListParams::PaymentType, Models::InternalAccountListParams::Status, Models::InternalAccountUpdateAccountCapabilityResponse::PaymentType, Models::InternalAccounts::BalanceReport::Balance::BalanceType, Models::InternalAccounts::BalanceReport::BalanceReportType, Models::InternalAccounts::BalanceReportCreateParams::Balance::BalanceType, Models::InternalAccounts::BalanceReportCreateParams::BalanceReportType, Models::InternalAccounts::BalanceReportListParams::BalanceReportType, Models::Invoice::PaymentMethod, Models::Invoice::PaymentType, Models::Invoice::Status, Models::InvoiceCreateParams::PaymentMethod, Models::InvoiceListParams::Status, Models::InvoiceUpdateParams::PaymentMethod, Models::LedgerAccount::LedgerableType, Models::LedgerAccountCreateRequest::LedgerableType, Models::LedgerAccountSettlement::Status, Models::LedgerAccountSettlementCreateParams::Status, Models::LedgerAccountSettlementUpdateParams::Status, Models::LedgerEntry::Status, Models::LedgerEntryListParams::OrderBy::CreatedAt, Models::LedgerEntryListParams::OrderBy::EffectiveAt, Models::LedgerEntryListParams::Status, Models::LedgerTransaction::LedgerableType, Models::LedgerTransaction::Status, Models::LedgerTransactionCreatePartialPostParams::PostedLedgerEntry::Direction, Models::LedgerTransactionCreateRequest::LedgerableType, Models::LedgerTransactionCreateRequest::Status, Models::LedgerTransactionCreateReversalParams::LedgerableType, Models::LedgerTransactionCreateReversalParams::Status, Models::LedgerTransactionListParams::LedgerableType, Models::LedgerTransactionListParams::OrderBy::CreatedAt, Models::LedgerTransactionListParams::OrderBy::EffectiveAt, Models::LedgerTransactionListParams::Status::UnionMember1, Models::LedgerTransactionUpdateParams::LedgerableType, Models::LedgerTransactionUpdateParams::Status, Models::LedgerTransactions::LedgerTransactionVersion::LedgerEntry::Status, Models::LedgerTransactions::LedgerTransactionVersion::LedgerableType, Models::LedgerTransactions::LedgerTransactionVersion::Status, Models::LegalEntity::Address::AddressType, Models::LegalEntity::Identification::IDType, Models::LegalEntity::LegalEntityType, Models::LegalEntity::LegalStructure, Models::LegalEntity::RiskRating, Models::LegalEntityAddressCreateRequest::AddressType, Models::LegalEntityAssociation::ChildLegalEntity::Address::AddressType, Models::LegalEntityAssociation::ChildLegalEntity::Identification::IDType, Models::LegalEntityAssociation::ChildLegalEntity::LegalEntityType, Models::LegalEntityAssociation::ChildLegalEntity::LegalStructure, Models::LegalEntityAssociation::ChildLegalEntity::RiskRating, Models::LegalEntityAssociation::RelationshipType, Models::LegalEntityAssociationCreateParams::RelationshipType, Models::LegalEntityCreateParams::LegalEntityAssociation::RelationshipType, Models::LegalEntityCreateParams::LegalEntityType, Models::LegalEntityCreateParams::LegalStructure, Models::LegalEntityCreateParams::RiskRating, Models::LegalEntityIndustryClassification::ClassificationType, Models::LegalEntityListParams::LegalEntityType, Models::LegalEntityUpdateParams::LegalStructure, Models::LegalEntityUpdateParams::RiskRating, Models::LegalEntityWealthEmploymentDetail::EmploymentStatus, Models::LegalEntityWealthEmploymentDetail::IncomeSource, Models::LegalEntityWealthEmploymentDetail::Industry, Models::LegalEntityWealthEmploymentDetail::Occupation, Models::LegalEntityWealthEmploymentDetail::SourceOfFunds, Models::LegalEntityWealthEmploymentDetail::WealthSource, Models::LineItem::ItemizableType, Models::LineItemListParams::ItemizableType, Models::LineItemRetrieveParams::ItemizableType, Models::LineItemUpdateParams::ItemizableType, Models::PaymentActionListParams::Status, Models::PaymentActionListParams::Type, Models::PaymentActionUpdateParams::Status, Models::PaymentFlow::Direction, Models::PaymentFlow::ExistingExternalAccountsFilter, Models::PaymentFlow::ExternalAccountCollection, Models::PaymentFlow::Status, Models::PaymentFlowCreateParams::Direction, Models::PaymentFlowUpdateParams::Status, Models::PaymentOrder::ChargeBearer, Models::PaymentOrder::CurrentHold::Object, Models::PaymentOrder::CurrentHold::Status, Models::PaymentOrder::CurrentHold::TargetType, Models::PaymentOrder::Direction, Models::PaymentOrder::ForeignExchangeIndicator, Models::PaymentOrder::Priority, Models::PaymentOrder::ReceivingAccountType, Models::PaymentOrder::ReconciliationStatus, Models::PaymentOrder::ReferenceNumber::ReferenceNumberType, Models::PaymentOrder::Status, Models::PaymentOrder::UltimateOriginatingAccountType, Models::PaymentOrderCreateAsyncParams::ChargeBearer, Models::PaymentOrderCreateAsyncParams::Direction, Models::PaymentOrderCreateAsyncParams::FallbackType, Models::PaymentOrderCreateAsyncParams::ForeignExchangeIndicator, Models::PaymentOrderCreateAsyncParams::Priority, Models::PaymentOrderCreateAsyncParams::ReceivingAccount::AccountDetail::AccountNumberType, Models::PaymentOrderCreateAsyncParams::ReceivingAccount::PartyType, Models::PaymentOrderCreateAsyncParams::ReceivingAccount::RoutingDetail::PaymentType, Models::PaymentOrderCreateAsyncParams::ReceivingAccount::RoutingDetail::RoutingNumberType, Models::PaymentOrderCreateAsyncParams::ReconciliationStatus, Models::PaymentOrderCreateParams::ChargeBearer, Models::PaymentOrderCreateParams::Direction, Models::PaymentOrderCreateParams::Document::DocumentableType, Models::PaymentOrderCreateParams::FallbackType, Models::PaymentOrderCreateParams::ForeignExchangeIndicator, Models::PaymentOrderCreateParams::Priority, Models::PaymentOrderCreateParams::ReceivingAccount::AccountDetail::AccountNumberType, Models::PaymentOrderCreateParams::ReceivingAccount::PartyType, Models::PaymentOrderCreateParams::ReceivingAccount::RoutingDetail::PaymentType, Models::PaymentOrderCreateParams::ReceivingAccount::RoutingDetail::RoutingNumberType, Models::PaymentOrderCreateParams::ReconciliationStatus, Models::PaymentOrderListParams::Priority, Models::PaymentOrderListParams::Status, Models::PaymentOrderListParams::Type, Models::PaymentOrderSubtype, Models::PaymentOrderType, Models::PaymentOrderUpdateParams::ChargeBearer, Models::PaymentOrderUpdateParams::Direction, Models::PaymentOrderUpdateParams::FallbackType, Models::PaymentOrderUpdateParams::ForeignExchangeIndicator, Models::PaymentOrderUpdateParams::Priority, Models::PaymentOrderUpdateParams::ReceivingAccount::AccountDetail::AccountNumberType, Models::PaymentOrderUpdateParams::ReceivingAccount::PartyType, Models::PaymentOrderUpdateParams::ReceivingAccount::RoutingDetail::PaymentType, Models::PaymentOrderUpdateParams::ReceivingAccount::RoutingDetail::RoutingNumberType, Models::PaymentOrderUpdateParams::ReconciliationStatus, Models::PaymentOrderUpdateParams::Status, Models::PaymentOrders::Reversal::Reason, Models::PaymentOrders::Reversal::ReconciliationStatus, Models::PaymentOrders::Reversal::Status, Models::PaymentOrders::ReversalCreateParams::Reason, Models::PaymentReference::ReferenceNumberType, Models::PaymentReference::ReferenceableType, Models::PaymentReferenceListParams::ReferenceableType, Models::ReconciliationRule::Direction, Models::ReconciliationRule::Type, Models::ReturnCreateParams::Code, Models::ReturnCreateParams::ReconciliationStatus, Models::ReturnCreateParams::ReturnableType, Models::ReturnListParams::ReturnableType, Models::ReturnObject::Code, Models::ReturnObject::ReconciliationStatus, Models::ReturnObject::ReferenceNumber::ReferenceNumberType, Models::ReturnObject::ReturnableType, Models::ReturnObject::Role, Models::ReturnObject::Status, Models::ReturnObject::Type, Models::RoutingDetail::PaymentType, Models::RoutingDetail::RoutingNumberType, Models::RoutingDetailCreateParams::AccountsType, Models::RoutingDetailCreateParams::PaymentType, Models::RoutingDetailCreateParams::RoutingNumberType, Models::RoutingDetailDeleteParams::AccountsType, Models::RoutingNumberLookupRequest::RoutingNumberType, Models::RoutingNumberLookupRequest::SupportedPaymentType, Models::Transaction::Type, Models::Transaction::VendorCodeType, Models::TransactionCreateParams::Type, Models::TransactionDirection, Models::Transactions::LineItemListParams::Type, Models::Transactions::TransactionLineItem::TransactableType, Models::Transactions::TransactionLineItem::Type, Models::ValidationValidateRoutingNumberParams::RoutingNumberType, Models::VirtualAccountCreateParams::AccountDetail::AccountNumberType, Models::VirtualAccountCreateParams::RoutingDetail::PaymentType, Models::VirtualAccountCreateParams::RoutingDetail::RoutingNumberType, Models::WealthAndEmploymentDetails::EmploymentStatus, Models::WealthAndEmploymentDetails::IncomeSource, Models::WealthAndEmploymentDetails::Industry, Models::WealthAndEmploymentDetails::Occupation, Models::WealthAndEmploymentDetails::SourceOfFunds, Models::WealthAndEmploymentDetails::WealthSource
- Defined in:
- lib/modern_treasury/internal/type/enum.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
A value from among a specified list of options. OpenAPI enum values map to Ruby values in the SDK as follows:
-
boolean => true | false
-
integer => Integer
-
float => Float
-
string => Symbol
We can therefore convert string values to Symbols, but can’t convert other values safely.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #===(other) ⇒ Boolean
-
#coerce(value, state:) ⇒ Symbol, Object
private
Unlike with primitives, ‘Enum` additionally validates that the value is a member of the enum.
- #dump(value, state: ) ⇒ Symbol, Object private
- #hash ⇒ Integer
- #inspect(depth: 0) ⇒ String private
- #to_sorbet_type ⇒ Object private
-
#values ⇒ Array<NilClass, Boolean, Integer, Float, Symbol>
private
All of the valid Symbol values for this enum.
Methods included from Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, to_sorbet_type
Methods included from Converter
coerce, dump, inspect, meta_info, new_coerce_state, type_info
Instance Method Details
#==(other) ⇒ Boolean
60 61 62 63 64 |
# File 'lib/modern_treasury/internal/type/enum.rb', line 60 def ==(other) # rubocop:disable Style/CaseEquality ModernTreasury::Internal::Type::Enum === other && other.values.to_set == values.to_set # rubocop:enable Style/CaseEquality end |
#===(other) ⇒ Boolean
53 |
# File 'lib/modern_treasury/internal/type/enum.rb', line 53 def ===(other) = values.include?(other) |
#coerce(value, state:) ⇒ Symbol, Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Unlike with primitives, ‘Enum` additionally validates that the value is a member of the enum.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/modern_treasury/internal/type/enum.rb', line 91 def coerce(value, state:) exactness = state.fetch(:exactness) val = value.is_a?(String) ? value.to_sym : value if values.include?(val) exactness[:yes] += 1 val elsif values.first&.class == val.class exactness[:maybe] += 1 value else exactness[:no] += 1 state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}") value end end |
#dump(value, state: ) ⇒ Symbol, Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
# File 'lib/modern_treasury/internal/type/enum.rb', line 108
|
#hash ⇒ Integer
69 |
# File 'lib/modern_treasury/internal/type/enum.rb', line 69 def hash = values.to_set.hash |
#inspect(depth: 0) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/modern_treasury/internal/type/enum.rb', line 139 def inspect(depth: 0) if depth.positive? return is_a?(Module) ? super() : self.class.name end members = values.map { ModernTreasury::Internal::Type::Converter.inspect(_1, depth: depth.succ) } prefix = is_a?(Module) ? name : self.class.name "#{prefix}[#{members.join(' | ')}]" end |
#to_sorbet_type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/modern_treasury/internal/type/enum.rb', line 122 def to_sorbet_type types = values.map { ModernTreasury::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq case types in [] T.noreturn in [type] type else T.any(*types) end end |
#values ⇒ Array<NilClass, Boolean, Integer, Float, Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
All of the valid Symbol values for this enum.
46 |
# File 'lib/modern_treasury/internal/type/enum.rb', line 46 def values = constants.map { const_get(_1) } |