class Teleswagger::Message
Attributes
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/teleswagger/models/message.rb, line 113 def self.attribute_map { :'message_id' => :'message_id', :'from' => :'from', :'date' => :'date', :'chat' => :'chat', :'forward_from' => :'forward_from', :'forward_from_chat' => :'forward_from_chat', :'forward_from_message_id' => :'forward_from_message_id', :'forward_date' => :'forward_date', :'reply_to_message' => :'reply_to_message', :'edit_date' => :'edit_date', :'text' => :'text', :'entities' => :'entities', :'caption_entities' => :'caption_entities', :'audio' => :'audio', :'document' => :'document', :'game' => :'game', :'photo' => :'photo', :'sticker' => :'sticker', :'video' => :'video', :'voice' => :'voice', :'video_note' => :'video_note', :'caption' => :'caption', :'contact' => :'contact', :'location' => :'location', :'venue' => :'venue', :'new_chat_members' => :'new_chat_members', :'left_chat_member' => :'left_chat_member', :'new_chat_title' => :'new_chat_title', :'new_chat_photo' => :'new_chat_photo', :'delete_chat_photo' => :'delete_chat_photo', :'group_chat_created' => :'group_chat_created', :'supergroup_chat_created' => :'supergroup_chat_created', :'channel_chat_created' => :'channel_chat_created', :'migrate_to_chat_id' => :'migrate_to_chat_id', :'migrate_from_chat_id' => :'migrate_from_chat_id', :'pinned_message' => :'pinned_message', :'invoice' => :'invoice', :'successful_payment' => :'successful_payment', :'forward_signature' => :'forward_signature', :'author_signature' => :'author_signature', :'connected_website' => :'connected_website' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/teleswagger/models/message.rb, line 208 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} if attributes.has_key?(:'message_id') self.message_id = attributes[:'message_id'] end if attributes.has_key?(:'from') self.from = attributes[:'from'] end if attributes.has_key?(:'date') self.date = attributes[:'date'] end if attributes.has_key?(:'chat') self.chat = attributes[:'chat'] end if attributes.has_key?(:'forward_from') self.forward_from = attributes[:'forward_from'] end if attributes.has_key?(:'forward_from_chat') self.forward_from_chat = attributes[:'forward_from_chat'] end if attributes.has_key?(:'forward_from_message_id') self.forward_from_message_id = attributes[:'forward_from_message_id'] end if attributes.has_key?(:'forward_date') self.forward_date = attributes[:'forward_date'] end if attributes.has_key?(:'reply_to_message') self.reply_to_message = attributes[:'reply_to_message'] end if attributes.has_key?(:'edit_date') self.edit_date = attributes[:'edit_date'] end if attributes.has_key?(:'text') self.text = attributes[:'text'] end if attributes.has_key?(:'entities') if (value = attributes[:'entities']).is_a?(Array) self.entities = value end end if attributes.has_key?(:'caption_entities') if (value = attributes[:'caption_entities']).is_a?(Array) self.caption_entities = value end end if attributes.has_key?(:'audio') self.audio = attributes[:'audio'] end if attributes.has_key?(:'document') self.document = attributes[:'document'] end if attributes.has_key?(:'game') self.game = attributes[:'game'] end if attributes.has_key?(:'photo') if (value = attributes[:'photo']).is_a?(Array) self.photo = value end end if attributes.has_key?(:'sticker') self.sticker = attributes[:'sticker'] end if attributes.has_key?(:'video') self.video = attributes[:'video'] end if attributes.has_key?(:'voice') self.voice = attributes[:'voice'] end if attributes.has_key?(:'video_note') self.video_note = attributes[:'video_note'] end if attributes.has_key?(:'caption') self.caption = attributes[:'caption'] end if attributes.has_key?(:'contact') self.contact = attributes[:'contact'] end if attributes.has_key?(:'location') self.location = attributes[:'location'] end if attributes.has_key?(:'venue') self.venue = attributes[:'venue'] end if attributes.has_key?(:'new_chat_members') if (value = attributes[:'new_chat_members']).is_a?(Array) self.new_chat_members = value end end if attributes.has_key?(:'left_chat_member') self.left_chat_member = attributes[:'left_chat_member'] end if attributes.has_key?(:'new_chat_title') self.new_chat_title = attributes[:'new_chat_title'] end if attributes.has_key?(:'new_chat_photo') if (value = attributes[:'new_chat_photo']).is_a?(Array) self.new_chat_photo = value end end if attributes.has_key?(:'delete_chat_photo') self.delete_chat_photo = attributes[:'delete_chat_photo'] end if attributes.has_key?(:'group_chat_created') self.group_chat_created = attributes[:'group_chat_created'] end if attributes.has_key?(:'supergroup_chat_created') self.supergroup_chat_created = attributes[:'supergroup_chat_created'] end if attributes.has_key?(:'channel_chat_created') self.channel_chat_created = attributes[:'channel_chat_created'] end if attributes.has_key?(:'migrate_to_chat_id') self.migrate_to_chat_id = attributes[:'migrate_to_chat_id'] end if attributes.has_key?(:'migrate_from_chat_id') self.migrate_from_chat_id = attributes[:'migrate_from_chat_id'] end if attributes.has_key?(:'pinned_message') self.pinned_message = attributes[:'pinned_message'] end if attributes.has_key?(:'invoice') self.invoice = attributes[:'invoice'] end if attributes.has_key?(:'successful_payment') self.successful_payment = attributes[:'successful_payment'] end if attributes.has_key?(:'forward_signature') self.forward_signature = attributes[:'forward_signature'] end if attributes.has_key?(:'author_signature') self.author_signature = attributes[:'author_signature'] end if attributes.has_key?(:'connected_website') self.connected_website = attributes[:'connected_website'] end end
Attribute type mapping.
# File lib/teleswagger/models/message.rb, line 160 def self.swagger_types { :'message_id' => :'Integer', :'from' => :'User', :'date' => :'Integer', :'chat' => :'Chat', :'forward_from' => :'User', :'forward_from_chat' => :'Chat', :'forward_from_message_id' => :'Integer', :'forward_date' => :'Integer', :'reply_to_message' => :'Message', :'edit_date' => :'Integer', :'text' => :'String', :'entities' => :'Array<MessageEntity>', :'caption_entities' => :'Array<MessageEntity>', :'audio' => :'Audio', :'document' => :'Document', :'game' => :'Game', :'photo' => :'Array<PhotoSize>', :'sticker' => :'Sticker', :'video' => :'Video', :'voice' => :'Voice', :'video_note' => :'VideoNote', :'caption' => :'String', :'contact' => :'Contact', :'location' => :'Location', :'venue' => :'Venue', :'new_chat_members' => :'Array<User>', :'left_chat_member' => :'User', :'new_chat_title' => :'String', :'new_chat_photo' => :'Array<PhotoSize>', :'delete_chat_photo' => :'BOOLEAN', :'group_chat_created' => :'BOOLEAN', :'supergroup_chat_created' => :'BOOLEAN', :'channel_chat_created' => :'BOOLEAN', :'migrate_to_chat_id' => :'Integer', :'migrate_from_chat_id' => :'Integer', :'pinned_message' => :'Message', :'invoice' => :'Invoice', :'successful_payment' => :'SuccessfulPayment', :'forward_signature' => :'String', :'author_signature' => :'String', :'connected_website' => :'String' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/teleswagger/models/message.rb, line 405 def ==(o) return true if self.equal?(o) self.class == o.class && message_id == o.message_id && from == o.from && date == o.date && chat == o.chat && forward_from == o.forward_from && forward_from_chat == o.forward_from_chat && forward_from_message_id == o.forward_from_message_id && forward_date == o.forward_date && reply_to_message == o.reply_to_message && edit_date == o.edit_date && text == o.text && entities == o.entities && caption_entities == o.caption_entities && audio == o.audio && document == o.document && game == o.game && photo == o.photo && sticker == o.sticker && video == o.video && voice == o.voice && video_note == o.video_note && caption == o.caption && contact == o.contact && location == o.location && venue == o.venue && new_chat_members == o.new_chat_members && left_chat_member == o.left_chat_member && new_chat_title == o.new_chat_title && new_chat_photo == o.new_chat_photo && delete_chat_photo == o.delete_chat_photo && group_chat_created == o.group_chat_created && supergroup_chat_created == o.supergroup_chat_created && channel_chat_created == o.channel_chat_created && migrate_to_chat_id == o.migrate_to_chat_id && migrate_from_chat_id == o.migrate_from_chat_id && pinned_message == o.pinned_message && invoice == o.invoice && successful_payment == o.successful_payment && forward_signature == o.forward_signature && author_signature == o.author_signature && connected_website == o.connected_website end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/teleswagger/models/message.rb, line 487 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /^(true|t|yes|y|1)$/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = Teleswagger.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/teleswagger/models/message.rb, line 553 def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/teleswagger/models/message.rb, line 466 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i # check to ensure the input is an array given that the 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) } ) 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 end self end
@see the `==` method @param [Object] Object to be compared
# File lib/teleswagger/models/message.rb, line 453 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/teleswagger/models/message.rb, line 459 def hash [message_id, from, date, chat, forward_from, forward_from_chat, forward_from_message_id, forward_date, reply_to_message, edit_date, text, entities, caption_entities, audio, document, game, photo, sticker, video, voice, video_note, caption, contact, location, venue, new_chat_members, left_chat_member, new_chat_title, new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created, migrate_to_chat_id, migrate_from_chat_id, pinned_message, invoice, successful_payment, forward_signature, author_signature, connected_website].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properies with the reasons
# File lib/teleswagger/models/message.rb, line 392 def list_invalid_properties invalid_properties = Array.new return invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/teleswagger/models/message.rb, line 539 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/teleswagger/models/message.rb, line 527 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/teleswagger/models/message.rb, line 399 def valid? return true end