Class: ModernTreasury::InvoiceLineItemCreateRequest
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ModernTreasury::InvoiceLineItemCreateRequest
- Defined in:
- lib/modern_treasury/models/invoice_line_item_create_request.rb
Overview
InvoiceLineItemCreateRequest Model.
Instance Attribute Summary collapse
-
#description ⇒ String
An optional free-form description of the line item.
-
#direction ⇒ String
Either ‘debit` or `credit`.
-
#name ⇒ String
The name of the line item, typically a product or SKU name.
-
#quantity ⇒ Integer
The number of units of a product or service that this line item is for.
-
#unit_amount ⇒ Integer
The cost per unit of the product or service that this line item is for, specified in the invoice currency’s smallest unit.
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(name = nil, unit_amount = nil, description = SKIP, quantity = SKIP, direction = SKIP) ⇒ InvoiceLineItemCreateRequest
constructor
A new instance of InvoiceLineItemCreateRequest.
-
#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, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name = nil, unit_amount = nil, description = SKIP, quantity = SKIP, direction = SKIP) ⇒ InvoiceLineItemCreateRequest
Returns a new instance of InvoiceLineItemCreateRequest.
61 62 63 64 65 66 67 68 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 61 def initialize(name = nil, unit_amount = nil, description = SKIP, quantity = SKIP, direction = SKIP) @name = name @description = description unless description == SKIP @quantity = quantity unless quantity == SKIP @unit_amount = unit_amount @direction = direction unless direction == SKIP end |
Instance Attribute Details
#description ⇒ String
An optional free-form description of the line item.
18 19 20 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 18 def description @description end |
#direction ⇒ String
Either ‘debit` or `credit`. `debit` indicates that a client owes the business money and increases the invoice’s ‘total_amount` due. `credit` has the opposite intention and effect.
34 35 36 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 34 def direction @direction end |
#name ⇒ String
The name of the line item, typically a product or SKU name.
14 15 16 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 14 def name @name end |
#quantity ⇒ Integer
The number of units of a product or service that this line item is for.
Must be a whole number. Defaults to 1 if not provided.
23 24 25 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 23 def quantity @quantity end |
#unit_amount ⇒ Integer
The cost per unit of the product or service that this line item is for,
specified in the invoice currency's smallest unit.
28 29 30 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 28 def unit_amount @unit_amount end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 71 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil unit_amount = hash.key?('unit_amount') ? hash['unit_amount'] : nil description = hash.key?('description') ? hash['description'] : SKIP quantity = hash.key?('quantity') ? hash['quantity'] : SKIP direction = hash.key?('direction') ? hash['direction'] : SKIP # Create object from extracted values. InvoiceLineItemCreateRequest.new(name, unit_amount, description, quantity, direction) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['description'] = 'description' @_hash['quantity'] = 'quantity' @_hash['unit_amount'] = 'unit_amount' @_hash['direction'] = 'direction' @_hash end |
.nullables ⇒ Object
An array for nullable fields
57 58 59 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 57 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
48 49 50 51 52 53 54 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 48 def self.optionals %w[ description quantity direction ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
97 98 99 100 101 102 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 97 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, description: #{@description.inspect}, quantity:"\ " #{@quantity.inspect}, unit_amount: #{@unit_amount.inspect}, direction:"\ " #{@direction.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
90 91 92 93 94 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 90 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, description: #{@description}, quantity: #{@quantity},"\ " unit_amount: #{@unit_amount}, direction: #{@direction}>" end |