Class: AdvancedBilling::UpdateInvoice
- Defined in:
- lib/advanced_billing/models/update_invoice.rb
Overview
Attributes of a draft ad hoc invoice which can be updated. Only the submitted attributes are changed.
Instance Attribute Summary collapse
-
#billing_address ⇒ CreateInvoiceAddress
Replaces the billing address on the invoice.
-
#coupons ⇒ Array[CreateInvoiceCoupon]
When present, replaces all discounts currently applied to the invoice.
-
#issue_date ⇒ Date
New issue date for the invoice (format YYYY-MM-DD).
-
#line_items ⇒ Array[UpdateInvoiceItem]
Line item changes to apply.
-
#memo ⇒ String
A custom memo displayed on the invoice.
-
#net_terms ⇒ Integer
Number of days after the issue date on which the invoice is due.
-
#payment_instructions ⇒ String
Custom payment instructions displayed on the invoice.
-
#seller_address ⇒ CreateInvoiceAddress
Replaces the seller address on the invoice.
-
#shipping_address ⇒ CreateInvoiceAddress
Replaces the shipping address on the invoice.
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.
Instance Method Summary collapse
-
#initialize(line_items: SKIP, issue_date: SKIP, net_terms: SKIP, payment_instructions: SKIP, memo: SKIP, seller_address: SKIP, billing_address: SKIP, shipping_address: SKIP, coupons: SKIP, additional_properties: {}) ⇒ UpdateInvoice
constructor
A new instance of UpdateInvoice.
-
#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(line_items: SKIP, issue_date: SKIP, net_terms: SKIP, payment_instructions: SKIP, memo: SKIP, seller_address: SKIP, billing_address: SKIP, shipping_address: SKIP, coupons: SKIP, additional_properties: {}) ⇒ UpdateInvoice
Returns a new instance of UpdateInvoice.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 92 def initialize(line_items: SKIP, issue_date: SKIP, net_terms: SKIP, payment_instructions: SKIP, memo: SKIP, seller_address: SKIP, billing_address: SKIP, shipping_address: SKIP, coupons: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @line_items = line_items unless line_items == SKIP @issue_date = issue_date unless issue_date == SKIP @net_terms = net_terms unless net_terms == SKIP @payment_instructions = payment_instructions unless payment_instructions == SKIP @memo = memo unless memo == SKIP @seller_address = seller_address unless seller_address == SKIP @billing_address = billing_address unless billing_address == SKIP @shipping_address = shipping_address unless shipping_address == SKIP @coupons = coupons unless coupons == SKIP end |
Instance Attribute Details
#billing_address ⇒ CreateInvoiceAddress
Replaces the billing address on the invoice
46 47 48 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 46 def billing_address @billing_address end |
#coupons ⇒ Array[CreateInvoiceCoupon]
When present, replaces all discounts currently applied to the invoice. Send an empty array to remove all discounts.
55 56 57 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 55 def coupons @coupons end |
#issue_date ⇒ Date
New issue date for the invoice (format YYYY-MM-DD). This date is interpreted and validated in your site's time zone. It must be today or a date in the past — future dates are not accepted. The due date is recalculated from the issue date and net terms.
25 26 27 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 25 def issue_date @issue_date end |
#line_items ⇒ Array[UpdateInvoiceItem]
Line item changes to apply. Line items without a uid are added, line
items with a uid are updated, and line items with a uid and _destroy
set to true are removed. Existing line items not referenced in the array
remain unchanged.
18 19 20 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 18 def line_items @line_items end |
#memo ⇒ String
A custom memo displayed on the invoice.
38 39 40 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 38 def memo @memo end |
#net_terms ⇒ Integer
Number of days after the issue date on which the invoice is due. The due date is recalculated when net terms or the issue date change.
30 31 32 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 30 def net_terms @net_terms end |
#payment_instructions ⇒ String
Custom payment instructions displayed on the invoice.
34 35 36 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 34 def payment_instructions @payment_instructions end |
#seller_address ⇒ CreateInvoiceAddress
Replaces the seller address on the invoice
42 43 44 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 42 def seller_address @seller_address end |
#shipping_address ⇒ CreateInvoiceAddress
Replaces the shipping address on the invoice
50 51 52 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 50 def shipping_address @shipping_address end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 113 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it line_items = nil unless hash['line_items'].nil? line_items = [] hash['line_items'].each do |structure| line_items << (UpdateInvoiceItem.from_hash(structure) if structure) end end line_items = SKIP unless hash.key?('line_items') issue_date = hash.key?('issue_date') ? hash['issue_date'] : SKIP net_terms = hash.key?('net_terms') ? hash['net_terms'] : SKIP payment_instructions = hash.key?('payment_instructions') ? hash['payment_instructions'] : SKIP memo = hash.key?('memo') ? hash['memo'] : SKIP seller_address = CreateInvoiceAddress.from_hash(hash['seller_address']) if hash['seller_address'] billing_address = CreateInvoiceAddress.from_hash(hash['billing_address']) if hash['billing_address'] shipping_address = CreateInvoiceAddress.from_hash(hash['shipping_address']) if hash['shipping_address'] # Parameter is an array, so we need to iterate through it coupons = nil unless hash['coupons'].nil? coupons = [] hash['coupons'].each do |structure| coupons << (CreateInvoiceCoupon.from_hash(structure) if structure) end end coupons = SKIP unless hash.key?('coupons') # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. UpdateInvoice.new(line_items: line_items, issue_date: issue_date, net_terms: net_terms, payment_instructions: payment_instructions, memo: memo, seller_address: seller_address, billing_address: billing_address, shipping_address: shipping_address, coupons: coupons, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 58 def self.names @_hash = {} if @_hash.nil? @_hash['line_items'] = 'line_items' @_hash['issue_date'] = 'issue_date' @_hash['net_terms'] = 'net_terms' @_hash['payment_instructions'] = 'payment_instructions' @_hash['memo'] = 'memo' @_hash['seller_address'] = 'seller_address' @_hash['billing_address'] = 'billing_address' @_hash['shipping_address'] = 'shipping_address' @_hash['coupons'] = 'coupons' @_hash end |
.nullables ⇒ Object
An array for nullable fields
88 89 90 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 88 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 73 def self.optionals %w[ line_items issue_date net_terms payment_instructions memo seller_address billing_address shipping_address coupons ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
176 177 178 179 180 181 182 183 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 176 def inspect class_name = self.class.name.split('::').last "<#{class_name} line_items: #{@line_items.inspect}, issue_date: #{@issue_date.inspect},"\ " net_terms: #{@net_terms.inspect}, payment_instructions: #{@payment_instructions.inspect},"\ " memo: #{@memo.inspect}, seller_address: #{@seller_address.inspect}, billing_address:"\ " #{@billing_address.inspect}, shipping_address: #{@shipping_address.inspect}, coupons:"\ " #{@coupons.inspect}, additional_properties: #{get_additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
166 167 168 169 170 171 172 173 |
# File 'lib/advanced_billing/models/update_invoice.rb', line 166 def to_s class_name = self.class.name.split('::').last "<#{class_name} line_items: #{@line_items}, issue_date: #{@issue_date}, net_terms:"\ " #{@net_terms}, payment_instructions: #{@payment_instructions}, memo: #{@memo},"\ " seller_address: #{@seller_address}, billing_address: #{@billing_address},"\ " shipping_address: #{@shipping_address}, coupons: #{@coupons}, additional_properties:"\ " #{get_additional_properties}>" end |