Module: FinchAPI::Type::Enum Private

Includes:
Converter
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::BenefitFeaturesAndOperations::SupportedFeatures::CompanyContribution, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::EmployeeDeduction, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::HsaContributionLimit, Models::HRIS::BenefitFrequency, Models::HRIS::BenefitType, Models::HRIS::Benefits::EnrolledIndividual::Code, 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::DocumentListParams::Type, Models::HRIS::DocumentResponse::Type, Models::HRIS::EmploymentData::Employment::Subtype, Models::HRIS::EmploymentData::Employment::Type, Models::HRIS::EmploymentData::EmploymentStatus, Models::HRIS::HRISCompany::Account::AccountType, Models::HRIS::HRISCompany::Entity::Subtype, Models::HRIS::HRISCompany::Entity::Type, Models::HRIS::Individual::Email::Type, Models::HRIS::Individual::Ethnicity, Models::HRIS::Individual::Gender, Models::HRIS::Individual::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/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::Models::ConnectionStatusType`
case connection_status_type
when FinchAPI::Models::ConnectionStatusType::PENDING
  # ...
when FinchAPI::Models::ConnectionStatusType::PROCESSING
  # ...
when FinchAPI::Models::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 Converter

coerce, dump, type_info

Instance Method Details

#==(other) ⇒ Boolean

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:

  • other (Object)

Returns:

  • (Boolean)


63
64
65
# File 'lib/finch-api/type/enum.rb', line 63

def ==(other)
  other.is_a?(Module) && other.singleton_class <= FinchAPI::Enum && other.values.to_set == values.to_set
end

#===(other) ⇒ Boolean

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:

  • other (Object)

Returns:

  • (Boolean)


58
# File 'lib/finch-api/type/enum.rb', line 58

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)


83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/finch-api/type/enum.rb', line 83

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) ⇒ 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)

Returns:

  • (Symbol, Object)


6
# File 'lib/finch-api/type/enum.rb', line 6

def dump(value) = super

#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>)


48
# File 'lib/finch-api/type/enum.rb', line 48

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