Class: AdvancedBilling::CreateOfferComponent

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

Overview

CreateOfferComponent 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(component_id: SKIP, price_point_id: SKIP, starting_quantity: SKIP, additional_properties: {}) ⇒ CreateOfferComponent

Returns a new instance of CreateOfferComponent.



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

def initialize(component_id: SKIP, price_point_id: SKIP,
               starting_quantity: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

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

Instance Attribute Details

#component_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def component_id
  @component_id
end

#price_point_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def price_point_id
  @price_point_id
end

#starting_quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/create_offer_component.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.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/advanced_billing/models/create_offer_component.rb', line 60

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

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

  # Create object from extracted values.
  CreateOfferComponent.new(component_id: component_id,
                           price_point_id: price_point_id,
                           starting_quantity: starting_quantity,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/advanced_billing/models/create_offer_component.rb', line 25

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
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/advanced_billing/models/create_offer_component.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/advanced_billing/models/create_offer_component.rb', line 34

def self.optionals
  %w[
    component_id
    price_point_id
    starting_quantity
  ]
end