Class: AdvancedBilling::ItemPricePointChanged

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/item_price_point_changed.rb

Overview

ItemPricePointChanged Model.

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(item_id:, item_type:, item_handle:, item_name:, previous_price_point:, current_price_point:, additional_properties: {}) ⇒ ItemPricePointChanged

Returns a new instance of ItemPricePointChanged.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 58

def initialize(item_id:, item_type:, item_handle:, item_name:,
               previous_price_point:, current_price_point:,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @item_id = item_id
  @item_type = item_type
  @item_handle = item_handle
  @item_name = item_name
  @previous_price_point = previous_price_point
  @current_price_point = current_price_point
end

Instance Attribute Details

#current_price_pointItemPricePointData

TODO: Write general description for this method

Returns:



34
35
36
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 34

def current_price_point
  @current_price_point
end

#item_handleString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 22

def item_handle
  @item_handle
end

#item_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 14

def item_id
  @item_id
end

#item_nameString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 26

def item_name
  @item_name
end

#item_typeString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 18

def item_type
  @item_type
end

#previous_price_pointItemPricePointData

TODO: Write general description for this method

Returns:



30
31
32
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 30

def previous_price_point
  @previous_price_point
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
  item_type = hash.key?('item_type') ? hash['item_type'] : nil
  item_handle = hash.key?('item_handle') ? hash['item_handle'] : nil
  item_name = hash.key?('item_name') ? hash['item_name'] : nil
  previous_price_point = ItemPricePointData.from_hash(hash['previous_price_point']) if
    hash['previous_price_point']
  current_price_point = ItemPricePointData.from_hash(hash['current_price_point']) if
    hash['current_price_point']

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  ItemPricePointChanged.new(item_id: item_id,
                            item_type: item_type,
                            item_handle: item_handle,
                            item_name: item_name,
                            previous_price_point: previous_price_point,
                            current_price_point: current_price_point,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['item_id'] = 'item_id'
  @_hash['item_type'] = 'item_type'
  @_hash['item_handle'] = 'item_handle'
  @_hash['item_name'] = 'item_name'
  @_hash['previous_price_point'] = 'previous_price_point'
  @_hash['current_price_point'] = 'current_price_point'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 49

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/advanced_billing/models/item_price_point_changed.rb', line 103

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.item_id,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.item_type,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.item_handle,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.item_name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.previous_price_point,
                              ->(val) { ItemPricePointData.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.current_price_point,
                              ->(val) { ItemPricePointData.validate(val) },
                              is_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['item_id'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['item_type'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['item_handle'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['item_name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['previous_price_point'],
                            ->(val) { ItemPricePointData.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['current_price_point'],
                            ->(val) { ItemPricePointData.validate(val) },
                            is_model_hash: true)
  )
end