Class: Brevo::CreateBalanceDefinitionPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/brevo/models/create_balance_definition_payload.rb

Overview

Payload for creating a new balance definition, specifying expiration rules, rounding strategies, and constraints.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CreateBalanceDefinitionPayload

Initializes the object

Parameters:

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

    Model attributes in the form of hash



134
135
136
137
138
139
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 134

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?(:'balanceAvailabilityDurationModifier')
    self.balance_availability_duration_modifier = attributes[:'balanceAvailabilityDurationModifier']
  end

  if attributes.has_key?(:'balanceAvailabilityDurationUnit')
    self.balance_availability_duration_unit = attributes[:'balanceAvailabilityDurationUnit']
  end

  if attributes.has_key?(:'balanceAvailabilityDurationValue')
    self.balance_availability_duration_value = attributes[:'balanceAvailabilityDurationValue']
  end

  if attributes.has_key?(:'balanceExpirationDate')
    self.balance_expiration_date = attributes[:'balanceExpirationDate']
  end

  if attributes.has_key?(:'balanceOptionAmountOvertakingStrategy')
    self.balance_option_amount_overtaking_strategy = attributes[:'balanceOptionAmountOvertakingStrategy']
  end

  if attributes.has_key?(:'balanceOptionCreditRounding')
    self.balance_option_credit_rounding = attributes[:'balanceOptionCreditRounding']
  end

  if attributes.has_key?(:'balanceOptionDebitRounding')
    self.balance_option_debit_rounding = attributes[:'balanceOptionDebitRounding']
  end

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

  if attributes.has_key?(:'imageRef')
    self.image_ref = attributes[:'imageRef']
  end

  if attributes.has_key?(:'maxAmount')
    self.max_amount = attributes[:'maxAmount']
  end

  if attributes.has_key?(:'maxCreditAmountLimit')
    self.max_credit_amount_limit = attributes[:'maxCreditAmountLimit']
  end

  if attributes.has_key?(:'maxDebitAmountLimit')
    self.max_debit_amount_limit = attributes[:'maxDebitAmountLimit']
  end

  if attributes.has_key?(:'meta')
    self.meta = attributes[:'meta']
  end

  if attributes.has_key?(:'minAmount')
    self.min_amount = attributes[:'minAmount']
  end

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'unit')
    self.unit = attributes[:'unit']
  end
end

Instance Attribute Details

#balance_availability_duration_modifierObject

Defines when the balance expires within the selected duration.



19
20
21
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 19

def balance_availability_duration_modifier
  @balance_availability_duration_modifier
end

#balance_availability_duration_unitObject

Unit of time for balance validity.



22
23
24
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 22

def balance_availability_duration_unit
  @balance_availability_duration_unit
end

#balance_availability_duration_valueObject

Number of time units before the balance expires.



25
26
27
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 25

def balance_availability_duration_value
  @balance_availability_duration_value
end

#balance_expiration_dateObject

Fixed expiration date (‘dd/mm` format) as an alternative to duration-based expiry.



28
29
30
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 28

def balance_expiration_date
  @balance_expiration_date
end

#balance_option_amount_overtaking_strategyObject

Defines whether partial credit is allowed when reaching max balance.



31
32
33
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 31

def balance_option_amount_overtaking_strategy
  @balance_option_amount_overtaking_strategy
end

#balance_option_credit_roundingObject

Defines rounding strategy for credit transactions.



34
35
36
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 34

def balance_option_credit_rounding
  @balance_option_credit_rounding
end

#balance_option_debit_roundingObject

Defines rounding strategy for debit transactions.



37
38
39
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 37

def balance_option_debit_rounding
  @balance_option_debit_rounding
end

#descriptionObject

Short description of the balance definition.



40
41
42
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 40

def description
  @description
end

#image_refObject

URL of an optional image reference.



43
44
45
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 43

def image_ref
  @image_ref
end

#max_amountObject

Maximum allowable balance amount.



46
47
48
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 46

def max_amount
  @max_amount
end

#max_credit_amount_limitObject

Maximum credit allowed per operation.



49
50
51
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 49

def max_credit_amount_limit
  @max_credit_amount_limit
end

#max_debit_amount_limitObject

Maximum debit allowed per operation.



52
53
54
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 52

def max_debit_amount_limit
  @max_debit_amount_limit
end

#metaObject

Additional metadata for the balance definition.



55
56
57
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 55

def meta
  @meta
end

#min_amountObject

Minimum allowable balance amount.



58
59
60
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 58

def min_amount
  @min_amount
end

#nameObject

Name of the balance definition.



61
62
63
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 61

def name
  @name
end

#unitObject

Unit of balance measurement.



64
65
66
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 64

def unit
  @unit
end

Class Method Details

.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
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 89

def self.attribute_map
  {
    :'balance_availability_duration_modifier' => :'balanceAvailabilityDurationModifier',
    :'balance_availability_duration_unit' => :'balanceAvailabilityDurationUnit',
    :'balance_availability_duration_value' => :'balanceAvailabilityDurationValue',
    :'balance_expiration_date' => :'balanceExpirationDate',
    :'balance_option_amount_overtaking_strategy' => :'balanceOptionAmountOvertakingStrategy',
    :'balance_option_credit_rounding' => :'balanceOptionCreditRounding',
    :'balance_option_debit_rounding' => :'balanceOptionDebitRounding',
    :'description' => :'description',
    :'image_ref' => :'imageRef',
    :'max_amount' => :'maxAmount',
    :'max_credit_amount_limit' => :'maxCreditAmountLimit',
    :'max_debit_amount_limit' => :'maxDebitAmountLimit',
    :'meta' => :'meta',
    :'min_amount' => :'minAmount',
    :'name' => :'name',
    :'unit' => :'unit'
  }
end

.swagger_typesObject

Attribute type mapping.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 111

def self.swagger_types
  {
    :'balance_availability_duration_modifier' => :'String',
    :'balance_availability_duration_unit' => :'String',
    :'balance_availability_duration_value' => :'Integer',
    :'balance_expiration_date' => :'Date',
    :'balance_option_amount_overtaking_strategy' => :'String',
    :'balance_option_credit_rounding' => :'String',
    :'balance_option_debit_rounding' => :'String',
    :'description' => :'String',
    :'image_ref' => :'String',
    :'max_amount' => :'Float',
    :'max_credit_amount_limit' => :'Float',
    :'max_debit_amount_limit' => :'Float',
    :'meta' => :'Object',
    :'min_amount' => :'Float',
    :'name' => :'String',
    :'unit' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 336

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      balance_availability_duration_modifier == o.balance_availability_duration_modifier &&
      balance_availability_duration_unit == o.balance_availability_duration_unit &&
      balance_availability_duration_value == o.balance_availability_duration_value &&
      balance_expiration_date == o.balance_expiration_date &&
      balance_option_amount_overtaking_strategy == o.balance_option_amount_overtaking_strategy &&
      balance_option_credit_rounding == o.balance_option_credit_rounding &&
      balance_option_debit_rounding == o.balance_option_debit_rounding &&
      description == o.description &&
      image_ref == o.image_ref &&
      max_amount == o.max_amount &&
      max_credit_amount_limit == o.max_credit_amount_limit &&
      max_debit_amount_limit == o.max_debit_amount_limit &&
      meta == o.meta &&
      min_amount == o.min_amount &&
      name == o.name &&
      unit == o.unit
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



393
394
395
396
397
398
399
400
401
402
403
404
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
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 393

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 = Brevo.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



459
460
461
462
463
464
465
466
467
468
469
470
471
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 459

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



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 372

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


359
360
361
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 359

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



365
366
367
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 365

def hash
  [balance_availability_duration_modifier, balance_availability_duration_unit, balance_availability_duration_value, balance_expiration_date, balance_option_amount_overtaking_strategy, balance_option_credit_rounding, balance_option_debit_rounding, description, image_ref, max_amount, max_credit_amount_limit, max_debit_amount_limit, meta, min_amount, name, unit].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 207

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

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

  if @name.to_s.length > 128
    invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 128.')
  end

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



439
440
441
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 439

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



445
446
447
448
449
450
451
452
453
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 445

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



433
434
435
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 433

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



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/brevo/models/create_balance_definition_payload.rb', line 230

def valid?
  balance_availability_duration_modifier_validator = EnumAttributeValidator.new('String', ['noModification', 'startOfPeriod', 'endOfPeriod'])
  return false unless balance_availability_duration_modifier_validator.valid?(@balance_availability_duration_modifier)
  balance_availability_duration_unit_validator = EnumAttributeValidator.new('String', ['day', 'week', 'month', 'year'])
  return false unless balance_availability_duration_unit_validator.valid?(@balance_availability_duration_unit)
  balance_option_amount_overtaking_strategy_validator = EnumAttributeValidator.new('String', ['strict', 'partial'])
  return false unless balance_option_amount_overtaking_strategy_validator.valid?(@balance_option_amount_overtaking_strategy)
  balance_option_credit_rounding_validator = EnumAttributeValidator.new('String', ['lower', 'upper', 'natural'])
  return false unless balance_option_credit_rounding_validator.valid?(@balance_option_credit_rounding)
  balance_option_debit_rounding_validator = EnumAttributeValidator.new('String', ['lower', 'upper', 'natural'])
  return false unless balance_option_debit_rounding_validator.valid?(@balance_option_debit_rounding)
  return false if !@description.nil? && @description.to_s.length > 256
  return false if @name.nil?
  return false if @name.to_s.length > 128
  return false if @unit.nil?
  unit_validator = EnumAttributeValidator.new('String', ['POINTS', 'EUR', 'USD', 'MXN', 'GBP', 'INR', 'CAD', 'SGD', 'RON', 'JPY', 'MYR', 'CLP', 'PEN', 'MAD', 'AUD', 'CHF', 'BRL'])
  return false unless unit_validator.valid?(@unit)
  true
end