Class: AdvancedBilling::ScheduledRenewalItemRequestBodyProduct
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ScheduledRenewalItemRequestBodyProduct
- Defined in:
- lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb
Overview
ScheduledRenewalItemRequestBodyProduct Model.
Instance Attribute Summary collapse
-
#custom_price ⇒ ScheduledRenewalProductPricePoint
Custom pricing for a product within a scheduled renewal.
-
#item_id ⇒ Integer
Product or component identifier.
-
#item_type ⇒ String
readonly
Item type to add.
-
#price_point_id ⇒ Integer
Price point identifier.
-
#quantity ⇒ Integer
Optional quantity for the item.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(item_id:, price_point_id: SKIP, quantity: SKIP, custom_price: SKIP, additional_properties: {}) ⇒ ScheduledRenewalItemRequestBodyProduct
constructor
A new instance of ScheduledRenewalItemRequestBodyProduct.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(item_id:, price_point_id: SKIP, quantity: SKIP, custom_price: SKIP, additional_properties: {}) ⇒ ScheduledRenewalItemRequestBodyProduct
Returns a new instance of ScheduledRenewalItemRequestBodyProduct.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 57 def initialize(item_id:, price_point_id: SKIP, quantity: SKIP, custom_price: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @item_type = 'Product' @item_id = item_id @price_point_id = price_point_id unless price_point_id == SKIP @quantity = quantity unless quantity == SKIP @custom_price = custom_price unless custom_price == SKIP end |
Instance Attribute Details
#custom_price ⇒ ScheduledRenewalProductPricePoint
Custom pricing for a product within a scheduled renewal.
30 31 32 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 30 def custom_price @custom_price end |
#item_id ⇒ Integer
Product or component identifier.
18 19 20 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 18 def item_id @item_id end |
#item_type ⇒ String (readonly)
Item type to add. Either Product or Component.
14 15 16 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 14 def item_type @item_type end |
#price_point_id ⇒ Integer
Price point identifier.
22 23 24 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 22 def price_point_id @price_point_id end |
#quantity ⇒ Integer
Optional quantity for the item.
26 27 28 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 26 def quantity @quantity end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 72 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. item_id = hash.key?('item_id') ? hash['item_id'] : nil price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP quantity = hash.key?('quantity') ? hash['quantity'] : SKIP custom_price = ScheduledRenewalProductPricePoint.from_hash(hash['custom_price']) if hash['custom_price'] # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. ScheduledRenewalItemRequestBodyProduct.new(item_id: item_id, price_point_id: price_point_id, quantity: quantity, custom_price: custom_price, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['item_type'] = 'item_type' @_hash['item_id'] = 'item_id' @_hash['price_point_id'] = 'price_point_id' @_hash['quantity'] = 'quantity' @_hash['custom_price'] = 'custom_price' @_hash end |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 44 def self.optionals %w[ price_point_id quantity custom_price ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 96 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.item_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.item_id, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['item_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['item_id'], ->(val) { val.instance_of? Integer }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
125 126 127 128 129 130 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 125 def inspect class_name = self.class.name.split('::').last "<#{class_name} item_type: #{@item_type.inspect}, item_id: #{@item_id.inspect},"\ " price_point_id: #{@price_point_id.inspect}, quantity: #{@quantity.inspect}, custom_price:"\ " #{@custom_price.inspect}, additional_properties: #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
117 118 119 120 121 122 |
# File 'lib/advanced_billing/models/scheduled_renewal_item_request_body_product.rb', line 117 def to_s class_name = self.class.name.split('::').last "<#{class_name} item_type: #{@item_type}, item_id: #{@item_id}, price_point_id:"\ " #{@price_point_id}, quantity: #{@quantity}, custom_price: #{@custom_price},"\ " additional_properties: #{get_additional_properties}>" end |