Class: Teleswagger::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/teleswagger/models/message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Message

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/teleswagger/models/message.rb', line 185

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?(:'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?(:'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

end

Instance Attribute Details

#audioObject

Returns the value of attribute audio.



42
43
44
# File 'lib/teleswagger/models/message.rb', line 42

def audio
  @audio
end

#author_signatureObject

Returns the value of attribute author_signature.



92
93
94
# File 'lib/teleswagger/models/message.rb', line 92

def author_signature
  @author_signature
end

#captionObject

Returns the value of attribute caption.



58
59
60
# File 'lib/teleswagger/models/message.rb', line 58

def caption
  @caption
end

#channel_chat_createdObject

Returns the value of attribute channel_chat_created.



80
81
82
# File 'lib/teleswagger/models/message.rb', line 80

def channel_chat_created
  @channel_chat_created
end

#chatObject

Returns the value of attribute chat.



24
25
26
# File 'lib/teleswagger/models/message.rb', line 24

def chat
  @chat
end

#contactObject

Returns the value of attribute contact.



60
61
62
# File 'lib/teleswagger/models/message.rb', line 60

def contact
  @contact
end

#dateObject

Returns the value of attribute date.



22
23
24
# File 'lib/teleswagger/models/message.rb', line 22

def date
  @date
end

#delete_chat_photoObject

Returns the value of attribute delete_chat_photo.



74
75
76
# File 'lib/teleswagger/models/message.rb', line 74

def delete_chat_photo
  @delete_chat_photo
end

#documentObject

Returns the value of attribute document.



44
45
46
# File 'lib/teleswagger/models/message.rb', line 44

def document
  @document
end

#edit_dateObject

Returns the value of attribute edit_date.



36
37
38
# File 'lib/teleswagger/models/message.rb', line 36

def edit_date
  @edit_date
end

#entitiesObject

Returns the value of attribute entities.



40
41
42
# File 'lib/teleswagger/models/message.rb', line 40

def entities
  @entities
end

#forward_dateObject

Returns the value of attribute forward_date.



32
33
34
# File 'lib/teleswagger/models/message.rb', line 32

def forward_date
  @forward_date
end

#forward_fromObject

Returns the value of attribute forward_from.



26
27
28
# File 'lib/teleswagger/models/message.rb', line 26

def forward_from
  @forward_from
end

#forward_from_chatObject

Returns the value of attribute forward_from_chat.



28
29
30
# File 'lib/teleswagger/models/message.rb', line 28

def forward_from_chat
  @forward_from_chat
end

#forward_from_message_idObject

Returns the value of attribute forward_from_message_id.



30
31
32
# File 'lib/teleswagger/models/message.rb', line 30

def forward_from_message_id
  @forward_from_message_id
end

#forward_signatureObject

Returns the value of attribute forward_signature.



90
91
92
# File 'lib/teleswagger/models/message.rb', line 90

def forward_signature
  @forward_signature
end

#fromObject

Returns the value of attribute from.



20
21
22
# File 'lib/teleswagger/models/message.rb', line 20

def from
  @from
end

#gameObject

Returns the value of attribute game.



46
47
48
# File 'lib/teleswagger/models/message.rb', line 46

def game
  @game
end

#group_chat_createdObject

Returns the value of attribute group_chat_created.



76
77
78
# File 'lib/teleswagger/models/message.rb', line 76

def group_chat_created
  @group_chat_created
end

#left_chat_memberObject

Returns the value of attribute left_chat_member.



68
69
70
# File 'lib/teleswagger/models/message.rb', line 68

def left_chat_member
  @left_chat_member
end

#locationObject

Returns the value of attribute location.



62
63
64
# File 'lib/teleswagger/models/message.rb', line 62

def location
  @location
end

#message_idObject

Returns the value of attribute message_id.



18
19
20
# File 'lib/teleswagger/models/message.rb', line 18

def message_id
  @message_id
end

#migrate_from_chat_idObject

Returns the value of attribute migrate_from_chat_id.



84
85
86
# File 'lib/teleswagger/models/message.rb', line 84

def migrate_from_chat_id
  @migrate_from_chat_id
end

#migrate_to_chat_idObject

Returns the value of attribute migrate_to_chat_id.



82
83
84
# File 'lib/teleswagger/models/message.rb', line 82

def migrate_to_chat_id
  @migrate_to_chat_id
end

#new_chat_membersObject

Returns the value of attribute new_chat_members.



66
67
68
# File 'lib/teleswagger/models/message.rb', line 66

def new_chat_members
  @new_chat_members
end

#new_chat_photoObject

Returns the value of attribute new_chat_photo.



72
73
74
# File 'lib/teleswagger/models/message.rb', line 72

def new_chat_photo
  @new_chat_photo
end

#new_chat_titleObject

Returns the value of attribute new_chat_title.



70
71
72
# File 'lib/teleswagger/models/message.rb', line 70

def new_chat_title
  @new_chat_title
end

#photoObject

Returns the value of attribute photo.



48
49
50
# File 'lib/teleswagger/models/message.rb', line 48

def photo
  @photo
end

#pinned_messageObject

Returns the value of attribute pinned_message.



86
87
88
# File 'lib/teleswagger/models/message.rb', line 86

def pinned_message
  @pinned_message
end

#reply_to_messageObject

Returns the value of attribute reply_to_message.



34
35
36
# File 'lib/teleswagger/models/message.rb', line 34

def reply_to_message
  @reply_to_message
end

#stickerObject

Returns the value of attribute sticker.



50
51
52
# File 'lib/teleswagger/models/message.rb', line 50

def sticker
  @sticker
end

#successful_paymentObject

Returns the value of attribute successful_payment.



88
89
90
# File 'lib/teleswagger/models/message.rb', line 88

def successful_payment
  @successful_payment
end

#supergroup_chat_createdObject

Returns the value of attribute supergroup_chat_created.



78
79
80
# File 'lib/teleswagger/models/message.rb', line 78

def supergroup_chat_created
  @supergroup_chat_created
end

#textObject

Returns the value of attribute text.



38
39
40
# File 'lib/teleswagger/models/message.rb', line 38

def text
  @text
end

#venueObject

Returns the value of attribute venue.



64
65
66
# File 'lib/teleswagger/models/message.rb', line 64

def venue
  @venue
end

#videoObject

Returns the value of attribute video.



52
53
54
# File 'lib/teleswagger/models/message.rb', line 52

def video
  @video
end

#video_noteObject

Returns the value of attribute video_note.



56
57
58
# File 'lib/teleswagger/models/message.rb', line 56

def video_note
  @video_note
end

#voiceObject

Returns the value of attribute voice.



54
55
56
# File 'lib/teleswagger/models/message.rb', line 54

def voice
  @voice
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/teleswagger/models/message.rb', line 96

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',
    :'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',
    :'successful_payment' => :'successful_payment',
    :'forward_signature' => :'forward_signature',
    :'author_signature' => :'author_signature'
  }
end

.swagger_typesObject

Attribute type mapping.



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/teleswagger/models/message.rb', line 140

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>',
    :'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',
    :'successful_payment' => :'SuccessfulPayment',
    :'forward_signature' => :'String',
    :'author_signature' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/teleswagger/models/message.rb', line 368

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 &&
      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 &&
      successful_payment == o.successful_payment &&
      forward_signature == o.forward_signature &&
      author_signature == o.author_signature
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/teleswagger/models/message.rb', line 447

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 =~ /\A(true|t|yes|y|1)\z/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

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/teleswagger/models/message.rb', line 513

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

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/teleswagger/models/message.rb', line 426

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/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

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


413
414
415
# File 'lib/teleswagger/models/message.rb', line 413

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



419
420
421
# File 'lib/teleswagger/models/message.rb', line 419

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, 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, successful_payment, forward_signature, author_signature].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properies with the reasons



355
356
357
358
# File 'lib/teleswagger/models/message.rb', line 355

def list_invalid_properties
  invalid_properties = Array.new
  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



493
494
495
# File 'lib/teleswagger/models/message.rb', line 493

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



499
500
501
502
503
504
505
506
507
# File 'lib/teleswagger/models/message.rb', line 499

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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



487
488
489
# File 'lib/teleswagger/models/message.rb', line 487

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



362
363
364
# File 'lib/teleswagger/models/message.rb', line 362

def valid?
  return true
end