Class: ApiReference::CreditBlockAllocation

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

Overview

The credit allocation that funded a block. Extends the allocation resource serialized on prices with the catalog-item attribution of the funding price.

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(currency:, allows_rollover:, custom_expiration:, item_id:, filters: SKIP, license_type_id: SKIP, additional_properties: nil) ⇒ CreditBlockAllocation

Returns a new instance of CreditBlockAllocation.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/api_reference/models/credit_block_allocation.rb', line 66

def initialize(currency:, allows_rollover:, custom_expiration:, item_id:,
               filters: SKIP, license_type_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @currency = currency
  @allows_rollover = allows_rollover
  @custom_expiration = custom_expiration
  @filters = filters unless filters == SKIP
  @license_type_id = license_type_id unless license_type_id == SKIP
  @item_id = item_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#allows_rolloverTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


19
20
21
# File 'lib/api_reference/models/credit_block_allocation.rb', line 19

def allows_rollover
  @allows_rollover
end

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/api_reference/models/credit_block_allocation.rb', line 15

def currency
  @currency
end

#custom_expirationCustomExpiration

TODO: Write general description for this method

Returns:



23
24
25
# File 'lib/api_reference/models/credit_block_allocation.rb', line 23

def custom_expiration
  @custom_expiration
end

#filtersArray[PriceFilter]

TODO: Write general description for this method

Returns:



27
28
29
# File 'lib/api_reference/models/credit_block_allocation.rb', line 27

def filters
  @filters
end

#item_idString

The ID of the catalog item this block was allocated from, derived from the allocation's price.

Returns:

  • (String)


36
37
38
# File 'lib/api_reference/models/credit_block_allocation.rb', line 36

def item_id
  @item_id
end

#license_type_idString

TODO: Write general description for this method

Returns:

  • (String)


31
32
33
# File 'lib/api_reference/models/credit_block_allocation.rb', line 31

def license_type_id
  @license_type_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



82
83
84
85
86
87
88
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
116
117
118
119
120
# File 'lib/api_reference/models/credit_block_allocation.rb', line 82

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  currency = hash.key?('currency') ? hash['currency'] : nil
  allows_rollover =
    hash.key?('allows_rollover') ? hash['allows_rollover'] : nil
  custom_expiration = CustomExpiration.from_hash(hash['custom_expiration']) if
    hash['custom_expiration']
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
  # Parameter is an array, so we need to iterate through it
  filters = nil
  unless hash['filters'].nil?
    filters = []
    hash['filters'].each do |structure|
      filters << (PriceFilter.from_hash(structure) if structure)
    end
  end

  filters = SKIP unless hash.key?('filters')
  license_type_id =
    hash.key?('license_type_id') ? hash['license_type_id'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CreditBlockAllocation.new(currency: currency,
                            allows_rollover: allows_rollover,
                            custom_expiration: custom_expiration,
                            item_id: item_id,
                            filters: filters,
                            license_type_id: license_type_id,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/api_reference/models/credit_block_allocation.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['currency'] = 'currency'
  @_hash['allows_rollover'] = 'allows_rollover'
  @_hash['custom_expiration'] = 'custom_expiration'
  @_hash['filters'] = 'filters'
  @_hash['license_type_id'] = 'license_type_id'
  @_hash['item_id'] = 'item_id'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
62
63
64
# File 'lib/api_reference/models/credit_block_allocation.rb', line 59

def self.nullables
  %w[
    custom_expiration
    license_type_id
  ]
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
# File 'lib/api_reference/models/credit_block_allocation.rb', line 51

def self.optionals
  %w[
    filters
    license_type_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



132
133
134
135
136
137
138
# File 'lib/api_reference/models/credit_block_allocation.rb', line 132

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency.inspect}, allows_rollover:"\
  " #{@allows_rollover.inspect}, custom_expiration: #{@custom_expiration.inspect}, filters:"\
  " #{@filters.inspect}, license_type_id: #{@license_type_id.inspect}, item_id:"\
  " #{@item_id.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



123
124
125
126
127
128
129
# File 'lib/api_reference/models/credit_block_allocation.rb', line 123

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency}, allows_rollover: #{@allows_rollover},"\
  " custom_expiration: #{@custom_expiration}, filters: #{@filters}, license_type_id:"\
  " #{@license_type_id}, item_id: #{@item_id}, additional_properties:"\
  " #{@additional_properties}>"
end