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



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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# 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

Instance Attribute Details

#audioObject

Returns the value of attribute audio.



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

def audio
  @audio
end

#author_signatureObject

Returns the value of attribute author_signature.



107
108
109
# File 'lib/teleswagger/models/message.rb', line 107

def author_signature
  @author_signature
end

#captionObject

Returns the value of attribute caption.



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

def caption
  @caption
end

#caption_entitiesObject

Returns the value of attribute caption_entities.



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

def caption_entities
  @caption_entities
end

#channel_chat_createdObject

Returns the value of attribute channel_chat_created.



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

def channel_chat_created
  @channel_chat_created
end

#chatObject

Returns the value of attribute chat.



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

def chat
  @chat
end

#connected_websiteObject

Returns the value of attribute connected_website.



109
110
111
# File 'lib/teleswagger/models/message.rb', line 109

def connected_website
  @connected_website
end

#contactObject

Returns the value of attribute contact.



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

def contact
  @contact
end

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#delete_chat_photoObject

Returns the value of attribute delete_chat_photo.



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

def delete_chat_photo
  @delete_chat_photo
end

#documentObject

Returns the value of attribute document.



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

def document
  @document
end

#edit_dateObject

Returns the value of attribute edit_date.



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

def edit_date
  @edit_date
end

#entitiesObject

Returns the value of attribute entities.



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

def entities
  @entities
end

#forward_dateObject

Returns the value of attribute forward_date.



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

def forward_date
  @forward_date
end

#forward_fromObject

Returns the value of attribute forward_from.



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

def forward_from
  @forward_from
end

#forward_from_chatObject

Returns the value of attribute forward_from_chat.



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

def forward_from_chat
  @forward_from_chat
end

#forward_from_message_idObject

Returns the value of attribute forward_from_message_id.



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

def forward_from_message_id
  @forward_from_message_id
end

#forward_signatureObject

Returns the value of attribute forward_signature.



105
106
107
# File 'lib/teleswagger/models/message.rb', line 105

def forward_signature
  @forward_signature
end

#fromObject

Returns the value of attribute from.



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

def from
  @from
end

#gameObject

Returns the value of attribute game.



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

def game
  @game
end

#group_chat_createdObject

Returns the value of attribute group_chat_created.



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

def group_chat_created
  @group_chat_created
end

#invoiceObject

Returns the value of attribute invoice.



101
102
103
# File 'lib/teleswagger/models/message.rb', line 101

def invoice
  @invoice
end

#left_chat_memberObject

Returns the value of attribute left_chat_member.



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

def left_chat_member
  @left_chat_member
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#message_idObject

Returns the value of attribute message_id.



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

def message_id
  @message_id
end

#migrate_from_chat_idObject

Returns the value of attribute migrate_from_chat_id.



97
98
99
# File 'lib/teleswagger/models/message.rb', line 97

def migrate_from_chat_id
  @migrate_from_chat_id
end

#migrate_to_chat_idObject

Returns the value of attribute migrate_to_chat_id.



95
96
97
# File 'lib/teleswagger/models/message.rb', line 95

def migrate_to_chat_id
  @migrate_to_chat_id
end

#new_chat_membersObject

Returns the value of attribute new_chat_members.



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

def new_chat_members
  @new_chat_members
end

#new_chat_photoObject

Returns the value of attribute new_chat_photo.



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

def new_chat_photo
  @new_chat_photo
end

#new_chat_titleObject

Returns the value of attribute new_chat_title.



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

def new_chat_title
  @new_chat_title
end

#photoObject

Returns the value of attribute photo.



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

def photo
  @photo
end

#pinned_messageObject

Returns the value of attribute pinned_message.



99
100
101
# File 'lib/teleswagger/models/message.rb', line 99

def pinned_message
  @pinned_message
end

#reply_to_messageObject

Returns the value of attribute reply_to_message.



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

def reply_to_message
  @reply_to_message
end

#stickerObject

Returns the value of attribute sticker.



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

def sticker
  @sticker
end

#successful_paymentObject

Returns the value of attribute successful_payment.



103
104
105
# File 'lib/teleswagger/models/message.rb', line 103

def successful_payment
  @successful_payment
end

#supergroup_chat_createdObject

Returns the value of attribute supergroup_chat_created.



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

def supergroup_chat_created
  @supergroup_chat_created
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

#venueObject

Returns the value of attribute venue.



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

def venue
  @venue
end

#videoObject

Returns the value of attribute video.



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

def video
  @video
end

#video_noteObject

Returns the value of attribute video_note.



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

def video_note
  @video_note
end

#voiceObject

Returns the value of attribute voice.



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

def voice
  @voice
end

Class Method Details

.attribute_mapObject

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



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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# 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

.swagger_typesObject

Attribute type mapping.



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# 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

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# 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

#_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



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# 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

#_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



553
554
555
556
557
558
559
560
561
562
563
564
565
# 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

#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



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# 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

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


453
454
455
# File 'lib/teleswagger/models/message.rb', line 453

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



459
460
461
# 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

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



392
393
394
395
# File 'lib/teleswagger/models/message.rb', line 392

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



533
534
535
# File 'lib/teleswagger/models/message.rb', line 533

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



539
540
541
542
543
544
545
546
547
# 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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



527
528
529
# File 'lib/teleswagger/models/message.rb', line 527

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



399
400
401
# File 'lib/teleswagger/models/message.rb', line 399

def valid?
  return true
end