Class: Merge::Accounting::CreditNoteLineItemRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/accounting/types/credit_note_line_item_request.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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remote_id: 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, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Accounting::CreditNoteLineItemRequest

Parameters:

  • remote_id (String) (defaults to: OMIT)

    The third-party API ID of the matching object.

  • item (Merge::Accounting::CreditNoteLineItemRequestItem) (defaults to: OMIT)
  • name (String) (defaults to: OMIT)

    The credit note line item’s name.

  • description (String) (defaults to: OMIT)

    The description of the item that is owed.

  • quantity (String) (defaults to: OMIT)

    The credit note line item’s quantity.

  • memo (String) (defaults to: OMIT)

    The credit note line item’s memo.

  • unit_price (String) (defaults to: OMIT)

    The credit note line item’s unit price.

  • tax_rate (String) (defaults to: OMIT)

    The tax rate that applies to this line item.

  • total_line_amount (String) (defaults to: OMIT)

    The credit note line item’s total.

  • tracking_category (String) (defaults to: OMIT)

    The credit note line item’s associated tracking category.

  • tracking_categories (Array<String>) (defaults to: OMIT)

    The credit note line item’s associated tracking categories.

  • account (String) (defaults to: OMIT)

    The credit note line item’s account.

  • company (Merge::Accounting::CreditNoteLineItemRequestCompany) (defaults to: OMIT)

    The company the credit note belongs to.

  • contact (Merge::Accounting::CreditNoteLineItemRequestContact) (defaults to: OMIT)

    The credit note’s contact.

  • project (Merge::Accounting::CreditNoteLineItemRequestProject) (defaults to: OMIT)
  • integration_params (Hash{String => Object}) (defaults to: OMIT)
  • linked_account_params (Hash{String => Object}) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



79
80
81
82
83
84
85
86
87
88
89
90
91
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
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 79

def initialize(remote_id: 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, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil)
  @remote_id = remote_id if remote_id != 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 =  if  != OMIT
  @company = company if company != OMIT
  @contact = contact if contact != OMIT
  @project = project if project != OMIT
  @integration_params = integration_params if integration_params != OMIT
  @linked_account_params =  if  != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "remote_id": remote_id,
    "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": ,
    "company": company,
    "contact": contact,
    "project": project,
    "integration_params": integration_params,
    "linked_account_params": 
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#accountString (readonly)

Returns The credit note line item’s account.

Returns:

  • (String)

    The credit note line item’s account.



41
42
43
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 41

def 
  @account
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



53
54
55
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 53

def additional_properties
  @additional_properties
end

#companyMerge::Accounting::CreditNoteLineItemRequestCompany (readonly)

Returns The company the credit note belongs to.

Returns:



43
44
45
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 43

def company
  @company
end

#contactMerge::Accounting::CreditNoteLineItemRequestContact (readonly)

Returns The credit note’s contact.

Returns:



45
46
47
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 45

def contact
  @contact
end

#descriptionString (readonly)

Returns The description of the item that is owed.

Returns:

  • (String)

    The description of the item that is owed.



25
26
27
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 25

def description
  @description
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


49
50
51
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 49

def integration_params
  @integration_params
end

#itemMerge::Accounting::CreditNoteLineItemRequestItem (readonly)



21
22
23
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 21

def item
  @item
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


51
52
53
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 51

def 
  @linked_account_params
end

#memoString (readonly)

Returns The credit note line item’s memo.

Returns:

  • (String)

    The credit note line item’s memo.



29
30
31
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 29

def memo
  @memo
end

#nameString (readonly)

Returns The credit note line item’s name.

Returns:

  • (String)

    The credit note line item’s name.



23
24
25
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 23

def name
  @name
end

#projectMerge::Accounting::CreditNoteLineItemRequestProject (readonly)



47
48
49
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 47

def project
  @project
end

#quantityString (readonly)

Returns The credit note line item’s quantity.

Returns:

  • (String)

    The credit note line item’s quantity.



27
28
29
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 27

def quantity
  @quantity
end

#remote_idString (readonly)

Returns The third-party API ID of the matching object.

Returns:

  • (String)

    The third-party API ID of the matching object.



19
20
21
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 19

def remote_id
  @remote_id
end

#tax_rateString (readonly)

Returns The tax rate that applies to this line item.

Returns:

  • (String)

    The tax rate that applies to this line item.



33
34
35
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 33

def tax_rate
  @tax_rate
end

#total_line_amountString (readonly)

Returns The credit note line item’s total.

Returns:

  • (String)

    The credit note line item’s total.



35
36
37
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 35

def total_line_amount
  @total_line_amount
end

#tracking_categoriesArray<String> (readonly)

Returns The credit note line item’s associated tracking categories.

Returns:

  • (Array<String>)

    The credit note line item’s associated tracking categories.



39
40
41
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 39

def tracking_categories
  @tracking_categories
end

#tracking_categoryString (readonly)

Returns The credit note line item’s associated tracking category.

Returns:

  • (String)

    The credit note line item’s associated tracking category.



37
38
39
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 37

def tracking_category
  @tracking_category
end

#unit_priceString (readonly)

Returns The credit note line item’s unit price.

Returns:

  • (String)

    The credit note line item’s unit price.



31
32
33
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 31

def unit_price
  @unit_price
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Accounting::CreditNoteLineItemRequest

Deserialize a JSON object to an instance of CreditNoteLineItemRequest

Parameters:

  • json_object (String)

Returns:



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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 126

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  remote_id = parsed_json["remote_id"]
  if parsed_json["item"].nil?
    item = nil
  else
    item = parsed_json["item"].to_json
    item = Merge::Accounting::CreditNoteLineItemRequestItem.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"]
   = parsed_json["account"]
  if parsed_json["company"].nil?
    company = nil
  else
    company = parsed_json["company"].to_json
    company = Merge::Accounting::CreditNoteLineItemRequestCompany.from_json(json_object: company)
  end
  if parsed_json["contact"].nil?
    contact = nil
  else
    contact = parsed_json["contact"].to_json
    contact = Merge::Accounting::CreditNoteLineItemRequestContact.from_json(json_object: contact)
  end
  if parsed_json["project"].nil?
    project = nil
  else
    project = parsed_json["project"].to_json
    project = Merge::Accounting::CreditNoteLineItemRequestProject.from_json(json_object: project)
  end
  integration_params = parsed_json["integration_params"]
   = parsed_json["linked_account_params"]
  new(
    remote_id: remote_id,
    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: ,
    company: company,
    contact: contact,
    project: project,
    integration_params: integration_params,
    linked_account_params: ,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 201

def self.validate_raw(obj:)
  obj.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.")
  obj.item.nil? || Merge::Accounting::CreditNoteLineItemRequestItem.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.&.is_a?(String) != false || raise("Passed value for field obj.account is not the expected type, validation failed.")
  obj.company.nil? || Merge::Accounting::CreditNoteLineItemRequestCompany.validate_raw(obj: obj.company)
  obj.contact.nil? || Merge::Accounting::CreditNoteLineItemRequestContact.validate_raw(obj: obj.contact)
  obj.project.nil? || Merge::Accounting::CreditNoteLineItemRequestProject.validate_raw(obj: obj.project)
  obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.")
  obj.&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreditNoteLineItemRequest to a JSON object

Returns:

  • (String)


191
192
193
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item_request.rb', line 191

def to_json(*_args)
  @_field_set&.to_json
end