Class: Merge::Accounting::CreditNoteLineItem
- Inherits:
-
Object
- Object
- Merge::Accounting::CreditNoteLineItem
- Defined in:
- lib/merge_ruby_client/accounting/types/credit_note_line_item.rb
Overview
# The CreditNoteLineItem Object
### Description
The `CreditNoteLineItem` object is used to represent a credit note's line items.
### Usage Example
Fetch from the `GET CreditNote` endpoint and view the credit note's line items.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#account ⇒ String
readonly
The credit note line item’s account.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#company ⇒ Merge::Accounting::CreditNoteLineItemCompany
readonly
The company the credit note belongs to.
-
#contact ⇒ Merge::Accounting::CreditNoteLineItemContact
readonly
The credit note’s contact.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
-
#description ⇒ String
readonly
The description of the item that is owed.
- #id ⇒ String readonly
- #item ⇒ Merge::Accounting::CreditNoteLineItemItem readonly
-
#memo ⇒ String
readonly
The credit note line item’s memo.
-
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
-
#name ⇒ String
readonly
The credit note line item’s name.
- #project ⇒ Merge::Accounting::CreditNoteLineItemProject readonly
-
#quantity ⇒ String
readonly
The credit note line item’s quantity.
-
#remote_id ⇒ String
readonly
The third-party API ID of the matching object.
-
#remote_was_deleted ⇒ Boolean
readonly
Indicates whether or not this object has been deleted in the third party platform.
-
#tax_rate ⇒ String
readonly
The tax rate that applies to this line item.
-
#total_line_amount ⇒ String
readonly
The credit note line item’s total.
-
#tracking_categories ⇒ Array<String>
readonly
The credit note line item’s associated tracking categories.
-
#tracking_category ⇒ String
readonly
The credit note line item’s associated tracking category.
-
#unit_price ⇒ String
readonly
The credit note line item’s unit price.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Accounting::CreditNoteLineItem
Deserialize a JSON object to an instance of CreditNoteLineItem.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, item: OMIT, name: OMIT, description: OMIT, quantity: OMIT, memo: OMIT, unit_price: OMIT, tax_rate: OMIT, total_line_amount: OMIT, tracking_category: OMIT, tracking_categories: OMIT, account: OMIT, company: OMIT, contact: OMIT, project: OMIT, remote_was_deleted: OMIT, additional_properties: nil) ⇒ Merge::Accounting::CreditNoteLineItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreditNoteLineItem to a JSON object.
Constructor Details
#initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, item: OMIT, name: OMIT, description: OMIT, quantity: OMIT, memo: OMIT, unit_price: OMIT, tax_rate: OMIT, total_line_amount: OMIT, tracking_category: OMIT, tracking_categories: OMIT, account: OMIT, company: OMIT, contact: OMIT, project: OMIT, remote_was_deleted: OMIT, additional_properties: nil) ⇒ Merge::Accounting::CreditNoteLineItem
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 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 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 92 def initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, item: OMIT, name: OMIT, description: OMIT, quantity: OMIT, memo: OMIT, unit_price: OMIT, tax_rate: OMIT, total_line_amount: OMIT, tracking_category: OMIT, tracking_categories: OMIT, account: OMIT, company: OMIT, contact: OMIT, project: OMIT, remote_was_deleted: OMIT, additional_properties: nil) @id = id if id != OMIT @remote_id = remote_id if remote_id != OMIT @created_at = created_at if created_at != OMIT @modified_at = modified_at if modified_at != OMIT @item = item if item != OMIT @name = name if name != OMIT @description = description if description != OMIT @quantity = quantity if quantity != OMIT @memo = memo if memo != OMIT @unit_price = unit_price if unit_price != OMIT @tax_rate = tax_rate if tax_rate != OMIT @total_line_amount = total_line_amount if total_line_amount != OMIT @tracking_category = tracking_category if tracking_category != OMIT @tracking_categories = tracking_categories if tracking_categories != OMIT @account = account if account != OMIT @company = company if company != OMIT @contact = contact if contact != OMIT @project = project if project != OMIT @remote_was_deleted = remote_was_deleted if remote_was_deleted != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "remote_id": remote_id, "created_at": created_at, "modified_at": modified_at, "item": item, "name": name, "description": description, "quantity": quantity, "memo": memo, "unit_price": unit_price, "tax_rate": tax_rate, "total_line_amount": total_line_amount, "tracking_category": tracking_category, "tracking_categories": tracking_categories, "account": account, "company": company, "contact": contact, "project": project, "remote_was_deleted": remote_was_deleted }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#account ⇒ String (readonly)
Returns The credit note line item’s account.
48 49 50 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 48 def account @account end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
61 62 63 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 61 def additional_properties @additional_properties end |
#company ⇒ Merge::Accounting::CreditNoteLineItemCompany (readonly)
Returns The company the credit note belongs to.
50 51 52 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 50 def company @company end |
#contact ⇒ Merge::Accounting::CreditNoteLineItemContact (readonly)
Returns The credit note’s contact.
52 53 54 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 52 def contact @contact end |
#created_at ⇒ DateTime (readonly)
Returns The datetime that this object was created by Merge.
24 25 26 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 24 def created_at @created_at end |
#description ⇒ String (readonly)
Returns The description of the item that is owed.
32 33 34 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 32 def description @description end |
#id ⇒ String (readonly)
20 21 22 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 20 def id @id end |
#item ⇒ Merge::Accounting::CreditNoteLineItemItem (readonly)
28 29 30 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 28 def item @item end |
#memo ⇒ String (readonly)
Returns The credit note line item’s memo.
36 37 38 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 36 def memo @memo end |
#modified_at ⇒ DateTime (readonly)
Returns The datetime that this object was modified by Merge.
26 27 28 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 26 def modified_at @modified_at end |
#name ⇒ String (readonly)
Returns The credit note line item’s name.
30 31 32 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 30 def name @name end |
#project ⇒ Merge::Accounting::CreditNoteLineItemProject (readonly)
54 55 56 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 54 def project @project end |
#quantity ⇒ String (readonly)
Returns The credit note line item’s quantity.
34 35 36 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 34 def quantity @quantity end |
#remote_id ⇒ String (readonly)
Returns The third-party API ID of the matching object.
22 23 24 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 22 def remote_id @remote_id end |
#remote_was_deleted ⇒ Boolean (readonly)
Returns Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).
59 60 61 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 59 def remote_was_deleted @remote_was_deleted end |
#tax_rate ⇒ String (readonly)
Returns The tax rate that applies to this line item.
40 41 42 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 40 def tax_rate @tax_rate end |
#total_line_amount ⇒ String (readonly)
Returns The credit note line item’s total.
42 43 44 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 42 def total_line_amount @total_line_amount end |
#tracking_categories ⇒ Array<String> (readonly)
Returns The credit note line item’s associated tracking categories.
46 47 48 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 46 def tracking_categories @tracking_categories end |
#tracking_category ⇒ String (readonly)
Returns The credit note line item’s associated tracking category.
44 45 46 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 44 def tracking_category @tracking_category end |
#unit_price ⇒ String (readonly)
Returns The credit note line item’s unit price.
38 39 40 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 38 def unit_price @unit_price end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Accounting::CreditNoteLineItem
Deserialize a JSON object to an instance of CreditNoteLineItem
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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 143 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] remote_id = parsed_json["remote_id"] created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?) modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?) if parsed_json["item"].nil? item = nil else item = parsed_json["item"].to_json item = Merge::Accounting::CreditNoteLineItemItem.from_json(json_object: item) end name = parsed_json["name"] description = parsed_json["description"] quantity = parsed_json["quantity"] memo = parsed_json["memo"] unit_price = parsed_json["unit_price"] tax_rate = parsed_json["tax_rate"] total_line_amount = parsed_json["total_line_amount"] tracking_category = parsed_json["tracking_category"] tracking_categories = parsed_json["tracking_categories"] account = parsed_json["account"] if parsed_json["company"].nil? company = nil else company = parsed_json["company"].to_json company = Merge::Accounting::CreditNoteLineItemCompany.from_json(json_object: company) end if parsed_json["contact"].nil? contact = nil else contact = parsed_json["contact"].to_json contact = Merge::Accounting::CreditNoteLineItemContact.from_json(json_object: contact) end if parsed_json["project"].nil? project = nil else project = parsed_json["project"].to_json project = Merge::Accounting::CreditNoteLineItemProject.from_json(json_object: project) end remote_was_deleted = parsed_json["remote_was_deleted"] new( id: id, remote_id: remote_id, created_at: created_at, modified_at: modified_at, item: item, name: name, description: description, quantity: quantity, memo: memo, unit_price: unit_price, tax_rate: tax_rate, total_line_amount: total_line_amount, tracking_category: tracking_category, tracking_categories: tracking_categories, account: account, company: company, contact: contact, project: project, remote_was_deleted: remote_was_deleted, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 222 def self.validate_raw(obj:) obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.") obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.") obj.item.nil? || Merge::Accounting::CreditNoteLineItemItem.validate_raw(obj: obj.item) obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") obj.quantity&.is_a?(String) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") obj.unit_price&.is_a?(String) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") obj.tax_rate&.is_a?(String) != false || raise("Passed value for field obj.tax_rate is not the expected type, validation failed.") obj.total_line_amount&.is_a?(String) != false || raise("Passed value for field obj.total_line_amount is not the expected type, validation failed.") obj.tracking_category&.is_a?(String) != false || raise("Passed value for field obj.tracking_category is not the expected type, validation failed.") obj.tracking_categories&.is_a?(Array) != false || raise("Passed value for field obj.tracking_categories is not the expected type, validation failed.") obj.account&.is_a?(String) != false || raise("Passed value for field obj.account is not the expected type, validation failed.") obj.company.nil? || Merge::Accounting::CreditNoteLineItemCompany.validate_raw(obj: obj.company) obj.contact.nil? || Merge::Accounting::CreditNoteLineItemContact.validate_raw(obj: obj.contact) obj.project.nil? || Merge::Accounting::CreditNoteLineItemProject.validate_raw(obj: obj.project) obj.remote_was_deleted&.is_a?(Boolean) != false || raise("Passed value for field obj.remote_was_deleted is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CreditNoteLineItem to a JSON object
212 213 214 |
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 212 def to_json(*_args) @_field_set&.to_json end |