Class: AdvancedBilling::InvoiceDiscount
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::InvoiceDiscount
- Defined in:
- lib/advanced_billing/models/invoice_discount.rb
Overview
InvoiceDiscount Model.
Instance Attribute Summary collapse
-
#code ⇒ String
TODO: Write general description for this method.
-
#description ⇒ String
TODO: Write general description for this method.
-
#discount_amount ⇒ String
TODO: Write general description for this method.
-
#discount_type ⇒ InvoiceDiscountType
TODO: Write general description for this method.
-
#eligible_amount ⇒ String
TODO: Write general description for this method.
-
#line_item_breakouts ⇒ Array[InvoiceDiscountBreakout]
TODO: Write general description for this method.
-
#percentage ⇒ String
TODO: Write general description for this method.
-
#source_id ⇒ Integer
TODO: Write general description for this method.
-
#source_type ⇒ InvoiceDiscountSourceType
TODO: Write general description for this method.
-
#title ⇒ String
TODO: Write general description for this method.
-
#transaction_id ⇒ Integer
TODO: Write general description for this method.
-
#uid ⇒ String
TODO: Write general description for this method.
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(uid: SKIP, title: SKIP, description: SKIP, code: SKIP, source_type: SKIP, source_id: SKIP, discount_type: SKIP, percentage: SKIP, eligible_amount: SKIP, discount_amount: SKIP, transaction_id: SKIP, line_item_breakouts: SKIP, additional_properties: {}) ⇒ InvoiceDiscount
constructor
A new instance of InvoiceDiscount.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(uid: SKIP, title: SKIP, description: SKIP, code: SKIP, source_type: SKIP, source_id: SKIP, discount_type: SKIP, percentage: SKIP, eligible_amount: SKIP, discount_amount: SKIP, transaction_id: SKIP, line_item_breakouts: SKIP, additional_properties: {}) ⇒ InvoiceDiscount
Returns a new instance of InvoiceDiscount.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 103 def initialize(uid: SKIP, title: SKIP, description: SKIP, code: SKIP, source_type: SKIP, source_id: SKIP, discount_type: SKIP, percentage: SKIP, eligible_amount: SKIP, discount_amount: SKIP, transaction_id: SKIP, line_item_breakouts: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @uid = uid unless uid == SKIP @title = title unless title == SKIP @description = description unless description == SKIP @code = code unless code == SKIP @source_type = source_type unless source_type == SKIP @source_id = source_id unless source_id == SKIP @discount_type = discount_type unless discount_type == SKIP @percentage = percentage unless percentage == SKIP @eligible_amount = eligible_amount unless eligible_amount == SKIP @discount_amount = discount_amount unless discount_amount == SKIP @transaction_id = transaction_id unless transaction_id == SKIP @line_item_breakouts = line_item_breakouts unless line_item_breakouts == SKIP end |
Instance Attribute Details
#code ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 26 def code @code end |
#description ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 22 def description @description end |
#discount_amount ⇒ String
TODO: Write general description for this method
50 51 52 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 50 def discount_amount @discount_amount end |
#discount_type ⇒ InvoiceDiscountType
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 38 def discount_type @discount_type end |
#eligible_amount ⇒ String
TODO: Write general description for this method
46 47 48 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 46 def eligible_amount @eligible_amount end |
#line_item_breakouts ⇒ Array[InvoiceDiscountBreakout]
TODO: Write general description for this method
58 59 60 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 58 def line_item_breakouts @line_item_breakouts end |
#percentage ⇒ String
TODO: Write general description for this method
42 43 44 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 42 def percentage @percentage end |
#source_id ⇒ Integer
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 34 def source_id @source_id end |
#source_type ⇒ InvoiceDiscountSourceType
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 30 def source_type @source_type end |
#title ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 18 def title @title end |
#transaction_id ⇒ Integer
TODO: Write general description for this method
54 55 56 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 54 def transaction_id @transaction_id end |
#uid ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 14 def uid @uid end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 128 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. uid = hash.key?('uid') ? hash['uid'] : SKIP title = hash.key?('title') ? hash['title'] : SKIP description = hash.key?('description') ? hash['description'] : SKIP code = hash.key?('code') ? hash['code'] : SKIP source_type = hash.key?('source_type') ? hash['source_type'] : SKIP source_id = hash.key?('source_id') ? hash['source_id'] : SKIP discount_type = hash.key?('discount_type') ? hash['discount_type'] : SKIP percentage = hash.key?('percentage') ? hash['percentage'] : SKIP eligible_amount = hash.key?('eligible_amount') ? hash['eligible_amount'] : SKIP discount_amount = hash.key?('discount_amount') ? hash['discount_amount'] : SKIP transaction_id = hash.key?('transaction_id') ? hash['transaction_id'] : SKIP # Parameter is an array, so we need to iterate through it line_item_breakouts = nil unless hash['line_item_breakouts'].nil? line_item_breakouts = [] hash['line_item_breakouts'].each do |structure| line_item_breakouts << (InvoiceDiscountBreakout.from_hash(structure) if structure) end end line_item_breakouts = SKIP unless hash.key?('line_item_breakouts') # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. InvoiceDiscount.new(uid: uid, title: title, description: description, code: code, source_type: source_type, source_id: source_id, discount_type: discount_type, percentage: percentage, eligible_amount: eligible_amount, discount_amount: discount_amount, transaction_id: transaction_id, line_item_breakouts: line_item_breakouts, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 61 def self.names @_hash = {} if @_hash.nil? @_hash['uid'] = 'uid' @_hash['title'] = 'title' @_hash['description'] = 'description' @_hash['code'] = 'code' @_hash['source_type'] = 'source_type' @_hash['source_id'] = 'source_id' @_hash['discount_type'] = 'discount_type' @_hash['percentage'] = 'percentage' @_hash['eligible_amount'] = 'eligible_amount' @_hash['discount_amount'] = 'discount_amount' @_hash['transaction_id'] = 'transaction_id' @_hash['line_item_breakouts'] = 'line_item_breakouts' @_hash end |
.nullables ⇒ Object
An array for nullable fields
97 98 99 100 101 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 97 def self.nullables %w[ description ] end |
.optionals ⇒ Object
An array for optional fields
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 79 def self.optionals %w[ uid title description code source_type source_id discount_type percentage eligible_amount discount_amount transaction_id line_item_breakouts ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
178 179 180 181 182 183 184 |
# File 'lib/advanced_billing/models/invoice_discount.rb', line 178 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |