Class: TelegramBot::InputInvoiceMessageContent

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

Overview

Represents the content of an invoice message to be sent as the result of an inline query.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ InputInvoiceMessageContent

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TelegramBot::InputInvoiceMessageContent` 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::InputInvoiceMessageContent`. 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?(:'title')
    self.title = attributes[:'title']
  else
    self.title = nil
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#currencyObject

Three-letter ISO 4217 currency code, see more on currencies



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

def currency
  @currency
end

#descriptionObject

Product description, 1-255 characters



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

def description
  @description
end

#is_flexibleObject

Optional. Pass True if the final price depends on the shipping method



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

def is_flexible
  @is_flexible
end

#max_tip_amountObject

Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0



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

def max_tip_amount
  @max_tip_amount
end

#need_emailObject

Optional. Pass True if you require the user’s email address to complete the order



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

def need_email
  @need_email
end

#need_nameObject

Optional. Pass True if you require the user’s full name to complete the order



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

def need_name
  @need_name
end

#need_phone_numberObject

Optional. Pass True if you require the user’s phone number to complete the order



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

def need_phone_number
  @need_phone_number
end

#need_shipping_addressObject

Optional. Pass True if you require the user’s shipping address to complete the order



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

def need_shipping_address
  @need_shipping_address
end

#payloadObject

Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.



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

def payload
  @payload
end

#photo_heightObject

Optional. Photo height



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

def photo_height
  @photo_height
end

#photo_sizeObject

Optional. Photo size in bytes



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

def photo_size
  @photo_size
end

#photo_urlObject

Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.



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

def photo_url
  @photo_url
end

#photo_widthObject

Optional. Photo width



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

def photo_width
  @photo_width
end

#pricesObject

Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)



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

def prices
  @prices
end

#provider_dataObject

Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider.



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

def provider_data
  @provider_data
end

#provider_tokenObject

Payment provider token, obtained via @BotFather



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

def provider_token
  @provider_token
end

#send_email_to_providerObject

Optional. Pass True if the user’s email address should be sent to provider



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

def send_email_to_provider
  @send_email_to_provider
end

#send_phone_number_to_providerObject

Optional. Pass True if the user’s phone number should be sent to provider



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

def send_phone_number_to_provider
  @send_phone_number_to_provider
end

#suggested_tip_amountsObject

Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.



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

def suggested_tip_amounts
  @suggested_tip_amounts
end

#titleObject

Product name, 1-32 characters



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

def title
  @title
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



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
396
397
398
399
400
401
402
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 365

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



106
107
108
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 106

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 80

def self.attribute_map
  {
    :'title' => :'title',
    :'description' => :'description',
    :'payload' => :'payload',
    :'provider_token' => :'provider_token',
    :'currency' => :'currency',
    :'prices' => :'prices',
    :'max_tip_amount' => :'max_tip_amount',
    :'suggested_tip_amounts' => :'suggested_tip_amounts',
    :'provider_data' => :'provider_data',
    :'photo_url' => :'photo_url',
    :'photo_size' => :'photo_size',
    :'photo_width' => :'photo_width',
    :'photo_height' => :'photo_height',
    :'need_name' => :'need_name',
    :'need_phone_number' => :'need_phone_number',
    :'need_email' => :'need_email',
    :'need_shipping_address' => :'need_shipping_address',
    :'send_phone_number_to_provider' => :'send_phone_number_to_provider',
    :'send_email_to_provider' => :'send_email_to_provider',
    :'is_flexible' => :'is_flexible'
  }
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



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 341

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



137
138
139
140
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 137

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

.openapi_typesObject

Attribute type mapping.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 111

def self.openapi_types
  {
    :'title' => :'String',
    :'description' => :'String',
    :'payload' => :'String',
    :'provider_token' => :'String',
    :'currency' => :'String',
    :'prices' => :'Array<LabeledPrice>',
    :'max_tip_amount' => :'Integer',
    :'suggested_tip_amounts' => :'Array<Integer>',
    :'provider_data' => :'String',
    :'photo_url' => :'String',
    :'photo_size' => :'Integer',
    :'photo_width' => :'Integer',
    :'photo_height' => :'Integer',
    :'need_name' => :'Boolean',
    :'need_phone_number' => :'Boolean',
    :'need_email' => :'Boolean',
    :'need_shipping_address' => :'Boolean',
    :'send_phone_number_to_provider' => :'Boolean',
    :'send_email_to_provider' => :'Boolean',
    :'is_flexible' => :'Boolean'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 301

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      title == o.title &&
      description == o.description &&
      payload == o.payload &&
      provider_token == o.provider_token &&
      currency == o.currency &&
      prices == o.prices &&
      max_tip_amount == o.max_tip_amount &&
      suggested_tip_amounts == o.suggested_tip_amounts &&
      provider_data == o.provider_data &&
      photo_url == o.photo_url &&
      photo_size == o.photo_size &&
      photo_width == o.photo_width &&
      photo_height == o.photo_height &&
      need_name == o.need_name &&
      need_phone_number == o.need_phone_number &&
      need_email == o.need_email &&
      need_shipping_address == o.need_shipping_address &&
      send_phone_number_to_provider == o.send_phone_number_to_provider &&
      send_email_to_provider == o.send_email_to_provider &&
      is_flexible == o.is_flexible
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



436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 436

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


328
329
330
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 328

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



334
335
336
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 334

def hash
  [title, description, payload, provider_token, currency, prices, max_tip_amount, suggested_tip_amounts, provider_data, photo_url, photo_size, photo_width, photo_height, need_name, need_phone_number, need_email, need_shipping_address, send_phone_number_to_provider, send_email_to_provider, is_flexible].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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

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

  if @description.nil?
    invalid_properties.push('invalid value for "description", description cannot be nil.')
  end

  if @payload.nil?
    invalid_properties.push('invalid value for "payload", payload cannot be nil.')
  end

  if @provider_token.nil?
    invalid_properties.push('invalid value for "provider_token", provider_token cannot be nil.')
  end

  if @currency.nil?
    invalid_properties.push('invalid value for "currency", currency cannot be nil.')
  end

  if @prices.nil?
    invalid_properties.push('invalid value for "prices", prices 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



412
413
414
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 412

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



418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 418

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



406
407
408
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 406

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



288
289
290
291
292
293
294
295
296
297
# File 'lib/telegram-bot/models/input_invoice_message_content.rb', line 288

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @title.nil?
  return false if @description.nil?
  return false if @payload.nil?
  return false if @provider_token.nil?
  return false if @currency.nil?
  return false if @prices.nil?
  true
end