Class: Devdraft::CreatePaymentLinkDto

Inherits:
ApiModelBase show all
Defined in:
lib/devdraft/models/create_payment_link_dto.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ CreatePaymentLinkDto

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 170

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

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Devdraft::CreatePaymentLinkDto`. Please check the name to make sure it's valid. List of attributes: " + acceptable_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?(:'url')
    self.url = attributes[:'url']
  else
    self.url = nil
  end

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

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

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

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

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

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

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

  if attributes.key?(:'is_for_all_product')
    self.is_for_all_product = attributes[:'is_for_all_product']
  else
    self.is_for_all_product = false
  end

  if attributes.key?(:'allow_quantity_adjustment')
    self.allow_quantity_adjustment = attributes[:'allow_quantity_adjustment']
  else
    self.allow_quantity_adjustment = true
  end

  if attributes.key?(:'collect_tax')
    self.collect_tax = attributes[:'collect_tax']
  else
    self.collect_tax = false
  end

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

  if attributes.key?(:'collect_address')
    self.collect_address = attributes[:'collect_address']
  else
    self.collect_address = false
  end

  if attributes.key?(:'limit_payments')
    self.limit_payments = attributes[:'limit_payments']
  else
    self.limit_payments = false
  end

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

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

  if attributes.key?(:'allow_mobile_payment')
    self.allow_mobile_payment = attributes[:'allow_mobile_payment']
  else
    self.allow_mobile_payment = false
  end

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

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

Instance Attribute Details

#allow_mobile_paymentObject

Whether to allow mobile payment



70
71
72
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 70

def allow_mobile_payment
  @allow_mobile_payment
end

#allow_quantity_adjustmentObject

Whether to allow quantity adjustment



49
50
51
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 49

def allow_quantity_adjustment
  @allow_quantity_adjustment
end

#amountObject

Amount for the payment link



34
35
36
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 34

def amount
  @amount
end

#collect_addressObject

Whether to collect address



58
59
60
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 58

def collect_address
  @collect_address
end

#collect_taxObject

Whether to collect tax



52
53
54
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 52

def collect_tax
  @collect_tax
end

#cover_imageObject

Cover image URL



28
29
30
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 28

def cover_image
  @cover_image
end

#currencyObject

Currency



73
74
75
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 73

def currency
  @currency
end

#custom_fieldsObject

Custom fields



67
68
69
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 67

def custom_fields
  @custom_fields
end

#customer_idObject

Customer ID



40
41
42
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 40

def customer_id
  @customer_id
end

#descriptionObject

Detailed description of what the customer is purchasing. Supports markdown formatting.



25
26
27
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 25

def description
  @description
end

#expiration_dateObject

Expiration date



76
77
78
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 76

def expiration_date
  @expiration_date
end

#is_for_all_productObject

Whether the payment link is for all products



46
47
48
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 46

def is_for_all_product
  @is_for_all_product
end

#limit_paymentsObject

Whether to limit payments



61
62
63
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 61

def limit_payments
  @limit_payments
end

Type of the payment link



31
32
33
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 31

def link_type
  @link_type
end

#max_paymentsObject

Maximum number of payments



64
65
66
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 64

def max_payments
  @max_payments
end

#payment_for_idObject

Payment for ID



37
38
39
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 37

def payment_for_id
  @payment_for_id
end

Array of products in the payment link



43
44
45
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 43

def payment_link_products
  @payment_link_products
end

#tax_idObject

Tax ID



55
56
57
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 55

def tax_id
  @tax_id
end

#titleObject

Display title for the payment link. This appears on the checkout page and in customer communications.



19
20
21
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 19

def title
  @title
end

#urlObject

Unique URL slug for the payment link. Can be a full URL or just the path segment. Must be unique within your account.



22
23
24
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 22

def url
  @url
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



127
128
129
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 127

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



132
133
134
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 132

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 101

def self.attribute_map
  {
    :'title' => :'title',
    :'url' => :'url',
    :'description' => :'description',
    :'cover_image' => :'coverImage',
    :'link_type' => :'linkType',
    :'amount' => :'amount',
    :'payment_for_id' => :'paymentForId',
    :'customer_id' => :'customerId',
    :'payment_link_products' => :'paymentLinkProducts',
    :'is_for_all_product' => :'isForAllProduct',
    :'allow_quantity_adjustment' => :'allowQuantityAdjustment',
    :'collect_tax' => :'collectTax',
    :'tax_id' => :'taxId',
    :'collect_address' => :'collectAddress',
    :'limit_payments' => :'limitPayments',
    :'max_payments' => :'maxPayments',
    :'custom_fields' => :'customFields',
    :'allow_mobile_payment' => :'allowMobilePayment',
    :'currency' => :'currency',
    :'expiration_date' => :'expiration_date'
  }
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



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 543

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



163
164
165
166
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 163

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

.openapi_typesObject

Attribute type mapping.



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 137

def self.openapi_types
  {
    :'title' => :'String',
    :'url' => :'String',
    :'description' => :'String',
    :'cover_image' => :'String',
    :'link_type' => :'String',
    :'amount' => :'Float',
    :'payment_for_id' => :'String',
    :'customer_id' => :'String',
    :'payment_link_products' => :'Array<PaymentLinkProductDto>',
    :'is_for_all_product' => :'Boolean',
    :'allow_quantity_adjustment' => :'Boolean',
    :'collect_tax' => :'Boolean',
    :'tax_id' => :'String',
    :'collect_address' => :'Boolean',
    :'limit_payments' => :'Boolean',
    :'max_payments' => :'Float',
    :'custom_fields' => :'Object',
    :'allow_mobile_payment' => :'Boolean',
    :'currency' => :'String',
    :'expiration_date' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 503

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      title == o.title &&
      url == o.url &&
      description == o.description &&
      cover_image == o.cover_image &&
      link_type == o.link_type &&
      amount == o.amount &&
      payment_for_id == o.payment_for_id &&
      customer_id == o.customer_id &&
      payment_link_products == o.payment_link_products &&
      is_for_all_product == o.is_for_all_product &&
      allow_quantity_adjustment == o.allow_quantity_adjustment &&
      collect_tax == o.collect_tax &&
      tax_id == o.tax_id &&
      collect_address == o.collect_address &&
      limit_payments == o.limit_payments &&
      max_payments == o.max_payments &&
      custom_fields == o.custom_fields &&
      allow_mobile_payment == o.allow_mobile_payment &&
      currency == o.currency &&
      expiration_date == o.expiration_date
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


530
531
532
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 530

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



536
537
538
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 536

def hash
  [title, url, description, cover_image, link_type, amount, payment_for_id, customer_id, payment_link_products, is_for_all_product, allow_quantity_adjustment, collect_tax, tax_id, collect_address, limit_payments, max_payments, custom_fields, allow_mobile_payment, currency, expiration_date].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 289

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 @title.to_s.length > 100
    invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 100.')
  end

  if @title.to_s.length < 3
    invalid_properties.push('invalid value for "title", the character length must be greater than or equal to 3.')
  end

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

  if !@description.nil? && @description.to_s.length > 500
    invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 500.')
  end

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

  if !@amount.nil? && @amount < 0.01
    invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.01.')
  end

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

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

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

  if !@max_payments.nil? && @max_payments < 1
    invalid_properties.push('invalid value for "max_payments", must be greater than or equal to 1.')
  end

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 565

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

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/devdraft/models/create_payment_link_dto.rb', line 349

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @title.nil?
  return false if @title.to_s.length > 100
  return false if @title.to_s.length < 3
  return false if @url.nil?
  return false if !@description.nil? && @description.to_s.length > 500
  return false if @link_type.nil?
  link_type_validator = EnumAttributeValidator.new('String', ["INVOICE", "PRODUCT", "COLLECTION", "DONATION"])
  return false unless link_type_validator.valid?(@link_type)
  return false if !@amount.nil? && @amount < 0.01
  return false if @allow_quantity_adjustment.nil?
  return false if @collect_tax.nil?
  return false if @collect_address.nil?
  return false if !@max_payments.nil? && @max_payments < 1
  return false if @allow_mobile_payment.nil?
  return false if @currency.nil?
  currency_validator = EnumAttributeValidator.new('String', ["usdc", "eurc"])
  return false unless currency_validator.valid?(@currency)
  true
end