merge_accounting_client 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +16 -0
  3. data/README.md +12 -5
  4. data/docs/Account.md +3 -1
  5. data/docs/AccountDetails.md +3 -1
  6. data/docs/AccountDetailsAndActions.md +2 -0
  7. data/docs/AccountingAttachment.md +1 -1
  8. data/docs/AccountsApi.md +7 -3
  9. data/docs/AddressesApi.md +3 -1
  10. data/docs/AttachmentsApi.md +2 -2
  11. data/docs/BalanceSheet.md +3 -1
  12. data/docs/BalanceSheetsApi.md +2 -2
  13. data/docs/CashFlowStatement.md +3 -1
  14. data/docs/CashFlowStatementsApi.md +2 -2
  15. data/docs/CategoryTypeEnum.md +15 -0
  16. data/docs/CompanyInfo.md +1 -1
  17. data/docs/CompanyInfoApi.md +2 -2
  18. data/docs/Contact.md +1 -1
  19. data/docs/ContactsApi.md +7 -3
  20. data/docs/CreditNote.md +7 -1
  21. data/docs/CreditNoteLineItem.md +38 -0
  22. data/docs/CreditNotesApi.md +7 -3
  23. data/docs/DataPassthroughRequest.md +3 -1
  24. data/docs/EndUserDetailsRequest.md +9 -7
  25. data/docs/Expense.md +1 -1
  26. data/docs/ExpensesApi.md +2 -2
  27. data/docs/IncomeStatement.md +3 -1
  28. data/docs/IncomeStatementsApi.md +2 -2
  29. data/docs/InvoiceLineItem.md +0 -2
  30. data/docs/InvoicesApi.md +8 -4
  31. data/docs/Item.md +1 -1
  32. data/docs/ItemsApi.md +7 -3
  33. data/docs/JournalEntriesApi.md +2 -2
  34. data/docs/JournalEntry.md +2 -0
  35. data/docs/JournalEntryRequest.md +2 -0
  36. data/docs/LinkToken.md +3 -1
  37. data/docs/LinkedAccountsApi.md +2 -0
  38. data/docs/PaginatedTransactionList.md +22 -0
  39. data/docs/Payment.md +1 -1
  40. data/docs/PaymentsApi.md +2 -2
  41. data/docs/PurchaseOrder.md +8 -2
  42. data/docs/PurchaseOrderLineItem.md +9 -1
  43. data/docs/PurchaseOrdersApi.md +7 -3
  44. data/docs/RemoteResponse.md +5 -1
  45. data/docs/ResponseTypeEnum.md +15 -0
  46. data/docs/SyncStatus.md +2 -2
  47. data/docs/SyncStatusApi.md +1 -1
  48. data/docs/TaxRate.md +1 -1
  49. data/docs/TaxRatesApi.md +2 -2
  50. data/docs/TrackingCategoriesApi.md +7 -3
  51. data/docs/TrackingCategory.md +3 -1
  52. data/docs/Transaction.md +40 -0
  53. data/docs/TransactionLineItem.md +34 -0
  54. data/docs/TransactionsApi.md +181 -0
  55. data/docs/VendorCredit.md +1 -1
  56. data/docs/VendorCreditsApi.md +2 -2
  57. data/lib/merge_accounting_client/api/accounts_api.rb +16 -2
  58. data/lib/merge_accounting_client/api/addresses_api.rb +7 -0
  59. data/lib/merge_accounting_client/api/attachments_api.rb +2 -2
  60. data/lib/merge_accounting_client/api/balance_sheets_api.rb +2 -2
  61. data/lib/merge_accounting_client/api/cash_flow_statements_api.rb +2 -2
  62. data/lib/merge_accounting_client/api/company_info_api.rb +2 -2
  63. data/lib/merge_accounting_client/api/contacts_api.rb +16 -2
  64. data/lib/merge_accounting_client/api/credit_notes_api.rb +16 -2
  65. data/lib/merge_accounting_client/api/expenses_api.rb +2 -2
  66. data/lib/merge_accounting_client/api/income_statements_api.rb +2 -2
  67. data/lib/merge_accounting_client/api/invoices_api.rb +17 -3
  68. data/lib/merge_accounting_client/api/items_api.rb +16 -2
  69. data/lib/merge_accounting_client/api/journal_entries_api.rb +2 -2
  70. data/lib/merge_accounting_client/api/linked_accounts_api.rb +3 -0
  71. data/lib/merge_accounting_client/api/payments_api.rb +2 -2
  72. data/lib/merge_accounting_client/api/purchase_orders_api.rb +16 -2
  73. data/lib/merge_accounting_client/api/sync_status_api.rb +2 -2
  74. data/lib/merge_accounting_client/api/tax_rates_api.rb +2 -2
  75. data/lib/merge_accounting_client/api/tracking_categories_api.rb +16 -2
  76. data/lib/merge_accounting_client/api/transactions_api.rb +196 -0
  77. data/lib/merge_accounting_client/api/vendor_credits_api.rb +2 -2
  78. data/lib/merge_accounting_client/api_client.rb +3 -0
  79. data/lib/merge_accounting_client/models/account.rb +12 -2
  80. data/lib/merge_accounting_client/models/account_details.rb +15 -4
  81. data/lib/merge_accounting_client/models/account_details_and_actions.rb +12 -1
  82. data/lib/merge_accounting_client/models/account_details_and_actions_status_enum.rb +17 -7
  83. data/lib/merge_accounting_client/models/account_status_enum.rb +17 -7
  84. data/lib/merge_accounting_client/models/accounting_attachment.rb +1 -1
  85. data/lib/merge_accounting_client/models/address_type_enum.rb +17 -7
  86. data/lib/merge_accounting_client/models/balance_sheet.rb +13 -2
  87. data/lib/merge_accounting_client/models/cash_flow_statement.rb +13 -2
  88. data/lib/merge_accounting_client/models/categories_enum.rb +17 -7
  89. data/lib/merge_accounting_client/models/category_enum.rb +17 -7
  90. data/lib/merge_accounting_client/models/category_type_enum.rb +45 -0
  91. data/lib/merge_accounting_client/models/classification_enum.rb +17 -7
  92. data/lib/merge_accounting_client/models/company_info.rb +1 -1
  93. data/lib/merge_accounting_client/models/contact.rb +1 -1
  94. data/lib/merge_accounting_client/models/country_enum.rb +17 -7
  95. data/lib/merge_accounting_client/models/credit_note.rb +35 -2
  96. data/lib/merge_accounting_client/models/credit_note_line_item.rb +380 -0
  97. data/lib/merge_accounting_client/models/credit_note_status_enum.rb +17 -7
  98. data/lib/merge_accounting_client/models/currency_enum.rb +17 -7
  99. data/lib/merge_accounting_client/models/data_passthrough_request.rb +14 -5
  100. data/lib/merge_accounting_client/models/encoding_enum.rb +18 -7
  101. data/lib/merge_accounting_client/models/end_user_details_request.rb +28 -11
  102. data/lib/merge_accounting_client/models/expense.rb +1 -1
  103. data/lib/merge_accounting_client/models/income_statement.rb +13 -2
  104. data/lib/merge_accounting_client/models/invoice_line_item.rb +1 -13
  105. data/lib/merge_accounting_client/models/invoice_type_enum.rb +17 -7
  106. data/lib/merge_accounting_client/models/issue_status_enum.rb +17 -7
  107. data/lib/merge_accounting_client/models/item.rb +1 -1
  108. data/lib/merge_accounting_client/models/journal_entry.rb +12 -1
  109. data/lib/merge_accounting_client/models/journal_entry_request.rb +12 -1
  110. data/lib/merge_accounting_client/models/link_token.rb +13 -4
  111. data/lib/merge_accounting_client/models/method_enum.rb +17 -7
  112. data/lib/merge_accounting_client/models/paginated_transaction_list.rb +240 -0
  113. data/lib/merge_accounting_client/models/payment.rb +1 -1
  114. data/lib/merge_accounting_client/models/purchase_order.rb +35 -2
  115. data/lib/merge_accounting_client/models/purchase_order_line_item.rb +83 -5
  116. data/lib/merge_accounting_client/models/purchase_order_status_enum.rb +17 -7
  117. data/lib/merge_accounting_client/models/remote_data.rb +1 -1
  118. data/lib/merge_accounting_client/models/remote_response.rb +27 -10
  119. data/lib/merge_accounting_client/models/request_format_enum.rb +17 -7
  120. data/lib/merge_accounting_client/models/response_type_enum.rb +45 -0
  121. data/lib/merge_accounting_client/models/state_enum.rb +17 -7
  122. data/lib/merge_accounting_client/models/status7d1_enum.rb +17 -7
  123. data/lib/merge_accounting_client/models/sync_status.rb +0 -10
  124. data/lib/merge_accounting_client/models/sync_status_status_enum.rb +18 -7
  125. data/lib/merge_accounting_client/models/tax_rate.rb +1 -1
  126. data/lib/merge_accounting_client/models/tracking_category.rb +13 -2
  127. data/lib/merge_accounting_client/models/transaction.rb +357 -0
  128. data/lib/merge_accounting_client/models/transaction_line_item.rb +359 -0
  129. data/lib/merge_accounting_client/models/vendor_credit.rb +1 -1
  130. data/lib/merge_accounting_client/version.rb +1 -1
  131. data/lib/merge_accounting_client.rb +7 -1
  132. data/merge_accounting_client.gemspec +1 -1
  133. data/spec/api/accounts_api_spec.rb +3 -1
  134. data/spec/api/addresses_api_spec.rb +1 -0
  135. data/spec/api/attachments_api_spec.rb +1 -1
  136. data/spec/api/balance_sheets_api_spec.rb +1 -1
  137. data/spec/api/cash_flow_statements_api_spec.rb +1 -1
  138. data/spec/api/company_info_api_spec.rb +1 -1
  139. data/spec/api/contacts_api_spec.rb +3 -1
  140. data/spec/api/credit_notes_api_spec.rb +3 -1
  141. data/spec/api/expenses_api_spec.rb +1 -1
  142. data/spec/api/income_statements_api_spec.rb +1 -1
  143. data/spec/api/invoices_api_spec.rb +3 -1
  144. data/spec/api/items_api_spec.rb +3 -1
  145. data/spec/api/journal_entries_api_spec.rb +1 -1
  146. data/spec/api/linked_accounts_api_spec.rb +1 -0
  147. data/spec/api/payments_api_spec.rb +1 -1
  148. data/spec/api/purchase_orders_api_spec.rb +3 -1
  149. data/spec/api/sync_status_api_spec.rb +1 -1
  150. data/spec/api/tax_rates_api_spec.rb +1 -1
  151. data/spec/api/tracking_categories_api_spec.rb +3 -1
  152. data/spec/api/transactions_api_spec.rb +70 -0
  153. data/spec/api/vendor_credits_api_spec.rb +1 -1
  154. data/spec/models/account_details_and_actions_spec.rb +6 -0
  155. data/spec/models/account_details_spec.rb +6 -0
  156. data/spec/models/account_spec.rb +6 -0
  157. data/spec/models/balance_sheet_spec.rb +6 -0
  158. data/spec/models/cash_flow_statement_spec.rb +6 -0
  159. data/spec/models/category_type_enum_spec.rb +28 -0
  160. data/spec/models/credit_note_line_item_spec.rb +94 -0
  161. data/spec/models/credit_note_spec.rb +18 -0
  162. data/spec/models/data_passthrough_request_spec.rb +6 -0
  163. data/spec/models/end_user_details_request_spec.rb +6 -0
  164. data/spec/models/income_statement_spec.rb +6 -0
  165. data/spec/models/invoice_line_item_spec.rb +0 -6
  166. data/spec/models/journal_entry_request_spec.rb +6 -0
  167. data/spec/models/journal_entry_spec.rb +6 -0
  168. data/spec/models/link_token_spec.rb +6 -0
  169. data/spec/models/paginated_transaction_list_spec.rb +46 -0
  170. data/spec/models/purchase_order_line_item_spec.rb +24 -0
  171. data/spec/models/purchase_order_spec.rb +18 -0
  172. data/spec/models/remote_response_spec.rb +12 -0
  173. data/spec/models/response_type_enum_spec.rb +28 -0
  174. data/spec/models/tracking_category_spec.rb +6 -0
  175. data/spec/models/transaction_line_item_spec.rb +82 -0
  176. data/spec/models/transaction_spec.rb +100 -0
  177. metadata +136 -107
@@ -0,0 +1,357 @@
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 Transaction Object ### Description The `Transaction` object is used to represent a company's transactions. ### Usage Example Fetch from the `GET Transaction` endpoint and view a company's transactions.
18
+ class Transaction
19
+ attr_accessor :id
20
+
21
+ # The type of general transaction.
22
+ attr_accessor :transaction_type
23
+
24
+ # The third-party API ID of the matching object.
25
+ attr_accessor :remote_id
26
+
27
+ attr_accessor :remote_data
28
+
29
+ # The transaction number.
30
+ attr_accessor :number
31
+
32
+ # The transaction date.
33
+ attr_accessor :transaction_date
34
+
35
+ # The transaction's account.
36
+ attr_accessor :account
37
+
38
+ # The transaction's contact.
39
+ attr_accessor :contact
40
+
41
+ # The transaction's total amount.
42
+ attr_accessor :total_amount
43
+
44
+ # The transaction's currency.
45
+ attr_accessor :currency
46
+
47
+ attr_accessor :line_items
48
+
49
+ # Indicates whether or not this object has been deleted by third party webhooks.
50
+ attr_accessor :remote_was_deleted
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'id' => :'id',
56
+ :'transaction_type' => :'transaction_type',
57
+ :'remote_id' => :'remote_id',
58
+ :'remote_data' => :'remote_data',
59
+ :'number' => :'number',
60
+ :'transaction_date' => :'transaction_date',
61
+ :'account' => :'account',
62
+ :'contact' => :'contact',
63
+ :'total_amount' => :'total_amount',
64
+ :'currency' => :'currency',
65
+ :'line_items' => :'line_items',
66
+ :'remote_was_deleted' => :'remote_was_deleted'
67
+ }
68
+ end
69
+
70
+ # Returns all the JSON keys this model knows about
71
+ def self.acceptable_attributes
72
+ attribute_map.values
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.openapi_types
77
+ {
78
+ :'id' => :'String',
79
+ :'transaction_type' => :'String',
80
+ :'remote_id' => :'String',
81
+ :'remote_data' => :'Array<RemoteData>',
82
+ :'number' => :'String',
83
+ :'transaction_date' => :'Time',
84
+ :'account' => :'String',
85
+ :'contact' => :'String',
86
+ :'total_amount' => :'String',
87
+ :'currency' => :'CurrencyEnum',
88
+ :'line_items' => :'Array<TransactionLineItem>',
89
+ :'remote_was_deleted' => :'Boolean'
90
+ }
91
+ end
92
+
93
+ # List of attributes with nullable: true
94
+ def self.openapi_nullable
95
+ Set.new([
96
+ :'transaction_type',
97
+ :'remote_id',
98
+ :'remote_data',
99
+ :'number',
100
+ :'transaction_date',
101
+ :'account',
102
+ :'contact',
103
+ :'total_amount',
104
+ :'currency',
105
+ ])
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MergeAccountingClient::Transaction` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ attributes = attributes.each_with_object({}) { |(k, v), h|
117
+ if (!self.class.attribute_map.key?(k.to_sym))
118
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MergeAccountingClient::Transaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
119
+ end
120
+ h[k.to_sym] = v
121
+ }
122
+
123
+ if attributes.key?(:'id')
124
+ self.id = attributes[:'id']
125
+ end
126
+
127
+ if attributes.key?(:'transaction_type')
128
+ self.transaction_type = attributes[:'transaction_type']
129
+ end
130
+
131
+ if attributes.key?(:'remote_id')
132
+ self.remote_id = attributes[:'remote_id']
133
+ end
134
+
135
+ if attributes.key?(:'remote_data')
136
+ if (value = attributes[:'remote_data']).is_a?(Array)
137
+ self.remote_data = value
138
+ end
139
+ end
140
+
141
+ if attributes.key?(:'number')
142
+ self.number = attributes[:'number']
143
+ end
144
+
145
+ if attributes.key?(:'transaction_date')
146
+ self.transaction_date = attributes[:'transaction_date']
147
+ end
148
+
149
+ if attributes.key?(:'account')
150
+ self.account = attributes[:'account']
151
+ end
152
+
153
+ if attributes.key?(:'contact')
154
+ self.contact = attributes[:'contact']
155
+ end
156
+
157
+ if attributes.key?(:'total_amount')
158
+ self.total_amount = attributes[:'total_amount']
159
+ end
160
+
161
+ if attributes.key?(:'currency')
162
+ self.currency = attributes[:'currency']
163
+ end
164
+
165
+ if attributes.key?(:'line_items')
166
+ if (value = attributes[:'line_items']).is_a?(Array)
167
+ self.line_items = value
168
+ end
169
+ end
170
+
171
+ if attributes.key?(:'remote_was_deleted')
172
+ self.remote_was_deleted = attributes[:'remote_was_deleted']
173
+ end
174
+ end
175
+
176
+ # Show invalid properties with the reasons. Usually used together with valid?
177
+ # @return Array for valid properties with the reasons
178
+ def list_invalid_properties
179
+ invalid_properties = Array.new
180
+ pattern = Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
181
+ if !@total_amount.nil? && @total_amount !~ pattern
182
+ invalid_properties.push("invalid value for \"total_amount\", must conform to the pattern #{pattern}.")
183
+ end
184
+
185
+ invalid_properties
186
+ end
187
+
188
+ # Check to see if the all the properties in the model are valid
189
+ # @return true if the model is valid
190
+ def valid?
191
+ return false if !@total_amount.nil? && @total_amount !~ Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
192
+ true
193
+ end
194
+
195
+ # Custom attribute writer method with validation
196
+ # @param [Object] total_amount Value to be assigned
197
+ def total_amount=(total_amount)
198
+ pattern = Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
199
+ if !total_amount.nil? && total_amount !~ pattern
200
+ fail ArgumentError, "invalid value for \"total_amount\", must conform to the pattern #{pattern}."
201
+ end
202
+
203
+ @total_amount = total_amount
204
+ end
205
+
206
+ # Checks equality by comparing each attribute.
207
+ # @param [Object] Object to be compared
208
+ def ==(o)
209
+ return true if self.equal?(o)
210
+ self.class == o.class &&
211
+ id == o.id &&
212
+ transaction_type == o.transaction_type &&
213
+ remote_id == o.remote_id &&
214
+ remote_data == o.remote_data &&
215
+ number == o.number &&
216
+ transaction_date == o.transaction_date &&
217
+ account == o.account &&
218
+ contact == o.contact &&
219
+ total_amount == o.total_amount &&
220
+ currency == o.currency &&
221
+ line_items == o.line_items &&
222
+ remote_was_deleted == o.remote_was_deleted
223
+ end
224
+
225
+ # @see the `==` method
226
+ # @param [Object] Object to be compared
227
+ def eql?(o)
228
+ self == o
229
+ end
230
+
231
+ # Calculates hash code according to all attributes.
232
+ # @return [Integer] Hash code
233
+ def hash
234
+ [id, transaction_type, remote_id, remote_data, number, transaction_date, account, contact, total_amount, currency, line_items, remote_was_deleted].hash
235
+ end
236
+
237
+ # Builds the object from hash
238
+ # @param [Hash] attributes Model attributes in the form of hash
239
+ # @return [Object] Returns the model itself
240
+ def self.build_from_hash(attributes)
241
+ new.build_from_hash(attributes)
242
+ end
243
+
244
+ # Builds the object from hash
245
+ # @param [Hash] attributes Model attributes in the form of hash
246
+ # @return [Object] Returns the model itself
247
+ def build_from_hash(attributes)
248
+ return nil unless attributes.is_a?(Hash)
249
+ self.class.openapi_types.each_pair do |key, type|
250
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
251
+ self.send("#{key}=", nil)
252
+ elsif type =~ /\AArray<(.*)>/i
253
+ # check to ensure the input is an array given that the attribute
254
+ # is documented as an array but the input is not
255
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
256
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
257
+ end
258
+ elsif !attributes[self.class.attribute_map[key]].nil?
259
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
260
+ end
261
+ end
262
+
263
+ self
264
+ end
265
+
266
+ # Deserializes the data based on type
267
+ # @param string type Data type
268
+ # @param string value Value to be deserialized
269
+ # @return [Object] Deserialized data
270
+ def _deserialize(type, value)
271
+ case type.to_sym
272
+ when :Time
273
+ Time.parse(value)
274
+ when :Date
275
+ Date.parse(value)
276
+ when :String
277
+ value
278
+ when :Integer
279
+ value.to_i
280
+ when :Float
281
+ value.to_f
282
+ when :Boolean
283
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
284
+ true
285
+ else
286
+ false
287
+ end
288
+ when :Object
289
+ # generic object (usually a Hash), return directly
290
+ value
291
+ when /\AArray<(?<inner_type>.+)>\z/
292
+ inner_type = Regexp.last_match[:inner_type]
293
+ value.map { |v| _deserialize(inner_type, v) }
294
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
295
+ k_type = Regexp.last_match[:k_type]
296
+ v_type = Regexp.last_match[:v_type]
297
+ {}.tap do |hash|
298
+ value.each do |k, v|
299
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
300
+ end
301
+ end
302
+ else # model
303
+ # models (e.g. Pet) or oneOf
304
+ klass = MergeAccountingClient.const_get(type)
305
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
306
+ end
307
+ end
308
+
309
+ # Returns the string representation of the object
310
+ # @return [String] String presentation of the object
311
+ def to_s
312
+ to_hash.to_s
313
+ end
314
+
315
+ # to_body is an alias to to_hash (backward compatibility)
316
+ # @return [Hash] Returns the object in the form of hash
317
+ def to_body
318
+ to_hash
319
+ end
320
+
321
+ # Returns the object in the form of hash
322
+ # @return [Hash] Returns the object in the form of hash
323
+ def to_hash
324
+ hash = {}
325
+ self.class.attribute_map.each_pair do |attr, param|
326
+ value = self.send(attr)
327
+ if value.nil?
328
+ is_nullable = self.class.openapi_nullable.include?(attr)
329
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
330
+ end
331
+
332
+ hash[param] = _to_hash(value)
333
+ end
334
+ hash
335
+ end
336
+
337
+ # Outputs non-array value in the form of hash
338
+ # For object, use to_hash. Otherwise, just return the value
339
+ # @param [Object] value Any valid value
340
+ # @return [Hash] Returns the value in the form of hash
341
+ def _to_hash(value)
342
+ if value.is_a?(Array)
343
+ value.compact.map { |v| _to_hash(v) }
344
+ elsif value.is_a?(Hash)
345
+ {}.tap do |hash|
346
+ value.each { |k, v| hash[k] = _to_hash(v) }
347
+ end
348
+ elsif value.respond_to? :to_hash
349
+ value.to_hash
350
+ else
351
+ value
352
+ end
353
+ end
354
+
355
+ end
356
+
357
+ end
@@ -0,0 +1,359 @@
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 TransactionLineItem Object ### Description The `TransactionLineItem` object is used to represent a transaction's line items. ### Usage Example Fetch from the `GET TransactionLineItem` endpoint and view the transaction's line items.
18
+ class TransactionLineItem
19
+ # A memo attached to the line item.
20
+ attr_accessor :memo
21
+
22
+ # The line item's unit price.
23
+ attr_accessor :unit_price
24
+
25
+ # The line item's quantity.
26
+ attr_accessor :quantity
27
+
28
+ attr_accessor :item
29
+
30
+ # The line item's account.
31
+ attr_accessor :account
32
+
33
+ # The line's associated tracking category.
34
+ attr_accessor :tracking_category
35
+
36
+ # The line item's total.
37
+ attr_accessor :total_line_amount
38
+
39
+ # The line item's tax rate.
40
+ attr_accessor :tax_rate
41
+
42
+ # The third-party API ID of the matching object.
43
+ attr_accessor :remote_id
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'memo' => :'memo',
49
+ :'unit_price' => :'unit_price',
50
+ :'quantity' => :'quantity',
51
+ :'item' => :'item',
52
+ :'account' => :'account',
53
+ :'tracking_category' => :'tracking_category',
54
+ :'total_line_amount' => :'total_line_amount',
55
+ :'tax_rate' => :'tax_rate',
56
+ :'remote_id' => :'remote_id'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'memo' => :'String',
69
+ :'unit_price' => :'String',
70
+ :'quantity' => :'String',
71
+ :'item' => :'String',
72
+ :'account' => :'String',
73
+ :'tracking_category' => :'String',
74
+ :'total_line_amount' => :'String',
75
+ :'tax_rate' => :'String',
76
+ :'remote_id' => :'String'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ :'memo',
84
+ :'unit_price',
85
+ :'quantity',
86
+ :'item',
87
+ :'account',
88
+ :'tracking_category',
89
+ :'total_line_amount',
90
+ :'tax_rate',
91
+ :'remote_id'
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MergeAccountingClient::TransactionLineItem` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!self.class.attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MergeAccountingClient::TransactionLineItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'memo')
111
+ self.memo = attributes[:'memo']
112
+ end
113
+
114
+ if attributes.key?(:'unit_price')
115
+ self.unit_price = attributes[:'unit_price']
116
+ end
117
+
118
+ if attributes.key?(:'quantity')
119
+ self.quantity = attributes[:'quantity']
120
+ end
121
+
122
+ if attributes.key?(:'item')
123
+ self.item = attributes[:'item']
124
+ end
125
+
126
+ if attributes.key?(:'account')
127
+ self.account = attributes[:'account']
128
+ end
129
+
130
+ if attributes.key?(:'tracking_category')
131
+ self.tracking_category = attributes[:'tracking_category']
132
+ end
133
+
134
+ if attributes.key?(:'total_line_amount')
135
+ self.total_line_amount = attributes[:'total_line_amount']
136
+ end
137
+
138
+ if attributes.key?(:'tax_rate')
139
+ self.tax_rate = attributes[:'tax_rate']
140
+ end
141
+
142
+ if attributes.key?(:'remote_id')
143
+ self.remote_id = attributes[:'remote_id']
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
151
+ pattern = Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
152
+ if !@unit_price.nil? && @unit_price !~ pattern
153
+ invalid_properties.push("invalid value for \"unit_price\", must conform to the pattern #{pattern}.")
154
+ end
155
+
156
+ pattern = Regexp.new(/^\d{0,24}(?:\.\d{0,8})?$/)
157
+ if !@quantity.nil? && @quantity !~ pattern
158
+ invalid_properties.push("invalid value for \"quantity\", must conform to the pattern #{pattern}.")
159
+ end
160
+
161
+ pattern = Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
162
+ if !@total_line_amount.nil? && @total_line_amount !~ pattern
163
+ invalid_properties.push("invalid value for \"total_line_amount\", must conform to the pattern #{pattern}.")
164
+ end
165
+
166
+ invalid_properties
167
+ end
168
+
169
+ # Check to see if the all the properties in the model are valid
170
+ # @return true if the model is valid
171
+ def valid?
172
+ return false if !@unit_price.nil? && @unit_price !~ Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
173
+ return false if !@quantity.nil? && @quantity !~ Regexp.new(/^\d{0,24}(?:\.\d{0,8})?$/)
174
+ return false if !@total_line_amount.nil? && @total_line_amount !~ Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
175
+ true
176
+ end
177
+
178
+ # Custom attribute writer method with validation
179
+ # @param [Object] unit_price Value to be assigned
180
+ def unit_price=(unit_price)
181
+ pattern = Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
182
+ if !unit_price.nil? && unit_price !~ pattern
183
+ fail ArgumentError, "invalid value for \"unit_price\", must conform to the pattern #{pattern}."
184
+ end
185
+
186
+ @unit_price = unit_price
187
+ end
188
+
189
+ # Custom attribute writer method with validation
190
+ # @param [Object] quantity Value to be assigned
191
+ def quantity=(quantity)
192
+ pattern = Regexp.new(/^\d{0,24}(?:\.\d{0,8})?$/)
193
+ if !quantity.nil? && quantity !~ pattern
194
+ fail ArgumentError, "invalid value for \"quantity\", must conform to the pattern #{pattern}."
195
+ end
196
+
197
+ @quantity = quantity
198
+ end
199
+
200
+ # Custom attribute writer method with validation
201
+ # @param [Object] total_line_amount Value to be assigned
202
+ def total_line_amount=(total_line_amount)
203
+ pattern = Regexp.new(/^\d{0,32}(?:\.\d{0,16})?$/)
204
+ if !total_line_amount.nil? && total_line_amount !~ pattern
205
+ fail ArgumentError, "invalid value for \"total_line_amount\", must conform to the pattern #{pattern}."
206
+ end
207
+
208
+ @total_line_amount = total_line_amount
209
+ end
210
+
211
+ # Checks equality by comparing each attribute.
212
+ # @param [Object] Object to be compared
213
+ def ==(o)
214
+ return true if self.equal?(o)
215
+ self.class == o.class &&
216
+ memo == o.memo &&
217
+ unit_price == o.unit_price &&
218
+ quantity == o.quantity &&
219
+ item == o.item &&
220
+ account == o.account &&
221
+ tracking_category == o.tracking_category &&
222
+ total_line_amount == o.total_line_amount &&
223
+ tax_rate == o.tax_rate &&
224
+ remote_id == o.remote_id
225
+ end
226
+
227
+ # @see the `==` method
228
+ # @param [Object] Object to be compared
229
+ def eql?(o)
230
+ self == o
231
+ end
232
+
233
+ # Calculates hash code according to all attributes.
234
+ # @return [Integer] Hash code
235
+ def hash
236
+ [memo, unit_price, quantity, item, account, tracking_category, total_line_amount, tax_rate, remote_id].hash
237
+ end
238
+
239
+ # Builds the object from hash
240
+ # @param [Hash] attributes Model attributes in the form of hash
241
+ # @return [Object] Returns the model itself
242
+ def self.build_from_hash(attributes)
243
+ new.build_from_hash(attributes)
244
+ end
245
+
246
+ # Builds the object from hash
247
+ # @param [Hash] attributes Model attributes in the form of hash
248
+ # @return [Object] Returns the model itself
249
+ def build_from_hash(attributes)
250
+ return nil unless attributes.is_a?(Hash)
251
+ self.class.openapi_types.each_pair do |key, type|
252
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
253
+ self.send("#{key}=", nil)
254
+ elsif type =~ /\AArray<(.*)>/i
255
+ # check to ensure the input is an array given that the attribute
256
+ # is documented as an array but the input is not
257
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
258
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
259
+ end
260
+ elsif !attributes[self.class.attribute_map[key]].nil?
261
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
262
+ end
263
+ end
264
+
265
+ self
266
+ end
267
+
268
+ # Deserializes the data based on type
269
+ # @param string type Data type
270
+ # @param string value Value to be deserialized
271
+ # @return [Object] Deserialized data
272
+ def _deserialize(type, value)
273
+ case type.to_sym
274
+ when :Time
275
+ Time.parse(value)
276
+ when :Date
277
+ Date.parse(value)
278
+ when :String
279
+ value
280
+ when :Integer
281
+ value.to_i
282
+ when :Float
283
+ value.to_f
284
+ when :Boolean
285
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
286
+ true
287
+ else
288
+ false
289
+ end
290
+ when :Object
291
+ # generic object (usually a Hash), return directly
292
+ value
293
+ when /\AArray<(?<inner_type>.+)>\z/
294
+ inner_type = Regexp.last_match[:inner_type]
295
+ value.map { |v| _deserialize(inner_type, v) }
296
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
297
+ k_type = Regexp.last_match[:k_type]
298
+ v_type = Regexp.last_match[:v_type]
299
+ {}.tap do |hash|
300
+ value.each do |k, v|
301
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
302
+ end
303
+ end
304
+ else # model
305
+ # models (e.g. Pet) or oneOf
306
+ klass = MergeAccountingClient.const_get(type)
307
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
308
+ end
309
+ end
310
+
311
+ # Returns the string representation of the object
312
+ # @return [String] String presentation of the object
313
+ def to_s
314
+ to_hash.to_s
315
+ end
316
+
317
+ # to_body is an alias to to_hash (backward compatibility)
318
+ # @return [Hash] Returns the object in the form of hash
319
+ def to_body
320
+ to_hash
321
+ end
322
+
323
+ # Returns the object in the form of hash
324
+ # @return [Hash] Returns the object in the form of hash
325
+ def to_hash
326
+ hash = {}
327
+ self.class.attribute_map.each_pair do |attr, param|
328
+ value = self.send(attr)
329
+ if value.nil?
330
+ is_nullable = self.class.openapi_nullable.include?(attr)
331
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
332
+ end
333
+
334
+ hash[param] = _to_hash(value)
335
+ end
336
+ hash
337
+ end
338
+
339
+ # Outputs non-array value in the form of hash
340
+ # For object, use to_hash. Otherwise, just return the value
341
+ # @param [Object] value Any valid value
342
+ # @return [Hash] Returns the value in the form of hash
343
+ def _to_hash(value)
344
+ if value.is_a?(Array)
345
+ value.compact.map { |v| _to_hash(v) }
346
+ elsif value.is_a?(Hash)
347
+ {}.tap do |hash|
348
+ value.each { |k, v| hash[k] = _to_hash(v) }
349
+ end
350
+ elsif value.respond_to? :to_hash
351
+ value.to_hash
352
+ else
353
+ value
354
+ end
355
+ end
356
+
357
+ end
358
+
359
+ end