Class: ApiReference::BulkWithFiltersTier

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/bulk_with_filters_tier.rb

Overview

Configuration for a single bulk pricing tier

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(unit_amount:, tier_lower_bound: SKIP) ⇒ BulkWithFiltersTier

Returns a new instance of BulkWithFiltersTier.



42
43
44
45
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 42

def initialize(unit_amount:, tier_lower_bound: SKIP)
  @tier_lower_bound = tier_lower_bound unless tier_lower_bound == SKIP
  @unit_amount = unit_amount
end

Instance Attribute Details

#tier_lower_boundString

The lower bound for this tier

Returns:

  • (String)


14
15
16
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 14

def tier_lower_bound
  @tier_lower_bound
end

#unit_amountString

Amount per unit

Returns:

  • (String)


18
19
20
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 18

def unit_amount
  @unit_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  unit_amount = hash.key?('unit_amount') ? hash['unit_amount'] : nil
  tier_lower_bound =
    hash.key?('tier_lower_bound') ? hash['tier_lower_bound'] : SKIP

  # Create object from extracted values.
  BulkWithFiltersTier.new(unit_amount: unit_amount,
                          tier_lower_bound: tier_lower_bound)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['tier_lower_bound'] = 'tier_lower_bound'
  @_hash['unit_amount'] = 'unit_amount'
  @_hash
end

.nullablesObject

An array for nullable fields



36
37
38
39
40
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 36

def self.nullables
  %w[
    tier_lower_bound
  ]
end

.optionalsObject

An array for optional fields



29
30
31
32
33
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 29

def self.optionals
  %w[
    tier_lower_bound
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 63

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.unit_amount,
                                 ->(val) { val.instance_of? String })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['unit_amount'],
                        ->(val) { val.instance_of? String })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



82
83
84
85
86
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 82

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} tier_lower_bound: #{@tier_lower_bound.inspect}, unit_amount:"\
  " #{@unit_amount.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



76
77
78
79
# File 'lib/api_reference/models/bulk_with_filters_tier.rb', line 76

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} tier_lower_bound: #{@tier_lower_bound}, unit_amount: #{@unit_amount}>"
end