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:, unit_amount:, description: SKIP, quantity: SKIP, direction: SKIP, additional_properties: nil) ⇒ 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:, unit_amount:, description: SKIP, quantity: SKIP, direction: SKIP, additional_properties: nil) ⇒ InvoiceLineItemCreateRequest
Returns a new instance of InvoiceLineItemCreateRequest.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 61 def initialize(name:, unit_amount:, description: SKIP, quantity: SKIP, direction: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @name = name @description = description unless description == SKIP @quantity = quantity unless quantity == SKIP @unit_amount = unit_amount @direction = direction unless direction == SKIP @additional_properties = additional_properties 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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 75 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 a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. InvoiceLineItemCreateRequest.new(name: name, unit_amount: unit_amount, description: description, quantity: quantity, direction: direction, additional_properties: additional_properties) 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.
110 111 112 113 114 115 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 110 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}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
102 103 104 105 106 107 |
# File 'lib/modern_treasury/models/invoice_line_item_create_request.rb', line 102 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, description: #{@description}, quantity: #{@quantity},"\ " unit_amount: #{@unit_amount}, direction: #{@direction}, additional_properties:"\ " #{@additional_properties}>" end |