merge_accounting_client 1.0.1 → 1.0.2

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