Class: Merge::Accounting::PaymentLineItem

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

Overview

# The PaymentLineItem Object

### Description
The `PaymentLineItem` object is an applied-to-line on a `Payment` that can
either be a `Invoice`, `CreditNote`, or `JournalEntry`.
### Usage Example
`Payment` will have a field called `applied-to-lines` which will be an array of
`PaymentLineItemInternalMappingSerializer` objects that can either be a
`Invoice`, `CreditNote`, or `JournalEntry`.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, applied_amount: OMIT, applied_date: OMIT, related_object_id: OMIT, related_object_type: OMIT, additional_properties: nil) ⇒ Merge::Accounting::PaymentLineItem

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.

  • applied_amount (String) (defaults to: OMIT)

    The amount being applied to the transaction.

  • applied_date (DateTime) (defaults to: OMIT)

    The date the payment portion is applied.

  • related_object_id (String) (defaults to: OMIT)

    The Merge ID of the transaction the payment portion is being applied to.

  • related_object_type (String) (defaults to: OMIT)

    The type of transaction the payment portion is being applied to. Possible values include: INVOICE, JOURNAL_ENTRY, or CREDIT_NOTE.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/merge_ruby_client/accounting/types/payment_line_item.rb', line 54

def initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, applied_amount: OMIT,
               applied_date: OMIT, related_object_id: OMIT, related_object_type: 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
  @applied_amount = applied_amount if applied_amount != OMIT
  @applied_date = applied_date if applied_date != OMIT
  @related_object_id = related_object_id if related_object_id != OMIT
  @related_object_type = related_object_type if related_object_type != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "remote_id": remote_id,
    "created_at": created_at,
    "modified_at": modified_at,
    "applied_amount": applied_amount,
    "applied_date": applied_date,
    "related_object_id": related_object_id,
    "related_object_type": related_object_type
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



36
37
38
# File 'lib/merge_ruby_client/accounting/types/payment_line_item.rb', line 36

def additional_properties
  @additional_properties
end

#applied_amountString (readonly)

Returns The amount being applied to the transaction.

Returns:

  • (String)

    The amount being applied to the transaction.



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

def applied_amount
  @applied_amount
end

#applied_dateDateTime (readonly)

Returns The date the payment portion is applied.

Returns:

  • (DateTime)

    The date the payment portion is applied.



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

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



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

def created_at
  @created_at
end

#idString (readonly)

Returns:

  • (String)


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

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



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

def modified_at
  @modified_at
end

Returns The Merge ID of the transaction the payment portion is being applied to.

Returns:

  • (String)

    The Merge ID of the transaction the payment portion is being applied to.



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

def related_object_id
  @related_object_id
end

Returns The type of transaction the payment portion is being applied to. Possible values include: INVOICE, JOURNAL_ENTRY, or CREDIT_NOTE.

Returns:

  • (String)

    The type of transaction the payment portion is being applied to. Possible values include: INVOICE, JOURNAL_ENTRY, or CREDIT_NOTE.



34
35
36
# File 'lib/merge_ruby_client/accounting/types/payment_line_item.rb', line 34

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



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

def remote_id
  @remote_id
end

Class Method Details

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

Deserialize a JSON object to an instance of PaymentLineItem

Parameters:

  • json_object (String)

Returns:



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/merge_ruby_client/accounting/types/payment_line_item.rb', line 83

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?)
  applied_amount = parsed_json["applied_amount"]
  applied_date = (DateTime.parse(parsed_json["applied_date"]) unless parsed_json["applied_date"].nil?)
  related_object_id = parsed_json["related_object_id"]
  related_object_type = parsed_json["related_object_type"]
  new(
    id: id,
    remote_id: remote_id,
    created_at: created_at,
    modified_at: modified_at,
    applied_amount: applied_amount,
    applied_date: applied_date,
    related_object_id: related_object_id,
    related_object_type: related_object_type,
    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)


120
121
122
123
124
125
126
127
128
129
# File 'lib/merge_ruby_client/accounting/types/payment_line_item.rb', line 120

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.applied_amount&.is_a?(String) != false || raise("Passed value for field obj.applied_amount is not the expected type, validation failed.")
  obj.applied_date&.is_a?(DateTime) != false || raise("Passed value for field obj.applied_date is not the expected type, validation failed.")
  obj.related_object_id&.is_a?(String) != false || raise("Passed value for field obj.related_object_id is not the expected type, validation failed.")
  obj.related_object_type&.is_a?(String) != false || raise("Passed value for field obj.related_object_type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PaymentLineItem to a JSON object

Returns:

  • (String)


110
111
112
# File 'lib/merge_ruby_client/accounting/types/payment_line_item.rb', line 110

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