Class: AdvancedBilling::CreateInvoice
- Defined in:
- lib/advanced_billing/models/create_invoice.rb
Overview
CreateInvoice Model.
Instance Attribute Summary collapse
-
#billing_address ⇒ CreateInvoiceAddress
Overrides the default for the customer.
-
#coupons ⇒ Array[CreateInvoiceCoupon]
Overrides the default for the customer.
-
#issue_date ⇒ Date
TODO: Write general description for this method.
-
#line_items ⇒ Array[CreateInvoiceItem]
TODO: Write general description for this method.
-
#memo ⇒ String
A custom memo can be sent to override the site’s default.
-
#net_terms ⇒ Integer
By default, invoices will be created with a due date matching the date of invoice creation.
-
#payment_instructions ⇒ String
By default, invoices will be created with a due date matching the date of invoice creation.
-
#seller_address ⇒ CreateInvoiceAddress
Overrides the defaults for the site.
-
#shipping_address ⇒ CreateInvoiceAddress
Overrides the default for the customer.
-
#status ⇒ CreateInvoiceStatus
Overrides the default for the customer.
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, status: CreateInvoiceStatus::OPEN, additional_properties: {}) ⇒ CreateInvoice
constructor
A new instance of CreateInvoice.
Methods inherited from BaseModel
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, status: CreateInvoiceStatus::OPEN, additional_properties: {}) ⇒ CreateInvoice
Returns a new instance of CreateInvoice.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 95 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, status: CreateInvoiceStatus::OPEN, additional_properties: {}) @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 @status = status unless status == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#billing_address ⇒ CreateInvoiceAddress
Overrides the default for the customer
44 45 46 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 44 def billing_address @billing_address end |
#coupons ⇒ Array[CreateInvoiceCoupon]
Overrides the default for the customer
52 53 54 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 52 def coupons @coupons end |
#issue_date ⇒ Date
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 18 def issue_date @issue_date end |
#line_items ⇒ Array[CreateInvoiceItem]
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 14 def line_items @line_items end |
#memo ⇒ String
A custom memo can be sent to override the site’s default.
36 37 38 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 36 def memo @memo end |
#net_terms ⇒ Integer
By default, invoices will be created with a due date matching the date of invoice creation. If a different due date is desired, the net_terms parameter can be sent indicating the number of days in advance the due date should be.
25 26 27 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 25 def net_terms @net_terms end |
#payment_instructions ⇒ String
By default, invoices will be created with a due date matching the date of invoice creation. If a different due date is desired, the net_terms parameter can be sent indicating the number of days in advance the due date should be.
32 33 34 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 32 def payment_instructions @payment_instructions end |
#seller_address ⇒ CreateInvoiceAddress
Overrides the defaults for the site
40 41 42 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 40 def seller_address @seller_address end |
#shipping_address ⇒ CreateInvoiceAddress
Overrides the default for the customer
48 49 50 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 48 def shipping_address @shipping_address end |
#status ⇒ CreateInvoiceStatus
Overrides the default for the customer
56 57 58 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 56 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 164 165 166 167 168 169 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 117 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 << (CreateInvoiceItem.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') status = hash['status'] ||= CreateInvoiceStatus::OPEN # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CreateInvoice.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, status: status, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 59 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['status'] = 'status' @_hash end |
.nullables ⇒ Object
An array for nullable fields
91 92 93 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 91 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/advanced_billing/models/create_invoice.rb', line 75 def self.optionals %w[ line_items issue_date net_terms payment_instructions memo seller_address billing_address shipping_address coupons status ] end |