Class: LobbyingDisclosureClient::Util::ConstantsValidator
- Inherits:
-
Object
- Object
- LobbyingDisclosureClient::Util::ConstantsValidator
- Extended by:
- T::Sig
- Defined in:
- lib/lobbying_disclosure_client/util/constants_validator.rb
Defined Under Namespace
Classes: InvalidEnumError, ItemToValidate
Constant Summary collapse
- ITEMS_TO_VALIDATE =
T.let( [ ItemToValidate.new( enum_klass: LobbyingDisclosureClient::Enums::ContributionType, api_klass: LobbyingDisclosureClient::V1::Constants::Contribution::ListContributionItemTypes ), ItemToValidate.new( enum_klass: LobbyingDisclosureClient::Enums::FilingType, api_klass: LobbyingDisclosureClient::V1::Constants::Filing::ListFilingTypes ), ItemToValidate.new( enum_klass: LobbyingDisclosureClient::Enums::GeneralIssueCode, api_klass: LobbyingDisclosureClient::V1::Constants::Filing::ListLobbyingActivityGeneralIssues ), ItemToValidate.new( enum_klass: LobbyingDisclosureClient::Enums::Country, api_klass: LobbyingDisclosureClient::V1::Constants::General::ListCountries ), ItemToValidate.new( enum_klass: LobbyingDisclosureClient::Enums::State, api_klass: LobbyingDisclosureClient::V1::Constants::General::ListStates ), ItemToValidate.new( enum_klass: LobbyingDisclosureClient::Enums::Prefix, api_klass: LobbyingDisclosureClient::V1::Constants::Lobbyist::ListLobbyistPrefixes ), ItemToValidate.new( enum_klass: LobbyingDisclosureClient::Enums::Suffix, api_klass: LobbyingDisclosureClient::V1::Constants::Lobbyist::ListLobbyistSuffixes ) ].freeze, T::Array[ItemToValidate] )
- VALUES_RETURNED_BY_API_EMPIRICALLY_BUT_NOT_INCLUDED_IN_CONSTANTS_ENDPOINTS =
T.let( { LobbyingDisclosureClient::Enums::Country => [ LobbyingDisclosureClient::Enums::Country::Blank.serialize ] }.freeze, T::Hash[T.class_of(T::Enum), T::Array[String]] )
Class Method Summary collapse
Class Method Details
.validate! ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/lobbying_disclosure_client/util/constants_validator.rb', line 69 def validate! validation_results = ITEMS_TO_VALIDATE.map do |item_to_validate| enum_is_in_sync_with_live_api_result?(item_to_validate) end if validation_results.all? puts 'All enums passed validation 🏆🏆🏆' else puts 'Some enums failed validation ⛈️⛈️⛈️' raise InvalidEnumError end end |