merge_accounting_client 1.0.8 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +238 -224
  3. data/docs/Account.md +5 -1
  4. data/docs/AccountIntegration.md +8 -2
  5. data/docs/AccountingAttachment.md +5 -1
  6. data/docs/AccountingPeriod.md +30 -0
  7. data/docs/AccountingPeriodStatusEnum.md +15 -0
  8. data/docs/AccountingPeriodsApi.md +167 -0
  9. data/docs/AccountingPhoneNumber.md +5 -1
  10. data/docs/AccountsApi.md +4 -4
  11. data/docs/Address.md +6 -2
  12. data/docs/AddressRequest.md +34 -0
  13. data/docs/AsyncPassthroughApi.md +155 -0
  14. data/docs/AsyncPassthroughReciept.md +18 -0
  15. data/docs/AttachmentsApi.md +4 -4
  16. data/docs/AuditLogEvent.md +32 -0
  17. data/docs/AuditTrailApi.md +91 -0
  18. data/docs/BalanceSheet.md +5 -1
  19. data/docs/BalanceSheetsApi.md +4 -4
  20. data/docs/CashFlowStatement.md +5 -1
  21. data/docs/CashFlowStatementsApi.md +4 -4
  22. data/docs/CompanyInfo.md +6 -2
  23. data/docs/CompanyInfoApi.md +4 -4
  24. data/docs/Contact.md +6 -2
  25. data/docs/ContactRequest.md +1 -1
  26. data/docs/ContactsApi.md +8 -4
  27. data/docs/CreditNote.md +14 -2
  28. data/docs/CreditNoteLineItem.md +9 -1
  29. data/docs/CreditNotesApi.md +6 -6
  30. data/docs/DeleteAccountApi.md +9 -9
  31. data/docs/EndUserDetailsRequest.md +2 -2
  32. data/docs/EventTypeEnum.md +15 -0
  33. data/docs/Expense.md +14 -2
  34. data/docs/ExpenseLine.md +11 -1
  35. data/docs/ExpenseLineRequest.md +2 -0
  36. data/docs/ExpenseRequest.md +9 -1
  37. data/docs/ExpensesApi.md +4 -4
  38. data/docs/ForceResyncApi.md +1 -1
  39. data/docs/IncomeStatement.md +5 -1
  40. data/docs/IncomeStatementsApi.md +4 -4
  41. data/docs/Invoice.md +18 -4
  42. data/docs/InvoiceLineItem.md +7 -1
  43. data/docs/InvoiceRequest.md +7 -1
  44. data/docs/InvoiceStatusEnum.md +15 -0
  45. data/docs/InvoicesApi.md +6 -6
  46. data/docs/Issue.md +2 -2
  47. data/docs/IssuesApi.md +6 -6
  48. data/docs/Item.md +5 -1
  49. data/docs/ItemsApi.md +4 -4
  50. data/docs/JournalEntriesApi.md +6 -6
  51. data/docs/JournalEntry.md +13 -1
  52. data/docs/JournalEntryRequest.md +4 -0
  53. data/docs/JournalLine.md +13 -1
  54. data/docs/JournalLineRequest.md +4 -0
  55. data/docs/LinkedAccountsApi.md +2 -2
  56. data/docs/MetaResponse.md +2 -2
  57. data/docs/PaginatedAccountingPeriodList.md +22 -0
  58. data/docs/PaginatedAuditLogEventList.md +22 -0
  59. data/docs/Payment.md +11 -1
  60. data/docs/PaymentLineItem.md +32 -0
  61. data/docs/PaymentLineItemRequest.md +30 -0
  62. data/docs/PaymentRequest.md +6 -0
  63. data/docs/PaymentsApi.md +4 -4
  64. data/docs/PurchaseOrder.md +13 -3
  65. data/docs/PurchaseOrderLineItem.md +9 -1
  66. data/docs/PurchaseOrderRequest.md +2 -0
  67. data/docs/PurchaseOrdersApi.md +6 -6
  68. data/docs/RemoteData.md +1 -1
  69. data/docs/ReportItem.md +5 -1
  70. data/docs/RoleEnum.md +15 -0
  71. data/docs/SyncStatus.md +1 -1
  72. data/docs/SyncStatusApi.md +15 -11
  73. data/docs/TaxRate.md +5 -1
  74. data/docs/TaxRatesApi.md +4 -4
  75. data/docs/TrackingCategoriesApi.md +4 -4
  76. data/docs/TrackingCategory.md +5 -1
  77. data/docs/Transaction.md +9 -3
  78. data/docs/TransactionLineItem.md +9 -1
  79. data/docs/TransactionsApi.md +4 -4
  80. data/docs/VendorCredit.md +10 -2
  81. data/docs/VendorCreditLine.md +9 -1
  82. data/docs/VendorCreditsApi.md +6 -6
  83. data/git_push.sh +58 -0
  84. data/lib/merge_accounting_client/api/accounting_periods_api.rb +167 -0
  85. data/lib/merge_accounting_client/api/accounts_api.rb +4 -4
  86. data/lib/merge_accounting_client/api/async_passthrough_api.rb +160 -0
  87. data/lib/merge_accounting_client/api/attachments_api.rb +4 -4
  88. data/lib/merge_accounting_client/api/audit_trail_api.rb +95 -0
  89. data/lib/merge_accounting_client/api/balance_sheets_api.rb +4 -4
  90. data/lib/merge_accounting_client/api/cash_flow_statements_api.rb +4 -4
  91. data/lib/merge_accounting_client/api/company_info_api.rb +4 -4
  92. data/lib/merge_accounting_client/api/contacts_api.rb +10 -4
  93. data/lib/merge_accounting_client/api/credit_notes_api.rb +6 -6
  94. data/lib/merge_accounting_client/api/delete_account_api.rb +7 -7
  95. data/lib/merge_accounting_client/api/expenses_api.rb +6 -6
  96. data/lib/merge_accounting_client/api/force_resync_api.rb +2 -2
  97. data/lib/merge_accounting_client/api/income_statements_api.rb +4 -4
  98. data/lib/merge_accounting_client/api/invoices_api.rb +6 -6
  99. data/lib/merge_accounting_client/api/issues_api.rb +6 -6
  100. data/lib/merge_accounting_client/api/items_api.rb +4 -4
  101. data/lib/merge_accounting_client/api/journal_entries_api.rb +6 -6
  102. data/lib/merge_accounting_client/api/linked_accounts_api.rb +3 -3
  103. data/lib/merge_accounting_client/api/payments_api.rb +6 -6
  104. data/lib/merge_accounting_client/api/purchase_orders_api.rb +6 -6
  105. data/lib/merge_accounting_client/api/sync_status_api.rb +2 -2
  106. data/lib/merge_accounting_client/api/tax_rates_api.rb +4 -4
  107. data/lib/merge_accounting_client/api/tracking_categories_api.rb +4 -4
  108. data/lib/merge_accounting_client/api/transactions_api.rb +6 -6
  109. data/lib/merge_accounting_client/api/vendor_credits_api.rb +6 -6
  110. data/lib/merge_accounting_client/configuration.rb +4 -0
  111. data/lib/merge_accounting_client/models/account.rb +22 -3
  112. data/lib/merge_accounting_client/models/account_integration.rb +37 -4
  113. data/lib/merge_accounting_client/models/account_request.rb +1 -1
  114. data/lib/merge_accounting_client/models/accounting_attachment.rb +21 -2
  115. data/lib/merge_accounting_client/models/accounting_period.rb +296 -0
  116. data/lib/merge_accounting_client/models/accounting_period_status_enum.rb +45 -0
  117. data/lib/merge_accounting_client/models/accounting_phone_number.rb +24 -5
  118. data/lib/merge_accounting_client/models/address.rb +24 -5
  119. data/lib/merge_accounting_client/models/address_request.rb +311 -0
  120. data/lib/merge_accounting_client/models/async_passthrough_reciept.rb +223 -0
  121. data/lib/merge_accounting_client/models/audit_log_event.rb +356 -0
  122. data/lib/merge_accounting_client/models/balance_sheet.rb +21 -2
  123. data/lib/merge_accounting_client/models/cash_flow_statement.rb +21 -2
  124. data/lib/merge_accounting_client/models/company_info.rb +22 -3
  125. data/lib/merge_accounting_client/models/contact.rb +23 -4
  126. data/lib/merge_accounting_client/models/contact_request.rb +2 -2
  127. data/lib/merge_accounting_client/models/credit_note.rb +84 -3
  128. data/lib/merge_accounting_client/models/credit_note_line_item.rb +43 -5
  129. data/lib/merge_accounting_client/models/end_user_details_request.rb +2 -2
  130. data/lib/merge_accounting_client/models/event_type_enum.rb +67 -0
  131. data/lib/merge_accounting_client/models/expense.rb +66 -3
  132. data/lib/merge_accounting_client/models/expense_line.rb +54 -5
  133. data/lib/merge_accounting_client/models/expense_line_request.rb +12 -1
  134. data/lib/merge_accounting_client/models/expense_request.rb +46 -2
  135. data/lib/merge_accounting_client/models/income_statement.rb +21 -2
  136. data/lib/merge_accounting_client/models/invoice.rb +84 -9
  137. data/lib/merge_accounting_client/models/invoice_line_item.rb +31 -2
  138. data/lib/merge_accounting_client/models/invoice_line_item_request.rb +1 -1
  139. data/lib/merge_accounting_client/models/invoice_request.rb +35 -2
  140. data/lib/merge_accounting_client/models/invoice_status_enum.rb +49 -0
  141. data/lib/merge_accounting_client/models/issue.rb +1 -0
  142. data/lib/merge_accounting_client/models/item.rb +21 -2
  143. data/lib/merge_accounting_client/models/journal_entry.rb +81 -2
  144. data/lib/merge_accounting_client/models/journal_entry_request.rb +38 -1
  145. data/lib/merge_accounting_client/models/journal_line.rb +65 -5
  146. data/lib/merge_accounting_client/models/journal_line_request.rb +23 -1
  147. data/lib/merge_accounting_client/models/paginated_accounting_period_list.rb +240 -0
  148. data/lib/merge_accounting_client/models/paginated_audit_log_event_list.rb +240 -0
  149. data/lib/merge_accounting_client/models/payment.rb +55 -2
  150. data/lib/merge_accounting_client/models/payment_line_item.rb +308 -0
  151. data/lib/merge_accounting_client/models/payment_line_item_request.rb +319 -0
  152. data/lib/merge_accounting_client/models/payment_request.rb +35 -1
  153. data/lib/merge_accounting_client/models/purchase_order.rb +70 -3
  154. data/lib/merge_accounting_client/models/purchase_order_line_item.rb +43 -5
  155. data/lib/merge_accounting_client/models/purchase_order_request.rb +12 -1
  156. data/lib/merge_accounting_client/models/remote_data.rb +3 -4
  157. data/lib/merge_accounting_client/models/report_item.rb +24 -5
  158. data/lib/merge_accounting_client/models/role_enum.rb +49 -0
  159. data/lib/merge_accounting_client/models/sync_status_status_enum.rb +1 -1
  160. data/lib/merge_accounting_client/models/tax_rate.rb +21 -2
  161. data/lib/merge_accounting_client/models/tracking_category.rb +22 -3
  162. data/lib/merge_accounting_client/models/transaction.rb +33 -3
  163. data/lib/merge_accounting_client/models/transaction_line_item.rb +43 -5
  164. data/lib/merge_accounting_client/models/vendor_credit.rb +44 -3
  165. data/lib/merge_accounting_client/models/vendor_credit_line.rb +43 -5
  166. data/lib/merge_accounting_client/version.rb +1 -1
  167. data/lib/merge_accounting_client.rb +15 -7
  168. data/spec/api/accounting_periods_api_spec.rb +63 -0
  169. data/spec/api/accounts_api_spec.rb +2 -2
  170. data/spec/api/async_passthrough_api_spec.rb +59 -0
  171. data/spec/api/attachments_api_spec.rb +2 -2
  172. data/spec/api/audit_trail_api_spec.rb +51 -0
  173. data/spec/api/balance_sheets_api_spec.rb +2 -2
  174. data/spec/api/cash_flow_statements_api_spec.rb +2 -2
  175. data/spec/api/company_info_api_spec.rb +2 -2
  176. data/spec/api/contacts_api_spec.rb +4 -2
  177. data/spec/api/credit_notes_api_spec.rb +2 -2
  178. data/spec/api/delete_account_api_spec.rb +2 -2
  179. data/spec/api/expenses_api_spec.rb +2 -2
  180. data/spec/api/force_resync_api_spec.rb +1 -1
  181. data/spec/api/income_statements_api_spec.rb +2 -2
  182. data/spec/api/invoices_api_spec.rb +2 -2
  183. data/spec/api/issues_api_spec.rb +3 -3
  184. data/spec/api/items_api_spec.rb +2 -2
  185. data/spec/api/journal_entries_api_spec.rb +2 -2
  186. data/spec/api/linked_accounts_api_spec.rb +1 -1
  187. data/spec/api/payments_api_spec.rb +2 -2
  188. data/spec/api/purchase_orders_api_spec.rb +2 -2
  189. data/spec/api/sync_status_api_spec.rb +1 -1
  190. data/spec/api/tax_rates_api_spec.rb +2 -2
  191. data/spec/api/tracking_categories_api_spec.rb +2 -2
  192. data/spec/api/transactions_api_spec.rb +2 -2
  193. data/spec/api/vendor_credits_api_spec.rb +2 -2
  194. data/spec/models/account_integration_spec.rb +18 -0
  195. data/spec/models/account_spec.rb +12 -0
  196. data/spec/models/accounting_attachment_spec.rb +12 -0
  197. data/spec/models/accounting_period_spec.rb +70 -0
  198. data/spec/models/accounting_period_status_enum_spec.rb +28 -0
  199. data/spec/models/accounting_phone_number_spec.rb +12 -0
  200. data/spec/models/address_request_spec.rb +82 -0
  201. data/spec/models/address_spec.rb +12 -0
  202. data/spec/models/async_passthrough_reciept_spec.rb +34 -0
  203. data/spec/models/audit_log_event_spec.rb +76 -0
  204. data/spec/models/balance_sheet_spec.rb +12 -0
  205. data/spec/models/cash_flow_statement_spec.rb +12 -0
  206. data/spec/models/company_info_spec.rb +12 -0
  207. data/spec/models/contact_spec.rb +12 -0
  208. data/spec/models/credit_note_line_item_spec.rb +24 -0
  209. data/spec/models/credit_note_spec.rb +36 -0
  210. data/spec/models/event_type_enum_spec.rb +28 -0
  211. data/spec/models/expense_line_request_spec.rb +6 -0
  212. data/spec/models/expense_line_spec.rb +30 -0
  213. data/spec/models/expense_request_spec.rb +24 -0
  214. data/spec/models/expense_spec.rb +36 -0
  215. data/spec/models/income_statement_spec.rb +12 -0
  216. data/spec/models/invoice_line_item_spec.rb +18 -0
  217. data/spec/models/invoice_request_spec.rb +18 -0
  218. data/spec/models/invoice_spec.rb +43 -1
  219. data/spec/models/invoice_status_enum_spec.rb +28 -0
  220. data/spec/models/item_spec.rb +12 -0
  221. data/spec/models/journal_entry_request_spec.rb +12 -0
  222. data/spec/models/journal_entry_spec.rb +36 -0
  223. data/spec/models/journal_line_request_spec.rb +12 -0
  224. data/spec/models/journal_line_spec.rb +36 -0
  225. data/spec/models/paginated_accounting_period_list_spec.rb +46 -0
  226. data/spec/models/paginated_audit_log_event_list_spec.rb +46 -0
  227. data/spec/models/payment_line_item_request_spec.rb +70 -0
  228. data/spec/models/payment_line_item_spec.rb +76 -0
  229. data/spec/models/payment_request_spec.rb +18 -0
  230. data/spec/models/payment_spec.rb +30 -0
  231. data/spec/models/purchase_order_line_item_spec.rb +24 -0
  232. data/spec/models/purchase_order_request_spec.rb +6 -0
  233. data/spec/models/purchase_order_spec.rb +30 -0
  234. data/spec/models/report_item_spec.rb +12 -0
  235. data/spec/models/role_enum_spec.rb +28 -0
  236. data/spec/models/tax_rate_spec.rb +12 -0
  237. data/spec/models/tracking_category_spec.rb +12 -0
  238. data/spec/models/transaction_line_item_spec.rb +24 -0
  239. data/spec/models/transaction_spec.rb +18 -0
  240. data/spec/models/vendor_credit_line_spec.rb +24 -0
  241. data/spec/models/vendor_credit_spec.rb +24 -0
  242. metadata +211 -150
@@ -0,0 +1,308 @@
1
+ =begin
2
+ #Merge Accounting API
3
+
4
+ #The unified API for building rich integrations with multiple Accounting & Finance platforms.
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: hello@merge.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MergeAccountingClient
17
+ # # 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`.
18
+ class PaymentLineItem
19
+ # The amount being applied to the transaction.
20
+ attr_accessor :applied_amount
21
+
22
+ # The date the payment portion is applied.
23
+ attr_accessor :applied_date
24
+
25
+ # The third-party API ID of the matching object.
26
+ attr_accessor :remote_id
27
+
28
+ # The Merge ID of the transaction the payment portion is being applied to.
29
+ attr_accessor :related_object_id
30
+
31
+ # The type of transaction the payment portion is being applied to. Possible values include: INVOICE, JOURNAL_ENTRY, or CREDIT_NOTE.
32
+ attr_accessor :related_object_type
33
+
34
+ attr_accessor :id
35
+
36
+ attr_accessor :created_at
37
+
38
+ # This is the datetime that this object was last updated by Merge
39
+ attr_accessor :modified_at
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'applied_amount' => :'applied_amount',
45
+ :'applied_date' => :'applied_date',
46
+ :'remote_id' => :'remote_id',
47
+ :'related_object_id' => :'related_object_id',
48
+ :'related_object_type' => :'related_object_type',
49
+ :'id' => :'id',
50
+ :'created_at' => :'created_at',
51
+ :'modified_at' => :'modified_at'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'applied_amount' => :'String',
64
+ :'applied_date' => :'Time',
65
+ :'remote_id' => :'String',
66
+ :'related_object_id' => :'String',
67
+ :'related_object_type' => :'String',
68
+ :'id' => :'String',
69
+ :'created_at' => :'Time',
70
+ :'modified_at' => :'Time'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ :'applied_amount',
78
+ :'applied_date',
79
+ :'remote_id',
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MergeAccountingClient::PaymentLineItem` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h|
92
+ if (!self.class.attribute_map.key?(k.to_sym))
93
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MergeAccountingClient::PaymentLineItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
+ end
95
+ h[k.to_sym] = v
96
+ }
97
+
98
+ if attributes.key?(:'applied_amount')
99
+ self.applied_amount = attributes[:'applied_amount']
100
+ end
101
+
102
+ if attributes.key?(:'applied_date')
103
+ self.applied_date = attributes[:'applied_date']
104
+ end
105
+
106
+ if attributes.key?(:'remote_id')
107
+ self.remote_id = attributes[:'remote_id']
108
+ end
109
+
110
+ if attributes.key?(:'related_object_id')
111
+ self.related_object_id = attributes[:'related_object_id']
112
+ end
113
+
114
+ if attributes.key?(:'related_object_type')
115
+ self.related_object_type = attributes[:'related_object_type']
116
+ end
117
+
118
+ if attributes.key?(:'id')
119
+ self.id = attributes[:'id']
120
+ end
121
+
122
+ if attributes.key?(:'created_at')
123
+ self.created_at = attributes[:'created_at']
124
+ end
125
+
126
+ if attributes.key?(:'modified_at')
127
+ self.modified_at = attributes[:'modified_at']
128
+ end
129
+ end
130
+
131
+ # Show invalid properties with the reasons. Usually used together with valid?
132
+ # @return Array for valid properties with the reasons
133
+ def list_invalid_properties
134
+ invalid_properties = Array.new
135
+ pattern = Regexp.new(/^-?\d{0,32}(?:\.\d{0,16})?$/)
136
+ if !@applied_amount.nil? && @applied_amount.to_s !~ pattern
137
+ invalid_properties.push("invalid value for \"applied_amount\", must conform to the pattern #{pattern}.")
138
+ end
139
+
140
+ invalid_properties
141
+ end
142
+
143
+ # Check to see if the all the properties in the model are valid
144
+ # @return true if the model is valid
145
+ def valid?
146
+ return false if !@applied_amount.nil? && @applied_amount.to_s !~ Regexp.new(/^-?\d{0,32}(?:\.\d{0,16})?$/)
147
+ true
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] applied_amount Value to be assigned
152
+ def applied_amount=(applied_amount)
153
+ pattern = Regexp.new(/^-?\d{0,32}(?:\.\d{0,16})?$/)
154
+ if !applied_amount.nil? && applied_amount.to_s !~ pattern
155
+ fail ArgumentError, "invalid value for \"applied_amount\", must conform to the pattern #{pattern}."
156
+ end
157
+
158
+ @applied_amount = applied_amount
159
+ end
160
+
161
+ # Checks equality by comparing each attribute.
162
+ # @param [Object] Object to be compared
163
+ def ==(o)
164
+ return true if self.equal?(o)
165
+ self.class == o.class &&
166
+ applied_amount == o.applied_amount &&
167
+ applied_date == o.applied_date &&
168
+ remote_id == o.remote_id &&
169
+ related_object_id == o.related_object_id &&
170
+ related_object_type == o.related_object_type &&
171
+ id == o.id &&
172
+ created_at == o.created_at &&
173
+ modified_at == o.modified_at
174
+ end
175
+
176
+ # @see the `==` method
177
+ # @param [Object] Object to be compared
178
+ def eql?(o)
179
+ self == o
180
+ end
181
+
182
+ # Calculates hash code according to all attributes.
183
+ # @return [Integer] Hash code
184
+ def hash
185
+ [applied_amount, applied_date, remote_id, related_object_id, related_object_type, id, created_at, modified_at].hash
186
+ end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def self.build_from_hash(attributes)
192
+ new.build_from_hash(attributes)
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def build_from_hash(attributes)
199
+ return nil unless attributes.is_a?(Hash)
200
+ self.class.openapi_types.each_pair do |key, type|
201
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
202
+ self.send("#{key}=", nil)
203
+ elsif type =~ /\AArray<(.*)>/i
204
+ # check to ensure the input is an array given that the attribute
205
+ # is documented as an array but the input is not
206
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
207
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
208
+ end
209
+ elsif !attributes[self.class.attribute_map[key]].nil?
210
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
211
+ end
212
+ end
213
+
214
+ self
215
+ end
216
+
217
+ # Deserializes the data based on type
218
+ # @param string type Data type
219
+ # @param string value Value to be deserialized
220
+ # @return [Object] Deserialized data
221
+ def _deserialize(type, value)
222
+ case type.to_sym
223
+ when :Time
224
+ Time.parse(value)
225
+ when :Date
226
+ Date.parse(value)
227
+ when :String
228
+ value
229
+ when :Integer
230
+ value.to_i
231
+ when :Float
232
+ value.to_f
233
+ when :Boolean
234
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
235
+ true
236
+ else
237
+ false
238
+ end
239
+ when :Object
240
+ # generic object (usually a Hash), return directly
241
+ value
242
+ when /\AArray<(?<inner_type>.+)>\z/
243
+ inner_type = Regexp.last_match[:inner_type]
244
+ value.map { |v| _deserialize(inner_type, v) }
245
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
246
+ k_type = Regexp.last_match[:k_type]
247
+ v_type = Regexp.last_match[:v_type]
248
+ {}.tap do |hash|
249
+ value.each do |k, v|
250
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
251
+ end
252
+ end
253
+ else # model
254
+ # models (e.g. Pet) or oneOf
255
+ klass = MergeAccountingClient.const_get(type)
256
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
257
+ end
258
+ end
259
+
260
+ # Returns the string representation of the object
261
+ # @return [String] String presentation of the object
262
+ def to_s
263
+ to_hash.to_s
264
+ end
265
+
266
+ # to_body is an alias to to_hash (backward compatibility)
267
+ # @return [Hash] Returns the object in the form of hash
268
+ def to_body
269
+ to_hash
270
+ end
271
+
272
+ # Returns the object in the form of hash
273
+ # @return [Hash] Returns the object in the form of hash
274
+ def to_hash
275
+ hash = {}
276
+ self.class.attribute_map.each_pair do |attr, param|
277
+ value = self.send(attr)
278
+ if value.nil?
279
+ is_nullable = self.class.openapi_nullable.include?(attr)
280
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
281
+ end
282
+
283
+ hash[param] = _to_hash(value)
284
+ end
285
+ hash
286
+ end
287
+
288
+ # Outputs non-array value in the form of hash
289
+ # For object, use to_hash. Otherwise, just return the value
290
+ # @param [Object] value Any valid value
291
+ # @return [Hash] Returns the value in the form of hash
292
+ def _to_hash(value)
293
+ if value.is_a?(Array)
294
+ value.compact.map { |v| _to_hash(v) }
295
+ elsif value.is_a?(Hash)
296
+ {}.tap do |hash|
297
+ value.each { |k, v| hash[k] = _to_hash(v) }
298
+ end
299
+ elsif value.respond_to? :to_hash
300
+ value.to_hash
301
+ else
302
+ value
303
+ end
304
+ end
305
+
306
+ end
307
+
308
+ end
@@ -0,0 +1,319 @@
1
+ =begin
2
+ #Merge Accounting API
3
+
4
+ #The unified API for building rich integrations with multiple Accounting & Finance platforms.
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: hello@merge.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module MergeAccountingClient
17
+ # # 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`.
18
+ class PaymentLineItemRequest
19
+ # The amount being applied to the transaction.
20
+ attr_accessor :applied_amount
21
+
22
+ # The date the payment portion is applied.
23
+ attr_accessor :applied_date
24
+
25
+ # The third-party API ID of the matching object.
26
+ attr_accessor :remote_id
27
+
28
+ # The Merge ID of the transaction the payment portion is being applied to.
29
+ attr_accessor :related_object_id
30
+
31
+ # The type of transaction the payment portion is being applied to. Possible values include: INVOICE, JOURNAL_ENTRY, or CREDIT_NOTE.
32
+ attr_accessor :related_object_type
33
+
34
+ attr_accessor :integration_params
35
+
36
+ attr_accessor :linked_account_params
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'applied_amount' => :'applied_amount',
42
+ :'applied_date' => :'applied_date',
43
+ :'remote_id' => :'remote_id',
44
+ :'related_object_id' => :'related_object_id',
45
+ :'related_object_type' => :'related_object_type',
46
+ :'integration_params' => :'integration_params',
47
+ :'linked_account_params' => :'linked_account_params'
48
+ }
49
+ end
50
+
51
+ # Returns all the JSON keys this model knows about
52
+ def self.acceptable_attributes
53
+ attribute_map.values
54
+ end
55
+
56
+ # Attribute type mapping.
57
+ def self.openapi_types
58
+ {
59
+ :'applied_amount' => :'String',
60
+ :'applied_date' => :'Time',
61
+ :'remote_id' => :'String',
62
+ :'related_object_id' => :'String',
63
+ :'related_object_type' => :'String',
64
+ :'integration_params' => :'Hash<String, Object>',
65
+ :'linked_account_params' => :'Hash<String, Object>'
66
+ }
67
+ end
68
+
69
+ # List of attributes with nullable: true
70
+ def self.openapi_nullable
71
+ Set.new([
72
+ :'applied_amount',
73
+ :'applied_date',
74
+ :'remote_id',
75
+ :'integration_params',
76
+ :'linked_account_params'
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MergeAccountingClient::PaymentLineItemRequest` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MergeAccountingClient::PaymentLineItemRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'applied_amount')
96
+ self.applied_amount = attributes[:'applied_amount']
97
+ end
98
+
99
+ if attributes.key?(:'applied_date')
100
+ self.applied_date = attributes[:'applied_date']
101
+ end
102
+
103
+ if attributes.key?(:'remote_id')
104
+ self.remote_id = attributes[:'remote_id']
105
+ end
106
+
107
+ if attributes.key?(:'related_object_id')
108
+ self.related_object_id = attributes[:'related_object_id']
109
+ end
110
+
111
+ if attributes.key?(:'related_object_type')
112
+ self.related_object_type = attributes[:'related_object_type']
113
+ end
114
+
115
+ if attributes.key?(:'integration_params')
116
+ if (value = attributes[:'integration_params']).is_a?(Hash)
117
+ self.integration_params = value
118
+ end
119
+ end
120
+
121
+ if attributes.key?(:'linked_account_params')
122
+ if (value = attributes[:'linked_account_params']).is_a?(Hash)
123
+ self.linked_account_params = value
124
+ end
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ invalid_properties = Array.new
132
+ pattern = Regexp.new(/^-?\d{0,32}(?:\.\d{0,16})?$/)
133
+ if !@applied_amount.nil? && @applied_amount.to_s !~ pattern
134
+ invalid_properties.push("invalid value for \"applied_amount\", must conform to the pattern #{pattern}.")
135
+ end
136
+
137
+ if !@related_object_type.nil? && @related_object_type.to_s.length < 1
138
+ invalid_properties.push('invalid value for "related_object_type", the character length must be great than or equal to 1.')
139
+ end
140
+
141
+ invalid_properties
142
+ end
143
+
144
+ # Check to see if the all the properties in the model are valid
145
+ # @return true if the model is valid
146
+ def valid?
147
+ return false if !@applied_amount.nil? && @applied_amount.to_s !~ Regexp.new(/^-?\d{0,32}(?:\.\d{0,16})?$/)
148
+ return false if !@related_object_type.nil? && @related_object_type.to_s.length < 1
149
+ true
150
+ end
151
+
152
+ # Custom attribute writer method with validation
153
+ # @param [Object] applied_amount Value to be assigned
154
+ def applied_amount=(applied_amount)
155
+ pattern = Regexp.new(/^-?\d{0,32}(?:\.\d{0,16})?$/)
156
+ if !applied_amount.nil? && applied_amount.to_s !~ pattern
157
+ fail ArgumentError, "invalid value for \"applied_amount\", must conform to the pattern #{pattern}."
158
+ end
159
+
160
+ @applied_amount = applied_amount
161
+ end
162
+
163
+ # Custom attribute writer method with validation
164
+ # @param [Object] related_object_type Value to be assigned
165
+ def related_object_type=(related_object_type)
166
+ if !related_object_type.nil? && related_object_type.to_s.length < 1
167
+ fail ArgumentError, 'invalid value for "related_object_type", the character length must be great than or equal to 1.'
168
+ end
169
+
170
+ @related_object_type = related_object_type
171
+ end
172
+
173
+ # Checks equality by comparing each attribute.
174
+ # @param [Object] Object to be compared
175
+ def ==(o)
176
+ return true if self.equal?(o)
177
+ self.class == o.class &&
178
+ applied_amount == o.applied_amount &&
179
+ applied_date == o.applied_date &&
180
+ remote_id == o.remote_id &&
181
+ related_object_id == o.related_object_id &&
182
+ related_object_type == o.related_object_type &&
183
+ integration_params == o.integration_params &&
184
+ linked_account_params == o.linked_account_params
185
+ end
186
+
187
+ # @see the `==` method
188
+ # @param [Object] Object to be compared
189
+ def eql?(o)
190
+ self == o
191
+ end
192
+
193
+ # Calculates hash code according to all attributes.
194
+ # @return [Integer] Hash code
195
+ def hash
196
+ [applied_amount, applied_date, remote_id, related_object_id, related_object_type, integration_params, linked_account_params].hash
197
+ end
198
+
199
+ # Builds the object from hash
200
+ # @param [Hash] attributes Model attributes in the form of hash
201
+ # @return [Object] Returns the model itself
202
+ def self.build_from_hash(attributes)
203
+ new.build_from_hash(attributes)
204
+ end
205
+
206
+ # Builds the object from hash
207
+ # @param [Hash] attributes Model attributes in the form of hash
208
+ # @return [Object] Returns the model itself
209
+ def build_from_hash(attributes)
210
+ return nil unless attributes.is_a?(Hash)
211
+ self.class.openapi_types.each_pair do |key, type|
212
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
213
+ self.send("#{key}=", nil)
214
+ elsif type =~ /\AArray<(.*)>/i
215
+ # check to ensure the input is an array given that the attribute
216
+ # is documented as an array but the input is not
217
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
218
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
219
+ end
220
+ elsif !attributes[self.class.attribute_map[key]].nil?
221
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
222
+ end
223
+ end
224
+
225
+ self
226
+ end
227
+
228
+ # Deserializes the data based on type
229
+ # @param string type Data type
230
+ # @param string value Value to be deserialized
231
+ # @return [Object] Deserialized data
232
+ def _deserialize(type, value)
233
+ case type.to_sym
234
+ when :Time
235
+ Time.parse(value)
236
+ when :Date
237
+ Date.parse(value)
238
+ when :String
239
+ value
240
+ when :Integer
241
+ value.to_i
242
+ when :Float
243
+ value.to_f
244
+ when :Boolean
245
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
246
+ true
247
+ else
248
+ false
249
+ end
250
+ when :Object
251
+ # generic object (usually a Hash), return directly
252
+ value
253
+ when /\AArray<(?<inner_type>.+)>\z/
254
+ inner_type = Regexp.last_match[:inner_type]
255
+ value.map { |v| _deserialize(inner_type, v) }
256
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
257
+ k_type = Regexp.last_match[:k_type]
258
+ v_type = Regexp.last_match[:v_type]
259
+ {}.tap do |hash|
260
+ value.each do |k, v|
261
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
262
+ end
263
+ end
264
+ else # model
265
+ # models (e.g. Pet) or oneOf
266
+ klass = MergeAccountingClient.const_get(type)
267
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
268
+ end
269
+ end
270
+
271
+ # Returns the string representation of the object
272
+ # @return [String] String presentation of the object
273
+ def to_s
274
+ to_hash.to_s
275
+ end
276
+
277
+ # to_body is an alias to to_hash (backward compatibility)
278
+ # @return [Hash] Returns the object in the form of hash
279
+ def to_body
280
+ to_hash
281
+ end
282
+
283
+ # Returns the object in the form of hash
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_hash
286
+ hash = {}
287
+ self.class.attribute_map.each_pair do |attr, param|
288
+ value = self.send(attr)
289
+ if value.nil?
290
+ is_nullable = self.class.openapi_nullable.include?(attr)
291
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
292
+ end
293
+
294
+ hash[param] = _to_hash(value)
295
+ end
296
+ hash
297
+ end
298
+
299
+ # Outputs non-array value in the form of hash
300
+ # For object, use to_hash. Otherwise, just return the value
301
+ # @param [Object] value Any valid value
302
+ # @return [Hash] Returns the value in the form of hash
303
+ def _to_hash(value)
304
+ if value.is_a?(Array)
305
+ value.compact.map { |v| _to_hash(v) }
306
+ elsif value.is_a?(Hash)
307
+ {}.tap do |hash|
308
+ value.each { |k, v| hash[k] = _to_hash(v) }
309
+ end
310
+ elsif value.respond_to? :to_hash
311
+ value.to_hash
312
+ else
313
+ value
314
+ end
315
+ end
316
+
317
+ end
318
+
319
+ end