lib/messente_api/models/telegram.rb in messente_api-1.4.0 vs lib/messente_api/models/telegram.rb in messente_api-2.1.0
- old
+ new
@@ -1,18 +1,19 @@
=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
# Telegram message content
class Telegram
# Phone number or alphanumeric sender name
@@ -69,10 +70,15 @@
:'audio_url' => :'audio_url',
:'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
{
:'sender' => :'String',
:'validity' => :'Integer',
@@ -137,17 +143,19 @@
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
invalid_properties
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'
channel_validator = EnumAttributeValidator.new('String', ["telegram"])
return false unless channel_validator.valid?(@channel)
true
end
@@ -189,41 +197,37 @@
# 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
@@ -249,11 +253,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
@@ -275,11 +281,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
@@ -298,7 +304,9 @@
value.to_hash
else
value
end
end
+
end
+
end