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

- old
+ new

@@ -1,31 +1,35 @@ =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 # SMS message content class SMS # Text content of the SMS attr_accessor :text # Phone number or alphanumeric sender name attr_accessor :sender - # After how many minutes this channel is considered as failed and the next channel is attempted + # After how many minutes this channel is considered as failed and the next channel is attempted. Only one of \"ttl\" and \"validity\" can be used. attr_accessor :validity + # After how many seconds this channel is considered as failed and the next channel is attempted. Only one of \"ttl\" and \"validity\" can be used. + attr_accessor :ttl + # Defines how non-GSM characters will be treated: - \"on\" Use replacement settings from the account's [API Auto Replace settings page](https://dashboard.messente.com/api-settings/auto-replace) (default) - \"full\" All non GSM 03.38 characters will be replaced with suitable alternatives - \"off\" Message content is not modified in any way attr_accessor :autoconvert # hex-encoded string containing SMS UDH attr_accessor :udh @@ -59,22 +63,29 @@ def self.attribute_map { :'text' => :'text', :'sender' => :'sender', :'validity' => :'validity', + :'ttl' => :'ttl', :'autoconvert' => :'autoconvert', :'udh' => :'udh', :'channel' => :'channel' } end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + # Attribute type mapping. def self.openapi_types { :'text' => :'String', :'sender' => :'String', :'validity' => :'Integer', + :'ttl' => :'Integer', :'autoconvert' => :'String', :'udh' => :'String', :'channel' => :'String' } end @@ -100,20 +111,26 @@ h[k.to_sym] = v } if attributes.key?(:'text') self.text = attributes[:'text'] + else + self.text = nil end if attributes.key?(:'sender') self.sender = attributes[:'sender'] end if attributes.key?(:'validity') self.validity = attributes[:'validity'] end + if attributes.key?(:'ttl') + self.ttl = attributes[:'ttl'] + end + if attributes.key?(:'autoconvert') self.autoconvert = attributes[:'autoconvert'] end if attributes.key?(:'udh') @@ -128,10 +145,11 @@ end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @text.nil? invalid_properties.push('invalid value for "text", text cannot be nil.') end @@ -139,10 +157,11 @@ end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' return false if @text.nil? autoconvert_validator = EnumAttributeValidator.new('String', ["full", "on", "off"]) return false unless autoconvert_validator.valid?(@autoconvert) channel_validator = EnumAttributeValidator.new('String', ["sms"]) return false unless channel_validator.valid?(@channel) @@ -175,10 +194,11 @@ return true if self.equal?(o) self.class == o.class && text == o.text && sender == o.sender && validity == o.validity && + ttl == o.ttl && autoconvert == o.autoconvert && udh == o.udh && channel == o.channel end @@ -189,48 +209,44 @@ end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [text, sender, validity, autoconvert, udh, channel].hash + [text, sender, validity, ttl, autoconvert, udh, channel].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - - self + new(transformed_hash) end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data - def _deserialize(type, value) + def self._deserialize(type, value) case type.to_sym - when :DateTime - DateTime.parse(value) + when :Time + Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer @@ -256,11 +272,13 @@ value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model - MessenteApi.const_get(type).build_from_hash(value) + # models (e.g. Pet) or oneOf + klass = MessenteApi.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object @@ -282,11 +300,11 @@ value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end - + hash[param] = _to_hash(value) end hash end @@ -305,7 +323,9 @@ value.to_hash else value end end + end + end