Class: TelegramBot::ExternalReplyInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram-bot/models/external_reply_info.rb

Overview

This object contains information about a message that is being replied to, which may come from another chat or forum topic.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ExternalReplyInfo

Initializes the object

Parameters:

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

    Model attributes in the form of hash



159
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
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
# File 'lib/telegram-bot/models/external_reply_info.rb', line 159

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TelegramBot::ExternalReplyInfo` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TelegramBot::ExternalReplyInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'origin')
    self.origin = attributes[:'origin']
  else
    self.origin = nil
  end

  if attributes.key?(:'chat')
    self.chat = attributes[:'chat']
  end

  if attributes.key?(:'message_id')
    self.message_id = attributes[:'message_id']
  end

  if attributes.key?(:'link_preview_options')
    self.link_preview_options = attributes[:'link_preview_options']
  end

  if attributes.key?(:'animation')
    self.animation = attributes[:'animation']
  end

  if attributes.key?(:'audio')
    self.audio = attributes[:'audio']
  end

  if attributes.key?(:'document')
    self.document = attributes[:'document']
  end

  if attributes.key?(:'photo')
    if (value = attributes[:'photo']).is_a?(Array)
      self.photo = value
    end
  end

  if attributes.key?(:'sticker')
    self.sticker = attributes[:'sticker']
  end

  if attributes.key?(:'story')
    self.story = attributes[:'story']
  end

  if attributes.key?(:'video')
    self.video = attributes[:'video']
  end

  if attributes.key?(:'video_note')
    self.video_note = attributes[:'video_note']
  end

  if attributes.key?(:'voice')
    self.voice = attributes[:'voice']
  end

  if attributes.key?(:'has_media_spoiler')
    self.has_media_spoiler = attributes[:'has_media_spoiler']
  end

  if attributes.key?(:'contact')
    self.contact = attributes[:'contact']
  end

  if attributes.key?(:'dice')
    self.dice = attributes[:'dice']
  end

  if attributes.key?(:'game')
    self.game = attributes[:'game']
  end

  if attributes.key?(:'giveaway')
    self.giveaway = attributes[:'giveaway']
  end

  if attributes.key?(:'giveaway_winners')
    self.giveaway_winners = attributes[:'giveaway_winners']
  end

  if attributes.key?(:'invoice')
    self.invoice = attributes[:'invoice']
  end

  if attributes.key?(:'location')
    self.location = attributes[:'location']
  end

  if attributes.key?(:'poll')
    self.poll = attributes[:'poll']
  end

  if attributes.key?(:'venue')
    self.venue = attributes[:'venue']
  end
end

Instance Attribute Details

#animationObject

Optional. Message is an animation, information about the animation



32
33
34
# File 'lib/telegram-bot/models/external_reply_info.rb', line 32

def animation
  @animation
end

#audioObject

Optional. Message is an audio file, information about the file



35
36
37
# File 'lib/telegram-bot/models/external_reply_info.rb', line 35

def audio
  @audio
end

#chatObject

Optional. Chat the original message belongs to. Available only if the chat is a supergroup or a channel.



23
24
25
# File 'lib/telegram-bot/models/external_reply_info.rb', line 23

def chat
  @chat
end

#contactObject

Optional. Message is a shared contact, information about the contact



62
63
64
# File 'lib/telegram-bot/models/external_reply_info.rb', line 62

def contact
  @contact
end

#diceObject

Optional. Message is a dice with random value



65
66
67
# File 'lib/telegram-bot/models/external_reply_info.rb', line 65

def dice
  @dice
end

#documentObject

Optional. Message is a general file, information about the file



38
39
40
# File 'lib/telegram-bot/models/external_reply_info.rb', line 38

def document
  @document
end

#gameObject

Optional. Message is a game, information about the game. More about games: core.telegram.org/bots/api#games



68
69
70
# File 'lib/telegram-bot/models/external_reply_info.rb', line 68

def game
  @game
end

#giveawayObject

Optional. Message is a scheduled giveaway, information about the giveaway



71
72
73
# File 'lib/telegram-bot/models/external_reply_info.rb', line 71

def giveaway
  @giveaway
end

#giveaway_winnersObject

Optional. A giveaway with public winners was completed



74
75
76
# File 'lib/telegram-bot/models/external_reply_info.rb', line 74

def giveaway_winners
  @giveaway_winners
end

#has_media_spoilerObject

Optional. True, if the message media is covered by a spoiler animation



59
60
61
# File 'lib/telegram-bot/models/external_reply_info.rb', line 59

def has_media_spoiler
  @has_media_spoiler
end

#invoiceObject

Optional. Message is an invoice for a payment, information about the invoice. More about payments: core.telegram.org/bots/api#payments



77
78
79
# File 'lib/telegram-bot/models/external_reply_info.rb', line 77

def invoice
  @invoice
end

Optional. Options used for link preview generation for the original message, if it is a text message



29
30
31
# File 'lib/telegram-bot/models/external_reply_info.rb', line 29

def link_preview_options
  @link_preview_options
end

#locationObject

Optional. Message is a shared location, information about the location



80
81
82
# File 'lib/telegram-bot/models/external_reply_info.rb', line 80

def location
  @location
end

#message_idObject

Optional. Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel.



26
27
28
# File 'lib/telegram-bot/models/external_reply_info.rb', line 26

def message_id
  @message_id
end

#originObject

Origin of the message replied to by the given message



20
21
22
# File 'lib/telegram-bot/models/external_reply_info.rb', line 20

def origin
  @origin
end

#photoObject

Optional. Message is a photo, available sizes of the photo



41
42
43
# File 'lib/telegram-bot/models/external_reply_info.rb', line 41

def photo
  @photo
end

#pollObject

Optional. Message is a native poll, information about the poll



83
84
85
# File 'lib/telegram-bot/models/external_reply_info.rb', line 83

def poll
  @poll
end

#stickerObject

Optional. Message is a sticker, information about the sticker



44
45
46
# File 'lib/telegram-bot/models/external_reply_info.rb', line 44

def sticker
  @sticker
end

#storyObject

Optional. Message is a forwarded story



47
48
49
# File 'lib/telegram-bot/models/external_reply_info.rb', line 47

def story
  @story
end

#venueObject

Optional. Message is a venue, information about the venue



86
87
88
# File 'lib/telegram-bot/models/external_reply_info.rb', line 86

def venue
  @venue
end

#videoObject

Optional. Message is a video, information about the video



50
51
52
# File 'lib/telegram-bot/models/external_reply_info.rb', line 50

def video
  @video
end

#video_noteObject

Optional. Message is a video note, information about the video message



53
54
55
# File 'lib/telegram-bot/models/external_reply_info.rb', line 53

def video_note
  @video_note
end

#voiceObject

Optional. Message is a voice message, information about the file



56
57
58
# File 'lib/telegram-bot/models/external_reply_info.rb', line 56

def voice
  @voice
end

Class Method Details

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



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
389
390
391
392
393
394
395
# File 'lib/telegram-bot/models/external_reply_info.rb', line 358

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.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
    # models (e.g. Pet) or oneOf
    klass = TelegramBot.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

.acceptable_attributesObject

Returns all the JSON keys this model knows about



118
119
120
# File 'lib/telegram-bot/models/external_reply_info.rb', line 118

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/telegram-bot/models/external_reply_info.rb', line 89

def self.attribute_map
  {
    :'origin' => :'origin',
    :'chat' => :'chat',
    :'message_id' => :'message_id',
    :'link_preview_options' => :'link_preview_options',
    :'animation' => :'animation',
    :'audio' => :'audio',
    :'document' => :'document',
    :'photo' => :'photo',
    :'sticker' => :'sticker',
    :'story' => :'story',
    :'video' => :'video',
    :'video_note' => :'video_note',
    :'voice' => :'voice',
    :'has_media_spoiler' => :'has_media_spoiler',
    :'contact' => :'contact',
    :'dice' => :'dice',
    :'game' => :'game',
    :'giveaway' => :'giveaway',
    :'giveaway_winners' => :'giveaway_winners',
    :'invoice' => :'invoice',
    :'location' => :'location',
    :'poll' => :'poll',
    :'venue' => :'venue'
  }
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



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/telegram-bot/models/external_reply_info.rb', line 334

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  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[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



152
153
154
155
# File 'lib/telegram-bot/models/external_reply_info.rb', line 152

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/telegram-bot/models/external_reply_info.rb', line 123

def self.openapi_types
  {
    :'origin' => :'Object',
    :'chat' => :'Chat',
    :'message_id' => :'Integer',
    :'link_preview_options' => :'LinkPreviewOptions',
    :'animation' => :'Animation',
    :'audio' => :'Audio',
    :'document' => :'Document',
    :'photo' => :'Array<PhotoSize>',
    :'sticker' => :'Sticker',
    :'story' => :'Story',
    :'video' => :'Video',
    :'video_note' => :'VideoNote',
    :'voice' => :'Voice',
    :'has_media_spoiler' => :'Boolean',
    :'contact' => :'Contact',
    :'dice' => :'Dice',
    :'game' => :'Game',
    :'giveaway' => :'Giveaway',
    :'giveaway_winners' => :'GiveawayWinners',
    :'invoice' => :'Invoice',
    :'location' => :'Location',
    :'poll' => :'Poll',
    :'venue' => :'Venue'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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
# File 'lib/telegram-bot/models/external_reply_info.rb', line 291

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      origin == o.origin &&
      chat == o.chat &&
      message_id == o.message_id &&
      link_preview_options == o.link_preview_options &&
      animation == o.animation &&
      audio == o.audio &&
      document == o.document &&
      photo == o.photo &&
      sticker == o.sticker &&
      story == o.story &&
      video == o.video &&
      video_note == o.video_note &&
      voice == o.voice &&
      has_media_spoiler == o.has_media_spoiler &&
      contact == o.contact &&
      dice == o.dice &&
      game == o.game &&
      giveaway == o.giveaway &&
      giveaway_winners == o.giveaway_winners &&
      invoice == o.invoice &&
      location == o.location &&
      poll == o.poll &&
      venue == o.venue
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



429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/telegram-bot/models/external_reply_info.rb', line 429

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

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


321
322
323
# File 'lib/telegram-bot/models/external_reply_info.rb', line 321

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



327
328
329
# File 'lib/telegram-bot/models/external_reply_info.rb', line 327

def hash
  [origin, chat, message_id, link_preview_options, animation, audio, document, photo, sticker, story, video, video_note, voice, has_media_spoiler, contact, dice, game, giveaway, giveaway_winners, invoice, location, poll, venue].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



271
272
273
274
275
276
277
278
279
# File 'lib/telegram-bot/models/external_reply_info.rb', line 271

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @origin.nil?
    invalid_properties.push('invalid value for "origin", origin cannot be nil.')
  end

  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



405
406
407
# File 'lib/telegram-bot/models/external_reply_info.rb', line 405

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



411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/telegram-bot/models/external_reply_info.rb', line 411

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



399
400
401
# File 'lib/telegram-bot/models/external_reply_info.rb', line 399

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



283
284
285
286
287
# File 'lib/telegram-bot/models/external_reply_info.rb', line 283

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @origin.nil?
  true
end