xero-ruby 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/finance_api.rb +866 -0
  3. data/lib/xero-ruby/api_client.rb +11 -0
  4. data/lib/xero-ruby/configuration.rb +2 -0
  5. data/lib/xero-ruby/models/accounting/contact.rb +86 -1
  6. data/lib/xero-ruby/models/finance/account_usage.rb +342 -0
  7. data/lib/xero-ruby/models/finance/account_usage_response.rb +254 -0
  8. data/lib/xero-ruby/models/finance/balance_sheet_account_detail.rb +262 -0
  9. data/lib/xero-ruby/models/finance/balance_sheet_account_group.rb +234 -0
  10. data/lib/xero-ruby/models/finance/balance_sheet_account_type.rb +244 -0
  11. data/lib/xero-ruby/models/finance/balance_sheet_response.rb +252 -0
  12. data/lib/xero-ruby/models/finance/bank_statement_response.rb +232 -0
  13. data/lib/xero-ruby/models/finance/cash_account_response.rb +262 -0
  14. data/lib/xero-ruby/models/finance/cash_balance.rb +242 -0
  15. data/lib/xero-ruby/models/finance/cash_validation_response.rb +262 -0
  16. data/lib/xero-ruby/models/finance/cashflow_account.rb +282 -0
  17. data/lib/xero-ruby/models/finance/cashflow_activity.rb +244 -0
  18. data/lib/xero-ruby/models/finance/cashflow_response.rb +254 -0
  19. data/lib/xero-ruby/models/finance/cashflow_type.rb +244 -0
  20. data/lib/xero-ruby/models/finance/contact_detail.rb +274 -0
  21. data/lib/xero-ruby/models/finance/contact_total_detail.rb +242 -0
  22. data/lib/xero-ruby/models/finance/contact_total_other.rb +252 -0
  23. data/lib/xero-ruby/models/finance/current_statement_response.rb +272 -0
  24. data/lib/xero-ruby/models/finance/data_source_response.rb +362 -0
  25. data/lib/xero-ruby/models/finance/history_record_response.rb +262 -0
  26. data/lib/xero-ruby/models/finance/income_by_contact_response.rb +284 -0
  27. data/lib/xero-ruby/models/finance/lock_history_model.rb +242 -0
  28. data/lib/xero-ruby/models/finance/lock_history_response.rb +244 -0
  29. data/lib/xero-ruby/models/finance/manual_journal_total.rb +222 -0
  30. data/lib/xero-ruby/models/finance/pnl_account.rb +272 -0
  31. data/lib/xero-ruby/models/finance/pnl_account_class.rb +234 -0
  32. data/lib/xero-ruby/models/finance/pnl_account_type.rb +244 -0
  33. data/lib/xero-ruby/models/finance/practice_response.rb +262 -0
  34. data/lib/xero-ruby/models/finance/problem.rb +252 -0
  35. data/lib/xero-ruby/models/finance/problem_type.rb +39 -0
  36. data/lib/xero-ruby/models/finance/profit_and_loss_response.rb +262 -0
  37. data/lib/xero-ruby/models/finance/report_history_model.rb +242 -0
  38. data/lib/xero-ruby/models/finance/report_history_response.rb +244 -0
  39. data/lib/xero-ruby/models/finance/statement_balance_response.rb +232 -0
  40. data/lib/xero-ruby/models/finance/statement_lines_response.rb +382 -0
  41. data/lib/xero-ruby/models/finance/total_detail.rb +242 -0
  42. data/lib/xero-ruby/models/finance/total_other.rb +242 -0
  43. data/lib/xero-ruby/models/finance/trial_balance_account.rb +312 -0
  44. data/lib/xero-ruby/models/finance/trial_balance_entry.rb +232 -0
  45. data/lib/xero-ruby/models/finance/trial_balance_movement.rb +252 -0
  46. data/lib/xero-ruby/models/finance/trial_balance_response.rb +244 -0
  47. data/lib/xero-ruby/models/finance/user_activities_response.rb +244 -0
  48. data/lib/xero-ruby/models/finance/user_response.rb +336 -0
  49. data/lib/xero-ruby/version.rb +6 -6
  50. data/lib/xero-ruby.rb +44 -0
  51. data/spec/api_client_spec.rb +3 -0
  52. data/spec/app_store/api/app_store_api_spec.rb +1 -1
  53. data/spec/configuration_spec.rb +1 -0
  54. data/spec/finance/api/finance_api_spec.rb +156 -0
  55. data/spec/finance/models/account_usage_response_spec.rb +58 -0
  56. data/spec/finance/models/account_usage_spec.rb +112 -0
  57. data/spec/finance/models/balance_sheet_account_detail_spec.rb +64 -0
  58. data/spec/finance/models/balance_sheet_account_group_spec.rb +46 -0
  59. data/spec/finance/models/balance_sheet_account_type_spec.rb +52 -0
  60. data/spec/finance/models/balance_sheet_response_spec.rb +58 -0
  61. data/spec/finance/models/bank_statement_response_spec.rb +46 -0
  62. data/spec/finance/models/cash_account_response_spec.rb +64 -0
  63. data/spec/finance/models/cash_balance_spec.rb +52 -0
  64. data/spec/finance/models/cash_validation_response_spec.rb +64 -0
  65. data/spec/finance/models/cashflow_account_spec.rb +76 -0
  66. data/spec/finance/models/cashflow_activity_spec.rb +52 -0
  67. data/spec/finance/models/cashflow_response_spec.rb +58 -0
  68. data/spec/finance/models/cashflow_type_spec.rb +52 -0
  69. data/spec/finance/models/current_statement_response_spec.rb +70 -0
  70. data/spec/finance/models/data_source_response_spec.rb +124 -0
  71. data/spec/finance/models/history_record_response_spec.rb +64 -0
  72. data/spec/finance/models/lock_history_model_spec.rb +52 -0
  73. data/spec/finance/models/lock_history_response_spec.rb +52 -0
  74. data/spec/finance/models/pnl_account_class_spec.rb +46 -0
  75. data/spec/finance/models/pnl_account_spec.rb +70 -0
  76. data/spec/finance/models/pnl_account_type_spec.rb +52 -0
  77. data/spec/finance/models/practice_response_spec.rb +64 -0
  78. data/spec/finance/models/problem_spec.rb +58 -0
  79. data/spec/finance/models/problem_type_spec.rb +34 -0
  80. data/spec/finance/models/profit_and_loss_response_spec.rb +64 -0
  81. data/spec/finance/models/report_history_model_spec.rb +52 -0
  82. data/spec/finance/models/report_history_response_spec.rb +52 -0
  83. data/spec/finance/models/statement_balance_response_spec.rb +46 -0
  84. data/spec/finance/models/statement_lines_response_spec.rb +136 -0
  85. data/spec/finance/models/trial_balance_account_spec.rb +94 -0
  86. data/spec/finance/models/trial_balance_entry_spec.rb +46 -0
  87. data/spec/finance/models/trial_balance_movement_spec.rb +58 -0
  88. data/spec/finance/models/trial_balance_response_spec.rb +52 -0
  89. data/spec/finance/models/user_activities_response_spec.rb +52 -0
  90. data/spec/finance/models/user_response_spec.rb +106 -0
  91. metadata +120 -2
@@ -0,0 +1,272 @@
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 CurrentStatementResponse
19
+ # Looking at the most recent bank statement, this field indicates the first date which transactions on this statement pertain to. This date is represented in ISO 8601 format.
20
+ attr_accessor :start_date
21
+
22
+ # Looking at the most recent bank statement, this field indicates the last date which transactions on this statement pertain to. This date is represented in ISO 8601 format.
23
+ attr_accessor :end_date
24
+
25
+ # Looking at the most recent bank statement, this field indicates the balance before the transactions on the statement are applied (note, this is not always populated by the bank in every single instance (~10%)).
26
+ attr_accessor :start_balance
27
+
28
+ # Looking at the most recent bank statement, this field indicates the balance after the transactions on the statement are applied (note, this is not always populated by the bank in every single instance (~10%)).
29
+ attr_accessor :end_balance
30
+
31
+ # Looking at the most recent bank statement, this field indicates when the document was imported into Xero. This date is represented in ISO 8601 format.
32
+ attr_accessor :imported_date_time_utc
33
+
34
+ # Looking at the most recent bank statement, this field indicates the source of the data (direct bank feed, indirect bank feed, file upload, or manual keying).
35
+ attr_accessor :import_source_type
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'start_date' => :'startDate',
41
+ :'end_date' => :'endDate',
42
+ :'start_balance' => :'startBalance',
43
+ :'end_balance' => :'endBalance',
44
+ :'imported_date_time_utc' => :'importedDateTimeUtc',
45
+ :'import_source_type' => :'importSourceType'
46
+ }
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.openapi_types
51
+ {
52
+ :'start_date' => :'Date',
53
+ :'end_date' => :'Date',
54
+ :'start_balance' => :'BigDecimal',
55
+ :'end_balance' => :'BigDecimal',
56
+ :'imported_date_time_utc' => :'DateTime',
57
+ :'import_source_type' => :'String'
58
+ }
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::CurrentStatementResponse` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::CurrentStatementResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'start_date')
77
+ self.start_date = attributes[:'start_date']
78
+ end
79
+
80
+ if attributes.key?(:'end_date')
81
+ self.end_date = attributes[:'end_date']
82
+ end
83
+
84
+ if attributes.key?(:'start_balance')
85
+ self.start_balance = attributes[:'start_balance']
86
+ end
87
+
88
+ if attributes.key?(:'end_balance')
89
+ self.end_balance = attributes[:'end_balance']
90
+ end
91
+
92
+ if attributes.key?(:'imported_date_time_utc')
93
+ self.imported_date_time_utc = attributes[:'imported_date_time_utc']
94
+ end
95
+
96
+ if attributes.key?(:'import_source_type')
97
+ self.import_source_type = attributes[:'import_source_type']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ start_date == o.start_date &&
120
+ end_date == o.end_date &&
121
+ start_balance == o.start_balance &&
122
+ end_balance == o.end_balance &&
123
+ imported_date_time_utc == o.imported_date_time_utc &&
124
+ import_source_type == o.import_source_type
125
+ end
126
+
127
+ # @see the `==` method
128
+ # @param [Object] Object to be compared
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculates hash code according to all attributes.
134
+ # @return [Integer] Hash code
135
+ def hash
136
+ [start_date, end_date, start_balance, end_balance, imported_date_time_utc, import_source_type].hash
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def self.build_from_hash(attributes)
143
+ new.build_from_hash(attributes)
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
156
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
157
+ end
158
+ elsif !attributes[self.class.attribute_map[key]].nil?
159
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
161
+ end
162
+
163
+ self
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def _deserialize(type, value)
171
+ case type.to_sym
172
+ when :DateTime
173
+ DateTime.parse(parse_date(value))
174
+ when :Date
175
+ Date.parse(parse_date(value))
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :BigDecimal
183
+ BigDecimal(value.to_s)
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ XeroRuby::Finance.const_get(type).build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash(downcase: false)
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ next if value.nil?
228
+ key = downcase ? attr : param
229
+ hash[key] = _to_hash(value, downcase: downcase)
230
+ end
231
+ hash
232
+ end
233
+
234
+ # Returns the object in the form of hash with snake_case
235
+ def to_attributes
236
+ to_hash(downcase: true)
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value, downcase: false)
244
+ if value.is_a?(Array)
245
+ value.map do |v|
246
+ v.to_hash(downcase: downcase)
247
+ end
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash(downcase: downcase)
254
+ else
255
+ value
256
+ end
257
+ end
258
+
259
+ def parse_date(datestring)
260
+ if datestring.include?('Date')
261
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
262
+ original, date, timezone = *date_pattern.match(datestring)
263
+ date = (date.to_i / 1000)
264
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
265
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
266
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
267
+ else # handle date 'types' for small subset of payroll API's
268
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
269
+ end
270
+ end
271
+ end
272
+ end
@@ -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