Class: Merge::Accounting::PaymentTerm
- Inherits:
-
Object
- Object
- Merge::Accounting::PaymentTerm
- Defined in:
- lib/merge_ruby_client/accounting/types/payment_term.rb
Overview
# The PaymentTerm Object
### Description
The `PaymentTerm` object is the agreed-upon conditions between a buyer and a
seller that define the timing,
amount, and conditions under which payment for goods or services must be made.
### Usage Example
Fetch from the `GET PaymentTerm` endpoint and view payment term information.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#company ⇒ Merge::Accounting::PaymentTermCompany
readonly
The subsidiary that the payment term belongs to.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
-
#days_until_due ⇒ Integer
readonly
The number of days after the invoice date that payment is due.
-
#discount_days ⇒ Integer
readonly
The number of days the invoice must be paid before discounts expire.
- #field_mappings ⇒ Hash{String => Object} readonly
- #id ⇒ String readonly
-
#is_active ⇒ Boolean
readonly
Trueif the payment term is active,Falseif not. -
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
-
#name ⇒ String
readonly
The name of the payment term.
- #remote_data ⇒ Array<Merge::Accounting::RemoteData> readonly
-
#remote_id ⇒ String
readonly
The third-party API ID of the matching object.
-
#remote_last_modified_at ⇒ DateTime
readonly
When the third party’s payment term was modified.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Accounting::PaymentTerm
Deserialize a JSON object to an instance of PaymentTerm.
-
.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(name:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, is_active: OMIT, company: OMIT, days_until_due: OMIT, discount_days: OMIT, remote_last_modified_at: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) ⇒ Merge::Accounting::PaymentTerm constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of PaymentTerm to a JSON object.
Constructor Details
#initialize(name:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, is_active: OMIT, company: OMIT, days_until_due: OMIT, discount_days: OMIT, remote_last_modified_at: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) ⇒ Merge::Accounting::PaymentTerm
65 66 67 68 69 70 71 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 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 65 def initialize(name:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, is_active: OMIT, company: OMIT, days_until_due: OMIT, discount_days: OMIT, remote_last_modified_at: OMIT, field_mappings: OMIT, remote_data: 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 @name = name @is_active = is_active if is_active != OMIT @company = company if company != OMIT @days_until_due = days_until_due if days_until_due != OMIT @discount_days = discount_days if discount_days != OMIT @remote_last_modified_at = remote_last_modified_at if remote_last_modified_at != OMIT @field_mappings = field_mappings if field_mappings != OMIT @remote_data = remote_data if remote_data != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "remote_id": remote_id, "created_at": created_at, "modified_at": modified_at, "name": name, "is_active": is_active, "company": company, "days_until_due": days_until_due, "discount_days": discount_days, "remote_last_modified_at": remote_last_modified_at, "field_mappings": field_mappings, "remote_data": remote_data }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
44 45 46 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 44 def additional_properties @additional_properties end |
#company ⇒ Merge::Accounting::PaymentTermCompany (readonly)
Returns The subsidiary that the payment term belongs to.
32 33 34 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 32 def company @company 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/payment_term.rb', line 24 def created_at @created_at end |
#days_until_due ⇒ Integer (readonly)
Returns The number of days after the invoice date that payment is due.
34 35 36 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 34 def days_until_due @days_until_due end |
#discount_days ⇒ Integer (readonly)
Returns The number of days the invoice must be paid before discounts expire.
36 37 38 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 36 def discount_days @discount_days end |
#field_mappings ⇒ Hash{String => Object} (readonly)
40 41 42 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 40 def field_mappings @field_mappings end |
#id ⇒ String (readonly)
20 21 22 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 20 def id @id end |
#is_active ⇒ Boolean (readonly)
Returns True if the payment term is active, False if not.
30 31 32 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 30 def is_active @is_active 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/payment_term.rb', line 26 def modified_at @modified_at end |
#name ⇒ String (readonly)
Returns The name of the payment term.
28 29 30 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 28 def name @name end |
#remote_data ⇒ Array<Merge::Accounting::RemoteData> (readonly)
42 43 44 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 42 def remote_data @remote_data 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/payment_term.rb', line 22 def remote_id @remote_id end |
#remote_last_modified_at ⇒ DateTime (readonly)
Returns When the third party’s payment term was modified.
38 39 40 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 38 def remote_last_modified_at @remote_last_modified_at end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Accounting::PaymentTerm
Deserialize a JSON object to an instance of PaymentTerm
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 138 139 140 141 142 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 102 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?) name = parsed_json["name"] is_active = parsed_json["is_active"] if parsed_json["company"].nil? company = nil else company = parsed_json["company"].to_json company = Merge::Accounting::PaymentTermCompany.from_json(json_object: company) end days_until_due = parsed_json["days_until_due"] discount_days = parsed_json["discount_days"] remote_last_modified_at = unless parsed_json["remote_last_modified_at"].nil? DateTime.parse(parsed_json["remote_last_modified_at"]) end field_mappings = parsed_json["field_mappings"] remote_data = parsed_json["remote_data"]&.map do |item| item = item.to_json Merge::Accounting::RemoteData.from_json(json_object: item) end new( id: id, remote_id: remote_id, created_at: created_at, modified_at: modified_at, name: name, is_active: is_active, company: company, days_until_due: days_until_due, discount_days: discount_days, remote_last_modified_at: remote_last_modified_at, field_mappings: field_mappings, remote_data: remote_data, 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.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 157 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.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.is_active&.is_a?(Boolean) != false || raise("Passed value for field obj.is_active is not the expected type, validation failed.") obj.company.nil? || Merge::Accounting::PaymentTermCompany.validate_raw(obj: obj.company) obj.days_until_due&.is_a?(Integer) != false || raise("Passed value for field obj.days_until_due is not the expected type, validation failed.") obj.discount_days&.is_a?(Integer) != false || raise("Passed value for field obj.discount_days is not the expected type, validation failed.") obj.remote_last_modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.remote_last_modified_at is not the expected type, validation failed.") obj.field_mappings&.is_a?(Hash) != false || raise("Passed value for field obj.field_mappings is not the expected type, validation failed.") obj.remote_data&.is_a?(Array) != false || raise("Passed value for field obj.remote_data is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of PaymentTerm to a JSON object
147 148 149 |
# File 'lib/merge_ruby_client/accounting/types/payment_term.rb', line 147 def to_json(*_args) @_field_set&.to_json end |