Module: FinchAPI::Internal::Type::Enum Private

Includes:
Converter, Util::SorbetRuntimeSupport
Included in:
Models::AccountUpdateEvent::Data::AuthenticationMethod::Type, Models::AccountUpdateEvent::EventType, Models::CompanyEvent::EventType, Models::Connect::SessionNewParams::Integration::AuthMethod, Models::Connect::SessionNewParams::Product, Models::Connect::SessionNewParams::Sandbox, Models::Connect::SessionReauthenticateParams::Product, Models::ConnectionStatusType, Models::CreateAccessTokenResponse::ClientType, Models::CreateAccessTokenResponse::ConnectionType, Models::DirectoryEvent::EventType, Models::EmploymentEvent::EventType, Models::HRIS::BenefitContribution::Type, Models::HRIS::BenefitCreateParams::CompanyContribution::Type, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::CompanyContribution, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::EmployeeDeduction, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::HsaContributionLimit, Models::HRIS::BenefitFrequency, Models::HRIS::BenefitListSupportedBenefitsResponse::CompanyContribution, Models::HRIS::BenefitListSupportedBenefitsResponse::EmployeeDeduction, Models::HRIS::BenefitListSupportedBenefitsResponse::HsaContributionLimit, Models::HRIS::BenefitType, Models::HRIS::Benefits::IndividualBenefit::Body::HsaContributionLimit, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::AnnualContributionLimit, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::CompanyContribution::Type, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::EmployeeDeduction::Type, Models::HRIS::Company::PayStatementItem::RuleCreateParams::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleCreateParams::EntityType, Models::HRIS::Company::PayStatementItem::RuleCreateResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleCreateResponse::EntityType, Models::HRIS::Company::PayStatementItem::RuleDeleteResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleDeleteResponse::EntityType, Models::HRIS::Company::PayStatementItem::RuleListResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleListResponse::EntityType, Models::HRIS::Company::PayStatementItem::RuleUpdateResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleUpdateResponse::EntityType, Models::HRIS::Company::PayStatementItemListParams::Category, Models::HRIS::Company::PayStatementItemListResponse::Category, Models::HRIS::CompanyBenefit::CompanyContribution::Type, Models::HRIS::DocumentListParams::Type, Models::HRIS::DocumentResponse::Type, Models::HRIS::EmploymentData::UnionMember0::Employment::Subtype, Models::HRIS::EmploymentData::UnionMember0::Employment::Type, Models::HRIS::EmploymentData::UnionMember0::EmploymentStatus, Models::HRIS::HRISCompany::Account::AccountType, Models::HRIS::HRISCompany::Entity::Subtype, Models::HRIS::HRISCompany::Entity::Type, Models::HRIS::Individual::UnionMember0::Email::Type, Models::HRIS::Individual::UnionMember0::Ethnicity, Models::HRIS::Individual::UnionMember0::Gender, Models::HRIS::Individual::UnionMember0::PhoneNumber::Type, Models::HRIS::PayStatement::Earning::Type, Models::HRIS::PayStatement::PaymentMethod, Models::HRIS::PayStatement::Tax::Type, Models::HRIS::PayStatement::Type, Models::HRIS::Payment::PayFrequency, Models::HRIS::SupportedBenefit::CompanyContribution, Models::HRIS::SupportedBenefit::EmployeeDeduction, Models::HRIS::SupportedBenefit::HsaContributionLimit, Models::HRIS::W42005::Data::Exemption, Models::HRIS::W42005::Data::FilingStatus, Models::HRIS::W42005::Type, Models::HRIS::W42020::Data::FilingStatus, Models::HRIS::W42020::Type, Models::Income::Unit, Models::IndividualEvent::EventType, Models::Introspection::AuthenticationMethod::Type, Models::Introspection::ClientType, Models::Introspection::ConnectionType, Models::JobCompletionEvent::EventType, Models::Jobs::AutomatedAsyncJob::Status, Models::Jobs::AutomatedAsyncJob::Type, Models::Jobs::AutomatedCreateParams::Type, Models::Jobs::ManualAsyncJob::Status, Models::OperationSupport, Models::PayStatementEvent::EventType, Models::PaymentEvent::EventType, Models::Payroll::PayGroupListResponse::PayFrequency, Models::Payroll::PayGroupRetrieveResponse::PayFrequency, Models::Provider::AuthenticationMethod::Type, Models::Sandbox::CompanyUpdateParams::Account::AccountType, Models::Sandbox::CompanyUpdateParams::Entity::Subtype, Models::Sandbox::CompanyUpdateParams::Entity::Type, Models::Sandbox::CompanyUpdateResponse::Account::AccountType, Models::Sandbox::CompanyUpdateResponse::Entity::Subtype, Models::Sandbox::CompanyUpdateResponse::Entity::Type, Models::Sandbox::ConnectionCreateParams::AuthenticationType, Models::Sandbox::ConnectionCreateResponse::AuthenticationType, Models::Sandbox::Connections::AccountCreateParams::AuthenticationType, Models::Sandbox::Connections::AccountCreateResponse::AuthenticationType, Models::Sandbox::Connections::AccountUpdateResponse::AuthenticationType, Models::Sandbox::DirectoryCreateParams::Body::Email::Type, Models::Sandbox::DirectoryCreateParams::Body::Employment::Subtype, Models::Sandbox::DirectoryCreateParams::Body::Employment::Type, Models::Sandbox::DirectoryCreateParams::Body::EmploymentStatus, Models::Sandbox::DirectoryCreateParams::Body::Ethnicity, Models::Sandbox::DirectoryCreateParams::Body::Gender, Models::Sandbox::DirectoryCreateParams::Body::PhoneNumber::Type, Models::Sandbox::EmploymentUpdateParams::Employment::Subtype, Models::Sandbox::EmploymentUpdateParams::Employment::Type, Models::Sandbox::EmploymentUpdateParams::EmploymentStatus, Models::Sandbox::EmploymentUpdateResponse::Employment::Subtype, Models::Sandbox::EmploymentUpdateResponse::Employment::Type, Models::Sandbox::EmploymentUpdateResponse::EmploymentStatus, Models::Sandbox::IndividualUpdateParams::Email::Type, Models::Sandbox::IndividualUpdateParams::Ethnicity, Models::Sandbox::IndividualUpdateParams::Gender, Models::Sandbox::IndividualUpdateParams::PhoneNumber::Type, Models::Sandbox::IndividualUpdateResponse::Email::Type, Models::Sandbox::IndividualUpdateResponse::Ethnicity, Models::Sandbox::IndividualUpdateResponse::Gender, Models::Sandbox::IndividualUpdateResponse::PhoneNumber::Type, Models::Sandbox::JobCreateParams::Type, Models::Sandbox::Jobs::SandboxJobConfiguration::CompletionStatus, Models::Sandbox::Jobs::SandboxJobConfiguration::Type, Models::Sandbox::PaymentCreateParams::PayStatement::Earning::Type, Models::Sandbox::PaymentCreateParams::PayStatement::PaymentMethod, Models::Sandbox::PaymentCreateParams::PayStatement::Tax::Type, Models::Sandbox::PaymentCreateParams::PayStatement::Type
Defined in:
lib/finch_api/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:

  1. boolean => true | false

  2. integer => Integer

  3. float => Float

  4. string => Symbol

We can therefore convert string values to Symbols, but can’t convert other values safely.

Examples:

# `connection_status_type` is a `FinchAPI::ConnectionStatusType`
case connection_status_type
when FinchAPI::ConnectionStatusType::PENDING
  # ...
when FinchAPI::ConnectionStatusType::PROCESSING
  # ...
when FinchAPI::ConnectionStatusType::CONNECTED
  # ...
else
  puts(connection_status_type)
end
case connection_status_type
in :pending
  # ...
in :processing
  # ...
in :connected
  # ...
else
  puts(connection_status_type)
end

Instance Method Summary collapse

Methods included from Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!

Methods included from Converter

coerce, dump, inspect, type_info

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:



64
65
66
67
68
# File 'lib/finch_api/internal/type/enum.rb', line 64

def ==(other)
  # rubocop:disable Style/CaseEquality
  FinchAPI::Internal::Type::Enum === other && other.values.to_set == values.to_set
  # rubocop:enable Style/CaseEquality
end

#===(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:



57
# File 'lib/finch_api/internal/type/enum.rb', line 57

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.

Parameters:

  • value (String, Symbol, Object)
  • state (Hash{Symbol=>Object})

    .

    @option state [Boolean, :strong] :strictness

    @option state [HashSymbol=>Object] :exactness

    @option state [Integer] :branched

Returns:

  • (Symbol, Object)


91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/finch_api/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
  else
    exactness[values.first&.class == val.class ? :maybe : :no] += 1
    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.

Parameters:

  • value (Symbol, Object)
  • state (Hash{Symbol=>Object}) (defaults to: )

    .

    @option state [Boolean] :can_retry

Returns:

  • (Symbol, Object)


# File 'lib/finch_api/internal/type/enum.rb', line 104

#hashInteger

Returns:

  • (Integer)


73
# File 'lib/finch_api/internal/type/enum.rb', line 73

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.

Parameters:

  • depth (Integer) (defaults to: 0)

Returns:

  • (String)


120
121
122
123
124
125
126
127
128
129
# File 'lib/finch_api/internal/type/enum.rb', line 120

def inspect(depth: 0)
  if depth.positive?
    return is_a?(Module) ? super() : self.class.name
  end

  members = values.map { FinchAPI::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
  prefix = is_a?(Module) ? name : self.class.name

  "#{prefix}[#{members.join(' | ')}]"
end

#valuesArray<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.

Returns:

  • (Array<NilClass, Boolean, Integer, Float, Symbol>)


50
# File 'lib/finch_api/internal/type/enum.rb', line 50

def values = constants.map { const_get(_1) }