lib/messente_api/models/viber.rb in messente_api-1.4.0 vs lib/messente_api/models/viber.rb in messente_api-2.1.0
- old
+ new
@@ -1,28 +1,32 @@
=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
# Viber message content
class Viber
# 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
+
# Plaintext content for Viber
attr_accessor :text
# URL for the embedded image Valid combinations: 1) image_url, 2) text, image_url, button_url, button_text
attr_accessor :image_url
@@ -61,23 +65,30 @@
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'sender' => :'sender',
:'validity' => :'validity',
+ :'ttl' => :'ttl',
:'text' => :'text',
:'image_url' => :'image_url',
:'button_url' => :'button_url',
:'button_text' => :'button_text',
:'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',
+ :'ttl' => :'Integer',
:'text' => :'String',
:'image_url' => :'String',
:'button_url' => :'String',
:'button_text' => :'String',
:'channel' => :'String'
@@ -111,10 +122,14 @@
if attributes.key?(:'validity')
self.validity = attributes[:'validity']
end
+ if attributes.key?(:'ttl')
+ self.ttl = attributes[:'ttl']
+ end
+
if attributes.key?(:'text')
self.text = attributes[:'text']
end
if attributes.key?(:'image_url')
@@ -137,17 +152,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', ["viber"])
return false unless channel_validator.valid?(@channel)
true
end
@@ -166,10 +183,11 @@
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
sender == o.sender &&
validity == o.validity &&
+ ttl == o.ttl &&
text == o.text &&
image_url == o.image_url &&
button_url == o.button_url &&
button_text == o.button_text &&
channel == o.channel
@@ -182,48 +200,44 @@
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
- [sender, validity, text, image_url, button_url, button_text, channel].hash
+ [sender, validity, ttl, text, image_url, button_url, button_text, 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
@@ -249,11 +263,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 +291,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 +314,9 @@
value.to_hash
else
value
end
end
+
end
+
end