Class: AdvancedBilling::OfferItem

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

Overview

OfferItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(component_id = SKIP, price_point_id = SKIP, starting_quantity = SKIP, editable = SKIP, component_unit_price = SKIP, component_name = SKIP, price_point_name = SKIP, currency_prices = SKIP) ⇒ OfferItem

Returns a new instance of OfferItem.



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/advanced_billing/models/offer_item.rb', line 77

def initialize(component_id = SKIP, price_point_id = SKIP,
               starting_quantity = SKIP, editable = SKIP,
               component_unit_price = SKIP, component_name = SKIP,
               price_point_name = SKIP, currency_prices = SKIP)
  @component_id = component_id unless component_id == SKIP
  @price_point_id = price_point_id unless price_point_id == SKIP
  @starting_quantity = starting_quantity unless starting_quantity == SKIP
  @editable = editable unless editable == SKIP
  @component_unit_price = component_unit_price unless component_unit_price == SKIP
  @component_name = component_name unless component_name == SKIP
  @price_point_name = price_point_name unless price_point_name == SKIP
  @currency_prices = currency_prices unless currency_prices == SKIP
end

Instance Attribute Details

#component_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def component_id
  @component_id
end

#component_nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def component_name
  @component_name
end

#component_unit_priceString

TODO: Write general description for this method

Returns:

  • (String)


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

def component_unit_price
  @component_unit_price
end

#currency_pricesArray[CurrencyPrice]

TODO: Write general description for this method

Returns:



42
43
44
# File 'lib/advanced_billing/models/offer_item.rb', line 42

def currency_prices
  @currency_prices
end

#editableTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def editable
  @editable
end

#price_point_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def price_point_id
  @price_point_id
end

#price_point_nameString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/offer_item.rb', line 38

def price_point_name
  @price_point_name
end

#starting_quantityString

TODO: Write general description for this method

Returns:

  • (String)


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

def starting_quantity
  @starting_quantity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
121
122
123
124
125
126
127
128
# File 'lib/advanced_billing/models/offer_item.rb', line 92

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  component_id = hash.key?('component_id') ? hash['component_id'] : SKIP
  price_point_id =
    hash.key?('price_point_id') ? hash['price_point_id'] : SKIP
  starting_quantity =
    hash.key?('starting_quantity') ? hash['starting_quantity'] : SKIP
  editable = hash.key?('editable') ? hash['editable'] : SKIP
  component_unit_price =
    hash.key?('component_unit_price') ? hash['component_unit_price'] : SKIP
  component_name =
    hash.key?('component_name') ? hash['component_name'] : SKIP
  price_point_name =
    hash.key?('price_point_name') ? hash['price_point_name'] : SKIP
  # Parameter is an array, so we need to iterate through it

  currency_prices = nil
  unless hash['currency_prices'].nil?
    currency_prices = []
    hash['currency_prices'].each do |structure|
      currency_prices << (CurrencyPrice.from_hash(structure) if structure)
    end
  end

  currency_prices = SKIP unless hash.key?('currency_prices')

  # Create object from extracted values.

  OfferItem.new(component_id,
                price_point_id,
                starting_quantity,
                editable,
                component_unit_price,
                component_name,
                price_point_name,
                currency_prices)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/advanced_billing/models/offer_item.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['component_id'] = 'component_id'
  @_hash['price_point_id'] = 'price_point_id'
  @_hash['starting_quantity'] = 'starting_quantity'
  @_hash['editable'] = 'editable'
  @_hash['component_unit_price'] = 'component_unit_price'
  @_hash['component_name'] = 'component_name'
  @_hash['price_point_name'] = 'price_point_name'
  @_hash['currency_prices'] = 'currency_prices'
  @_hash
end

.nullablesObject

An array for nullable fields



73
74
75
# File 'lib/advanced_billing/models/offer_item.rb', line 73

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    component_id
    price_point_id
    starting_quantity
    editable
    component_unit_price
    component_name
    price_point_name
    currency_prices
  ]
end