xero-ruby 3.2.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +71 -2
- data/lib/xero-ruby/api/accounting_api.rb +11 -2
- data/lib/xero-ruby/api/app_store_api.rb +87 -0
- data/lib/xero-ruby/api/finance_api.rb +866 -0
- data/lib/xero-ruby/api/payroll_au_api.rb +14 -14
- data/lib/xero-ruby/api/payroll_nz_api.rb +18 -12
- data/lib/xero-ruby/api/payroll_uk_api.rb +14 -2
- data/lib/xero-ruby/api_client.rb +30 -4
- data/lib/xero-ruby/configuration.rb +4 -0
- data/lib/xero-ruby/models/accounting/bank_transfer.rb +35 -1
- data/lib/xero-ruby/models/accounting/budget_balance.rb +2 -2
- data/lib/xero-ruby/models/accounting/contact.rb +86 -1
- data/lib/xero-ruby/models/accounting/payment.rb +11 -1
- data/lib/xero-ruby/models/accounting/time_zone.rb +1 -0
- data/lib/xero-ruby/models/app_store/plan.rb +310 -0
- data/lib/xero-ruby/models/app_store/price.rb +257 -0
- data/lib/xero-ruby/models/app_store/problem_details.rb +272 -0
- data/lib/xero-ruby/models/app_store/product.rb +288 -0
- data/lib/xero-ruby/models/app_store/subscription.rb +324 -0
- data/lib/xero-ruby/models/app_store/subscription_item.rb +292 -0
- data/lib/xero-ruby/models/finance/account_usage.rb +342 -0
- data/lib/xero-ruby/models/finance/account_usage_response.rb +254 -0
- data/lib/xero-ruby/models/finance/balance_sheet_account_detail.rb +262 -0
- data/lib/xero-ruby/models/finance/balance_sheet_account_group.rb +234 -0
- data/lib/xero-ruby/models/finance/balance_sheet_account_type.rb +244 -0
- data/lib/xero-ruby/models/finance/balance_sheet_response.rb +252 -0
- data/lib/xero-ruby/models/finance/bank_statement_response.rb +232 -0
- data/lib/xero-ruby/models/finance/cash_account_response.rb +262 -0
- data/lib/xero-ruby/models/finance/cash_balance.rb +242 -0
- data/lib/xero-ruby/models/finance/cash_validation_response.rb +262 -0
- data/lib/xero-ruby/models/finance/cashflow_account.rb +282 -0
- data/lib/xero-ruby/models/finance/cashflow_activity.rb +244 -0
- data/lib/xero-ruby/models/finance/cashflow_response.rb +254 -0
- data/lib/xero-ruby/models/finance/cashflow_type.rb +244 -0
- data/lib/xero-ruby/models/finance/contact_detail.rb +274 -0
- data/lib/xero-ruby/models/finance/contact_total_detail.rb +242 -0
- data/lib/xero-ruby/models/finance/contact_total_other.rb +252 -0
- data/lib/xero-ruby/models/finance/current_statement_response.rb +272 -0
- data/lib/xero-ruby/models/finance/data_source_response.rb +362 -0
- data/lib/xero-ruby/models/finance/history_record_response.rb +262 -0
- data/lib/xero-ruby/models/finance/income_by_contact_response.rb +284 -0
- data/lib/xero-ruby/models/finance/lock_history_model.rb +242 -0
- data/lib/xero-ruby/models/finance/lock_history_response.rb +244 -0
- data/lib/xero-ruby/models/finance/manual_journal_total.rb +222 -0
- data/lib/xero-ruby/models/finance/pnl_account.rb +272 -0
- data/lib/xero-ruby/models/finance/pnl_account_class.rb +234 -0
- data/lib/xero-ruby/models/finance/pnl_account_type.rb +244 -0
- data/lib/xero-ruby/models/finance/practice_response.rb +262 -0
- data/lib/xero-ruby/models/finance/problem.rb +252 -0
- data/lib/xero-ruby/models/finance/problem_type.rb +39 -0
- data/lib/xero-ruby/models/finance/profit_and_loss_response.rb +262 -0
- data/lib/xero-ruby/models/finance/report_history_model.rb +242 -0
- data/lib/xero-ruby/models/finance/report_history_response.rb +244 -0
- data/lib/xero-ruby/models/finance/statement_balance_response.rb +232 -0
- data/lib/xero-ruby/models/finance/statement_lines_response.rb +382 -0
- data/lib/xero-ruby/models/finance/total_detail.rb +242 -0
- data/lib/xero-ruby/models/finance/total_other.rb +242 -0
- data/lib/xero-ruby/models/finance/trial_balance_account.rb +312 -0
- data/lib/xero-ruby/models/finance/trial_balance_entry.rb +232 -0
- data/lib/xero-ruby/models/finance/trial_balance_movement.rb +252 -0
- data/lib/xero-ruby/models/finance/trial_balance_response.rb +244 -0
- data/lib/xero-ruby/models/finance/user_activities_response.rb +244 -0
- data/lib/xero-ruby/models/finance/user_response.rb +336 -0
- data/lib/xero-ruby/models/payroll_au/earnings_type.rb +2 -0
- data/lib/xero-ruby/models/payroll_au/employee.rb +30 -1
- data/lib/xero-ruby/models/payroll_au/manual_tax_type.rb +1 -0
- data/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +11 -1
- data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +4 -4
- data/lib/xero-ruby/version.rb +6 -6
- data/lib/xero-ruby.rb +51 -0
- data/spec/api_client_spec.rb +5 -2
- data/spec/app_store/api/app_store_api_spec.rb +45 -0
- data/spec/app_store/models/plan_spec.rb +62 -0
- data/spec/app_store/models/price_spec.rb +52 -0
- data/spec/app_store/models/problem_details_spec.rb +70 -0
- data/spec/app_store/models/product_spec.rb +56 -0
- data/spec/app_store/models/subscription_item_spec.rb +70 -0
- data/spec/app_store/models/subscription_spec.rb +82 -0
- data/spec/configuration_spec.rb +1 -0
- data/spec/finance/api/finance_api_spec.rb +156 -0
- data/spec/finance/models/account_usage_response_spec.rb +58 -0
- data/spec/finance/models/account_usage_spec.rb +112 -0
- data/spec/finance/models/balance_sheet_account_detail_spec.rb +64 -0
- data/spec/finance/models/balance_sheet_account_group_spec.rb +46 -0
- data/spec/finance/models/balance_sheet_account_type_spec.rb +52 -0
- data/spec/finance/models/balance_sheet_response_spec.rb +58 -0
- data/spec/finance/models/bank_statement_response_spec.rb +46 -0
- data/spec/finance/models/cash_account_response_spec.rb +64 -0
- data/spec/finance/models/cash_balance_spec.rb +52 -0
- data/spec/finance/models/cash_validation_response_spec.rb +64 -0
- data/spec/finance/models/cashflow_account_spec.rb +76 -0
- data/spec/finance/models/cashflow_activity_spec.rb +52 -0
- data/spec/finance/models/cashflow_response_spec.rb +58 -0
- data/spec/finance/models/cashflow_type_spec.rb +52 -0
- data/spec/finance/models/current_statement_response_spec.rb +70 -0
- data/spec/finance/models/data_source_response_spec.rb +124 -0
- data/spec/finance/models/history_record_response_spec.rb +64 -0
- data/spec/finance/models/lock_history_model_spec.rb +52 -0
- data/spec/finance/models/lock_history_response_spec.rb +52 -0
- data/spec/finance/models/pnl_account_class_spec.rb +46 -0
- data/spec/finance/models/pnl_account_spec.rb +70 -0
- data/spec/finance/models/pnl_account_type_spec.rb +52 -0
- data/spec/finance/models/practice_response_spec.rb +64 -0
- data/spec/finance/models/problem_spec.rb +58 -0
- data/spec/finance/models/problem_type_spec.rb +34 -0
- data/spec/finance/models/profit_and_loss_response_spec.rb +64 -0
- data/spec/finance/models/report_history_model_spec.rb +52 -0
- data/spec/finance/models/report_history_response_spec.rb +52 -0
- data/spec/finance/models/statement_balance_response_spec.rb +46 -0
- data/spec/finance/models/statement_lines_response_spec.rb +136 -0
- data/spec/finance/models/trial_balance_account_spec.rb +94 -0
- data/spec/finance/models/trial_balance_entry_spec.rb +46 -0
- data/spec/finance/models/trial_balance_movement_spec.rb +58 -0
- data/spec/finance/models/trial_balance_response_spec.rb +52 -0
- data/spec/finance/models/user_activities_response_spec.rb +52 -0
- data/spec/finance/models/user_response_spec.rb +106 -0
- metadata +142 -3
@@ -0,0 +1,362 @@
|
|
1
|
+
=begin
|
2
|
+
#Xero Finance API
|
3
|
+
|
4
|
+
#The Finance API is a collection of endpoints which customers can use in the course of a loan application, which may assist lenders to gain the confidence they need to provide capital.
|
5
|
+
|
6
|
+
Contact: api@xero.com
|
7
|
+
Generated by: https://openapi-generator.tech
|
8
|
+
OpenAPI Generator version: 4.3.1
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'time'
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module XeroRuby::Finance
|
16
|
+
require 'bigdecimal'
|
17
|
+
|
18
|
+
class DataSourceResponse
|
19
|
+
# Sum of the amounts of all statement lines where the source of the data was a direct bank feed in to Xero. This gives an indication on the certainty of correctness of the data.
|
20
|
+
attr_accessor :direct_bank_feed
|
21
|
+
|
22
|
+
# Sum of the amounts of all statement lines where the source of the data was a indirect bank feed to Xero (usually via Yodlee). This gives an indication on the certainty of correctness of the data.
|
23
|
+
attr_accessor :indirect_bank_feed
|
24
|
+
|
25
|
+
# Sum of the amounts of all statement lines where the source of the data was a CSV file upload in to Xero. This gives an indication on the certainty of correctness of the data.
|
26
|
+
attr_accessor :file_upload
|
27
|
+
|
28
|
+
# Sum of the amounts of all statement lines where the source of the data was manually keyed in to Xero. This gives an indication on the certainty of correctness of the data.
|
29
|
+
attr_accessor :manual
|
30
|
+
|
31
|
+
# Sum of the amounts of all statement lines where the source of the data was a direct bank feed in to Xero. This gives an indication on the certainty of correctness of the data. Only positive transactions are included.
|
32
|
+
attr_accessor :direct_bank_feed_pos
|
33
|
+
|
34
|
+
# Sum of the amounts of all statement lines where the source of the data was a indirect bank feed to Xero (usually via Yodlee). This gives an indication on the certainty of correctness of the data. Only positive transactions are included.
|
35
|
+
attr_accessor :indirect_bank_feed_pos
|
36
|
+
|
37
|
+
# Sum of the amounts of all statement lines where the source of the data was a CSV file upload in to Xero. This gives an indication on the certainty of correctness of the data. Only positive transactions are included.
|
38
|
+
attr_accessor :file_upload_pos
|
39
|
+
|
40
|
+
# Sum of the amounts of all statement lines where the source of the data was manually keyed in to Xero. This gives an indication on the certainty of correctness of the data. Only positive transactions are included.
|
41
|
+
attr_accessor :manual_pos
|
42
|
+
|
43
|
+
# Sum of the amounts of all statement lines where the source of the data was a direct bank feed in to Xero. This gives an indication on the certainty of correctness of the data. Only negative transactions are included.
|
44
|
+
attr_accessor :direct_bank_feed_neg
|
45
|
+
|
46
|
+
# Sum of the amounts of all statement lines where the source of the data was a indirect bank feed to Xero (usually via Yodlee). This gives an indication on the certainty of correctness of the data. Only negative transactions are included.
|
47
|
+
attr_accessor :indirect_bank_feed_neg
|
48
|
+
|
49
|
+
# Sum of the amounts of all statement lines where the source of the data was a CSV file upload in to Xero. This gives an indication on the certainty of correctness of the data. Only negative transactions are included.
|
50
|
+
attr_accessor :file_upload_neg
|
51
|
+
|
52
|
+
# Sum of the amounts of all statement lines where the source of the data was manually keyed in to Xero. This gives an indication on the certainty of correctness of the data. Only negative transactions are included.
|
53
|
+
attr_accessor :manual_neg
|
54
|
+
|
55
|
+
# Sum of the amounts of all statement lines where the source of the data was any other category. This gives an indication on the certainty of correctness of the data. Only positive transactions are included.
|
56
|
+
attr_accessor :other_pos
|
57
|
+
|
58
|
+
# Sum of the amounts of all statement lines where the source of the data was any other category. This gives an indication on the certainty of correctness of the data. Only negative transactions are included.
|
59
|
+
attr_accessor :other_neg
|
60
|
+
|
61
|
+
# Sum of the amounts of all statement lines where the source of the data was any other category. This gives an indication on the certainty of correctness of the data.
|
62
|
+
attr_accessor :other
|
63
|
+
|
64
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
65
|
+
def self.attribute_map
|
66
|
+
{
|
67
|
+
:'direct_bank_feed' => :'directBankFeed',
|
68
|
+
:'indirect_bank_feed' => :'indirectBankFeed',
|
69
|
+
:'file_upload' => :'fileUpload',
|
70
|
+
:'manual' => :'manual',
|
71
|
+
:'direct_bank_feed_pos' => :'directBankFeedPos',
|
72
|
+
:'indirect_bank_feed_pos' => :'indirectBankFeedPos',
|
73
|
+
:'file_upload_pos' => :'fileUploadPos',
|
74
|
+
:'manual_pos' => :'manualPos',
|
75
|
+
:'direct_bank_feed_neg' => :'directBankFeedNeg',
|
76
|
+
:'indirect_bank_feed_neg' => :'indirectBankFeedNeg',
|
77
|
+
:'file_upload_neg' => :'fileUploadNeg',
|
78
|
+
:'manual_neg' => :'manualNeg',
|
79
|
+
:'other_pos' => :'otherPos',
|
80
|
+
:'other_neg' => :'otherNeg',
|
81
|
+
:'other' => :'other'
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
# Attribute type mapping.
|
86
|
+
def self.openapi_types
|
87
|
+
{
|
88
|
+
:'direct_bank_feed' => :'BigDecimal',
|
89
|
+
:'indirect_bank_feed' => :'BigDecimal',
|
90
|
+
:'file_upload' => :'BigDecimal',
|
91
|
+
:'manual' => :'BigDecimal',
|
92
|
+
:'direct_bank_feed_pos' => :'BigDecimal',
|
93
|
+
:'indirect_bank_feed_pos' => :'BigDecimal',
|
94
|
+
:'file_upload_pos' => :'BigDecimal',
|
95
|
+
:'manual_pos' => :'BigDecimal',
|
96
|
+
:'direct_bank_feed_neg' => :'BigDecimal',
|
97
|
+
:'indirect_bank_feed_neg' => :'BigDecimal',
|
98
|
+
:'file_upload_neg' => :'BigDecimal',
|
99
|
+
:'manual_neg' => :'BigDecimal',
|
100
|
+
:'other_pos' => :'BigDecimal',
|
101
|
+
:'other_neg' => :'BigDecimal',
|
102
|
+
:'other' => :'BigDecimal'
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
# Initializes the object
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
+
def initialize(attributes = {})
|
109
|
+
if (!attributes.is_a?(Hash))
|
110
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::DataSourceResponse` initialize method"
|
111
|
+
end
|
112
|
+
|
113
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
114
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
115
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
116
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::DataSourceResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
117
|
+
end
|
118
|
+
h[k.to_sym] = v
|
119
|
+
}
|
120
|
+
|
121
|
+
if attributes.key?(:'direct_bank_feed')
|
122
|
+
self.direct_bank_feed = attributes[:'direct_bank_feed']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:'indirect_bank_feed')
|
126
|
+
self.indirect_bank_feed = attributes[:'indirect_bank_feed']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.key?(:'file_upload')
|
130
|
+
self.file_upload = attributes[:'file_upload']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:'manual')
|
134
|
+
self.manual = attributes[:'manual']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.key?(:'direct_bank_feed_pos')
|
138
|
+
self.direct_bank_feed_pos = attributes[:'direct_bank_feed_pos']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.key?(:'indirect_bank_feed_pos')
|
142
|
+
self.indirect_bank_feed_pos = attributes[:'indirect_bank_feed_pos']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:'file_upload_pos')
|
146
|
+
self.file_upload_pos = attributes[:'file_upload_pos']
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.key?(:'manual_pos')
|
150
|
+
self.manual_pos = attributes[:'manual_pos']
|
151
|
+
end
|
152
|
+
|
153
|
+
if attributes.key?(:'direct_bank_feed_neg')
|
154
|
+
self.direct_bank_feed_neg = attributes[:'direct_bank_feed_neg']
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.key?(:'indirect_bank_feed_neg')
|
158
|
+
self.indirect_bank_feed_neg = attributes[:'indirect_bank_feed_neg']
|
159
|
+
end
|
160
|
+
|
161
|
+
if attributes.key?(:'file_upload_neg')
|
162
|
+
self.file_upload_neg = attributes[:'file_upload_neg']
|
163
|
+
end
|
164
|
+
|
165
|
+
if attributes.key?(:'manual_neg')
|
166
|
+
self.manual_neg = attributes[:'manual_neg']
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.key?(:'other_pos')
|
170
|
+
self.other_pos = attributes[:'other_pos']
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.key?(:'other_neg')
|
174
|
+
self.other_neg = attributes[:'other_neg']
|
175
|
+
end
|
176
|
+
|
177
|
+
if attributes.key?(:'other')
|
178
|
+
self.other = attributes[:'other']
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
183
|
+
# @return Array for valid properties with the reasons
|
184
|
+
def list_invalid_properties
|
185
|
+
invalid_properties = Array.new
|
186
|
+
invalid_properties
|
187
|
+
end
|
188
|
+
|
189
|
+
# Check to see if the all the properties in the model are valid
|
190
|
+
# @return true if the model is valid
|
191
|
+
def valid?
|
192
|
+
true
|
193
|
+
end
|
194
|
+
|
195
|
+
# Checks equality by comparing each attribute.
|
196
|
+
# @param [Object] Object to be compared
|
197
|
+
def ==(o)
|
198
|
+
return true if self.equal?(o)
|
199
|
+
self.class == o.class &&
|
200
|
+
direct_bank_feed == o.direct_bank_feed &&
|
201
|
+
indirect_bank_feed == o.indirect_bank_feed &&
|
202
|
+
file_upload == o.file_upload &&
|
203
|
+
manual == o.manual &&
|
204
|
+
direct_bank_feed_pos == o.direct_bank_feed_pos &&
|
205
|
+
indirect_bank_feed_pos == o.indirect_bank_feed_pos &&
|
206
|
+
file_upload_pos == o.file_upload_pos &&
|
207
|
+
manual_pos == o.manual_pos &&
|
208
|
+
direct_bank_feed_neg == o.direct_bank_feed_neg &&
|
209
|
+
indirect_bank_feed_neg == o.indirect_bank_feed_neg &&
|
210
|
+
file_upload_neg == o.file_upload_neg &&
|
211
|
+
manual_neg == o.manual_neg &&
|
212
|
+
other_pos == o.other_pos &&
|
213
|
+
other_neg == o.other_neg &&
|
214
|
+
other == o.other
|
215
|
+
end
|
216
|
+
|
217
|
+
# @see the `==` method
|
218
|
+
# @param [Object] Object to be compared
|
219
|
+
def eql?(o)
|
220
|
+
self == o
|
221
|
+
end
|
222
|
+
|
223
|
+
# Calculates hash code according to all attributes.
|
224
|
+
# @return [Integer] Hash code
|
225
|
+
def hash
|
226
|
+
[direct_bank_feed, indirect_bank_feed, file_upload, manual, direct_bank_feed_pos, indirect_bank_feed_pos, file_upload_pos, manual_pos, direct_bank_feed_neg, indirect_bank_feed_neg, file_upload_neg, manual_neg, other_pos, other_neg, other].hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Builds the object from hash
|
230
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
231
|
+
# @return [Object] Returns the model itself
|
232
|
+
def self.build_from_hash(attributes)
|
233
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
240
|
+
return nil unless attributes.is_a?(Hash)
|
241
|
+
self.class.openapi_types.each_pair do |key, type|
|
242
|
+
if type =~ /\AArray<(.*)>/i
|
243
|
+
# check to ensure the input is an array given that the attribute
|
244
|
+
# is documented as an array but the input is not
|
245
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
246
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
247
|
+
end
|
248
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
249
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
250
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
251
|
+
end
|
252
|
+
|
253
|
+
self
|
254
|
+
end
|
255
|
+
|
256
|
+
# Deserializes the data based on type
|
257
|
+
# @param string type Data type
|
258
|
+
# @param string value Value to be deserialized
|
259
|
+
# @return [Object] Deserialized data
|
260
|
+
def _deserialize(type, value)
|
261
|
+
case type.to_sym
|
262
|
+
when :DateTime
|
263
|
+
DateTime.parse(parse_date(value))
|
264
|
+
when :Date
|
265
|
+
Date.parse(parse_date(value))
|
266
|
+
when :String
|
267
|
+
value.to_s
|
268
|
+
when :Integer
|
269
|
+
value.to_i
|
270
|
+
when :Float
|
271
|
+
value.to_f
|
272
|
+
when :BigDecimal
|
273
|
+
BigDecimal(value.to_s)
|
274
|
+
when :Boolean
|
275
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
276
|
+
true
|
277
|
+
else
|
278
|
+
false
|
279
|
+
end
|
280
|
+
when :Object
|
281
|
+
# generic object (usually a Hash), return directly
|
282
|
+
value
|
283
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
284
|
+
inner_type = Regexp.last_match[:inner_type]
|
285
|
+
value.map { |v| _deserialize(inner_type, v) }
|
286
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
287
|
+
k_type = Regexp.last_match[:k_type]
|
288
|
+
v_type = Regexp.last_match[:v_type]
|
289
|
+
{}.tap do |hash|
|
290
|
+
value.each do |k, v|
|
291
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
else # model
|
295
|
+
XeroRuby::Finance.const_get(type).build_from_hash(value)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
# Returns the string representation of the object
|
300
|
+
# @return [String] String presentation of the object
|
301
|
+
def to_s
|
302
|
+
to_hash.to_s
|
303
|
+
end
|
304
|
+
|
305
|
+
# to_body is an alias to to_hash (backward compatibility)
|
306
|
+
# @return [Hash] Returns the object in the form of hash
|
307
|
+
def to_body
|
308
|
+
to_hash
|
309
|
+
end
|
310
|
+
|
311
|
+
# Returns the object in the form of hash
|
312
|
+
# @return [Hash] Returns the object in the form of hash
|
313
|
+
def to_hash(downcase: false)
|
314
|
+
hash = {}
|
315
|
+
self.class.attribute_map.each_pair do |attr, param|
|
316
|
+
value = self.send(attr)
|
317
|
+
next if value.nil?
|
318
|
+
key = downcase ? attr : param
|
319
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
320
|
+
end
|
321
|
+
hash
|
322
|
+
end
|
323
|
+
|
324
|
+
# Returns the object in the form of hash with snake_case
|
325
|
+
def to_attributes
|
326
|
+
to_hash(downcase: true)
|
327
|
+
end
|
328
|
+
|
329
|
+
# Outputs non-array value in the form of hash
|
330
|
+
# For object, use to_hash. Otherwise, just return the value
|
331
|
+
# @param [Object] value Any valid value
|
332
|
+
# @return [Hash] Returns the value in the form of hash
|
333
|
+
def _to_hash(value, downcase: false)
|
334
|
+
if value.is_a?(Array)
|
335
|
+
value.map do |v|
|
336
|
+
v.to_hash(downcase: downcase)
|
337
|
+
end
|
338
|
+
elsif value.is_a?(Hash)
|
339
|
+
{}.tap do |hash|
|
340
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
341
|
+
end
|
342
|
+
elsif value.respond_to? :to_hash
|
343
|
+
value.to_hash(downcase: downcase)
|
344
|
+
else
|
345
|
+
value
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def parse_date(datestring)
|
350
|
+
if datestring.include?('Date')
|
351
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
352
|
+
original, date, timezone = *date_pattern.match(datestring)
|
353
|
+
date = (date.to_i / 1000)
|
354
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
355
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
356
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
357
|
+
else # handle date 'types' for small subset of payroll API's
|
358
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
@@ -0,0 +1,262 @@
|
|
1
|
+
=begin
|
2
|
+
#Xero Finance API
|
3
|
+
|
4
|
+
#The Finance API is a collection of endpoints which customers can use in the course of a loan application, which may assist lenders to gain the confidence they need to provide capital.
|
5
|
+
|
6
|
+
Contact: api@xero.com
|
7
|
+
Generated by: https://openapi-generator.tech
|
8
|
+
OpenAPI Generator version: 4.3.1
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'time'
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module XeroRuby::Finance
|
16
|
+
require 'bigdecimal'
|
17
|
+
|
18
|
+
class HistoryRecordResponse
|
19
|
+
# The type of change recorded against the document
|
20
|
+
attr_accessor :changes
|
21
|
+
|
22
|
+
# UTC date that the history record was created
|
23
|
+
attr_accessor :date_utc_string
|
24
|
+
|
25
|
+
# UTC date that the history record was created
|
26
|
+
attr_accessor :date_utc
|
27
|
+
|
28
|
+
# The users first and last name
|
29
|
+
attr_accessor :user
|
30
|
+
|
31
|
+
# Description of the change event or transaction
|
32
|
+
attr_accessor :details
|
33
|
+
|
34
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
35
|
+
def self.attribute_map
|
36
|
+
{
|
37
|
+
:'changes' => :'changes',
|
38
|
+
:'date_utc_string' => :'dateUTCString',
|
39
|
+
:'date_utc' => :'dateUTC',
|
40
|
+
:'user' => :'user',
|
41
|
+
:'details' => :'details'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Attribute type mapping.
|
46
|
+
def self.openapi_types
|
47
|
+
{
|
48
|
+
:'changes' => :'String',
|
49
|
+
:'date_utc_string' => :'String',
|
50
|
+
:'date_utc' => :'DateTime',
|
51
|
+
:'user' => :'String',
|
52
|
+
:'details' => :'String'
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
# Initializes the object
|
57
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
58
|
+
def initialize(attributes = {})
|
59
|
+
if (!attributes.is_a?(Hash))
|
60
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::HistoryRecordResponse` initialize method"
|
61
|
+
end
|
62
|
+
|
63
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
64
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
65
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
66
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::HistoryRecordResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
67
|
+
end
|
68
|
+
h[k.to_sym] = v
|
69
|
+
}
|
70
|
+
|
71
|
+
if attributes.key?(:'changes')
|
72
|
+
self.changes = attributes[:'changes']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes.key?(:'date_utc_string')
|
76
|
+
self.date_utc_string = attributes[:'date_utc_string']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.key?(:'date_utc')
|
80
|
+
self.date_utc = attributes[:'date_utc']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.key?(:'user')
|
84
|
+
self.user = attributes[:'user']
|
85
|
+
end
|
86
|
+
|
87
|
+
if attributes.key?(:'details')
|
88
|
+
self.details = attributes[:'details']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
93
|
+
# @return Array for valid properties with the reasons
|
94
|
+
def list_invalid_properties
|
95
|
+
invalid_properties = Array.new
|
96
|
+
invalid_properties
|
97
|
+
end
|
98
|
+
|
99
|
+
# Check to see if the all the properties in the model are valid
|
100
|
+
# @return true if the model is valid
|
101
|
+
def valid?
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
105
|
+
# Checks equality by comparing each attribute.
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def ==(o)
|
108
|
+
return true if self.equal?(o)
|
109
|
+
self.class == o.class &&
|
110
|
+
changes == o.changes &&
|
111
|
+
date_utc_string == o.date_utc_string &&
|
112
|
+
date_utc == o.date_utc &&
|
113
|
+
user == o.user &&
|
114
|
+
details == o.details
|
115
|
+
end
|
116
|
+
|
117
|
+
# @see the `==` method
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def eql?(o)
|
120
|
+
self == o
|
121
|
+
end
|
122
|
+
|
123
|
+
# Calculates hash code according to all attributes.
|
124
|
+
# @return [Integer] Hash code
|
125
|
+
def hash
|
126
|
+
[changes, date_utc_string, date_utc, user, details].hash
|
127
|
+
end
|
128
|
+
|
129
|
+
# Builds the object from hash
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
131
|
+
# @return [Object] Returns the model itself
|
132
|
+
def self.build_from_hash(attributes)
|
133
|
+
new.build_from_hash(attributes)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Builds the object from hash
|
137
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
138
|
+
# @return [Object] Returns the model itself
|
139
|
+
def build_from_hash(attributes)
|
140
|
+
return nil unless attributes.is_a?(Hash)
|
141
|
+
self.class.openapi_types.each_pair do |key, type|
|
142
|
+
if type =~ /\AArray<(.*)>/i
|
143
|
+
# check to ensure the input is an array given that the attribute
|
144
|
+
# is documented as an array but the input is not
|
145
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
146
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
147
|
+
end
|
148
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
149
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
150
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
151
|
+
end
|
152
|
+
|
153
|
+
self
|
154
|
+
end
|
155
|
+
|
156
|
+
# Deserializes the data based on type
|
157
|
+
# @param string type Data type
|
158
|
+
# @param string value Value to be deserialized
|
159
|
+
# @return [Object] Deserialized data
|
160
|
+
def _deserialize(type, value)
|
161
|
+
case type.to_sym
|
162
|
+
when :DateTime
|
163
|
+
DateTime.parse(parse_date(value))
|
164
|
+
when :Date
|
165
|
+
Date.parse(parse_date(value))
|
166
|
+
when :String
|
167
|
+
value.to_s
|
168
|
+
when :Integer
|
169
|
+
value.to_i
|
170
|
+
when :Float
|
171
|
+
value.to_f
|
172
|
+
when :BigDecimal
|
173
|
+
BigDecimal(value.to_s)
|
174
|
+
when :Boolean
|
175
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
176
|
+
true
|
177
|
+
else
|
178
|
+
false
|
179
|
+
end
|
180
|
+
when :Object
|
181
|
+
# generic object (usually a Hash), return directly
|
182
|
+
value
|
183
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
184
|
+
inner_type = Regexp.last_match[:inner_type]
|
185
|
+
value.map { |v| _deserialize(inner_type, v) }
|
186
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
187
|
+
k_type = Regexp.last_match[:k_type]
|
188
|
+
v_type = Regexp.last_match[:v_type]
|
189
|
+
{}.tap do |hash|
|
190
|
+
value.each do |k, v|
|
191
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
else # model
|
195
|
+
XeroRuby::Finance.const_get(type).build_from_hash(value)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Returns the string representation of the object
|
200
|
+
# @return [String] String presentation of the object
|
201
|
+
def to_s
|
202
|
+
to_hash.to_s
|
203
|
+
end
|
204
|
+
|
205
|
+
# to_body is an alias to to_hash (backward compatibility)
|
206
|
+
# @return [Hash] Returns the object in the form of hash
|
207
|
+
def to_body
|
208
|
+
to_hash
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the object in the form of hash
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
213
|
+
def to_hash(downcase: false)
|
214
|
+
hash = {}
|
215
|
+
self.class.attribute_map.each_pair do |attr, param|
|
216
|
+
value = self.send(attr)
|
217
|
+
next if value.nil?
|
218
|
+
key = downcase ? attr : param
|
219
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
220
|
+
end
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Returns the object in the form of hash with snake_case
|
225
|
+
def to_attributes
|
226
|
+
to_hash(downcase: true)
|
227
|
+
end
|
228
|
+
|
229
|
+
# Outputs non-array value in the form of hash
|
230
|
+
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
# @param [Object] value Any valid value
|
232
|
+
# @return [Hash] Returns the value in the form of hash
|
233
|
+
def _to_hash(value, downcase: false)
|
234
|
+
if value.is_a?(Array)
|
235
|
+
value.map do |v|
|
236
|
+
v.to_hash(downcase: downcase)
|
237
|
+
end
|
238
|
+
elsif value.is_a?(Hash)
|
239
|
+
{}.tap do |hash|
|
240
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
241
|
+
end
|
242
|
+
elsif value.respond_to? :to_hash
|
243
|
+
value.to_hash(downcase: downcase)
|
244
|
+
else
|
245
|
+
value
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def parse_date(datestring)
|
250
|
+
if datestring.include?('Date')
|
251
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
252
|
+
original, date, timezone = *date_pattern.match(datestring)
|
253
|
+
date = (date.to_i / 1000)
|
254
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
255
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
256
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
257
|
+
else # handle date 'types' for small subset of payroll API's
|
258
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|