Class: Merge::Accounting::CreditNoteLineItem

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/accounting/types/credit_note_line_item.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracking_categories:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, item: OMIT, name: OMIT, description: OMIT, quantity: OMIT, memo: OMIT, unit_price: OMIT, total_line_amount: OMIT, tracking_category: OMIT, account: OMIT, company: OMIT, remote_was_deleted: OMIT, additional_properties: nil) ⇒ Merge::Accounting::CreditNoteLineItem

Parameters:

  • id (String) (defaults to: OMIT)
  • remote_id (String) (defaults to: OMIT)

    The third-party API ID of the matching object.

  • created_at (DateTime) (defaults to: OMIT)

    The datetime that this object was created by Merge.

  • modified_at (DateTime) (defaults to: OMIT)

    The datetime that this object was modified by Merge.

  • item (Merge::Accounting::CreditNoteLineItemItem) (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.

  • 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>)

    The credit note line item’s associated tracking categories.

  • account (String) (defaults to: OMIT)

    The credit note line item’s account.

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

    The company the credit note belongs to.

  • remote_was_deleted (Boolean) (defaults to: OMIT)

    Indicates whether or not this object has been deleted in the third party platform.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



72
73
74
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
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 72

def initialize(tracking_categories:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, item: OMIT, name: OMIT,
               description: OMIT, quantity: OMIT, memo: OMIT, unit_price: OMIT, total_line_amount: OMIT, tracking_category: OMIT, account: OMIT, company: 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
  @total_line_amount = total_line_amount if total_line_amount != OMIT
  @tracking_category = tracking_category if tracking_category != OMIT
  @tracking_categories = tracking_categories
  @account =  if  != OMIT
  @company = company if company != 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,
    "total_line_amount": total_line_amount,
    "tracking_category": tracking_category,
    "tracking_categories": tracking_categories,
    "account": ,
    "company": company,
    "remote_was_deleted": remote_was_deleted
  }.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.



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

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



46
47
48
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 46

def additional_properties
  @additional_properties
end

#companyMerge::Accounting::CreditNoteLineItemCompany (readonly)

Returns The company the credit note belongs to.

Returns:



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

def company
  @company
end

#created_atDateTime (readonly)

Returns The datetime that this object was created by Merge.

Returns:

  • (DateTime)

    The datetime that this object was created by Merge.



17
18
19
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 17

def created_at
  @created_at
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.rb', line 25

def description
  @description
end

#idString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 13

def id
  @id
end

#itemMerge::Accounting::CreditNoteLineItemItem (readonly)



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

def item
  @item
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.rb', line 29

def memo
  @memo
end

#modified_atDateTime (readonly)

Returns The datetime that this object was modified by Merge.

Returns:

  • (DateTime)

    The datetime that this object was modified by Merge.



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

def modified_at
  @modified_at
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.rb', line 23

def name
  @name
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.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.



15
16
17
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 15

def remote_id
  @remote_id
end

#remote_was_deletedBoolean (readonly)

Returns Indicates whether or not this object has been deleted in the third party platform.

Returns:

  • (Boolean)

    Indicates whether or not this object has been deleted in the third party platform.



44
45
46
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 44

def remote_was_deleted
  @remote_was_deleted
end

#total_line_amountString (readonly)

Returns The credit note line item’s total.

Returns:

  • (String)

    The credit note line item’s total.



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

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.



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

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.



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

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.rb', line 31

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

Parameters:

  • json_object (String)

Returns:



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
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 117

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"]
  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::CreditNoteLineItemCompany.from_json(json_object: company)
  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,
    total_line_amount: total_line_amount,
    tracking_category: tracking_category,
    tracking_categories: tracking_categories,
    account: ,
    company: company,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 180

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.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::CreditNoteLineItemCompany.validate_raw(obj: obj.company)
  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

Returns:

  • (String)


170
171
172
# File 'lib/merge_ruby_client/accounting/types/credit_note_line_item.rb', line 170

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