lib/messente_api/models/channel.rb in messente_api-1.4.0 vs lib/messente_api/models/channel.rb in messente_api-2.1.0

- old
+ new

@@ -1,26 +1,31 @@ =begin #Messente API #[Messente](https://messente.com) is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds [tools](https://messente.com/documentation) to help organizations connect their services to people anywhere in the world. -The version of the OpenAPI document: 1.4.0 +The version of the OpenAPI document: 2.0.0 Contact: messente@messente.com Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 +Generator version: 7.6.0 =end require 'date' +require 'time' module MessenteApi class Channel SMS = "sms".freeze VIBER = "viber".freeze WHATSAPP = "whatsapp".freeze TELEGRAM = "telegram".freeze + def self.all_vars + @all_vars ||= [SMS, VIBER, WHATSAPP, TELEGRAM].freeze + end + # Builds the enum from string # @param [String] The enum value in the form of the string # @return [String] The enum value def self.build_from_hash(value) new.build_from_hash(value) @@ -28,11 +33,10 @@ # Builds the enum from string # @param [String] The enum value in the form of the string # @return [String] The enum value def build_from_hash(value) - constantValues = Channel.constants.select { |c| Channel::const_get(c) == value } - raise "Invalid ENUM value #{value} for class #Channel" if constantValues.empty? - value + return value if Channel.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #Channel" end end end