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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +71 -2
  3. data/lib/xero-ruby/api/accounting_api.rb +11 -2
  4. data/lib/xero-ruby/api/app_store_api.rb +87 -0
  5. data/lib/xero-ruby/api/finance_api.rb +866 -0
  6. data/lib/xero-ruby/api/payroll_au_api.rb +14 -14
  7. data/lib/xero-ruby/api/payroll_nz_api.rb +18 -12
  8. data/lib/xero-ruby/api/payroll_uk_api.rb +14 -2
  9. data/lib/xero-ruby/api_client.rb +30 -4
  10. data/lib/xero-ruby/configuration.rb +4 -0
  11. data/lib/xero-ruby/models/accounting/bank_transfer.rb +35 -1
  12. data/lib/xero-ruby/models/accounting/budget_balance.rb +2 -2
  13. data/lib/xero-ruby/models/accounting/contact.rb +86 -1
  14. data/lib/xero-ruby/models/accounting/payment.rb +11 -1
  15. data/lib/xero-ruby/models/accounting/time_zone.rb +1 -0
  16. data/lib/xero-ruby/models/app_store/plan.rb +310 -0
  17. data/lib/xero-ruby/models/app_store/price.rb +257 -0
  18. data/lib/xero-ruby/models/app_store/problem_details.rb +272 -0
  19. data/lib/xero-ruby/models/app_store/product.rb +288 -0
  20. data/lib/xero-ruby/models/app_store/subscription.rb +324 -0
  21. data/lib/xero-ruby/models/app_store/subscription_item.rb +292 -0
  22. data/lib/xero-ruby/models/finance/account_usage.rb +342 -0
  23. data/lib/xero-ruby/models/finance/account_usage_response.rb +254 -0
  24. data/lib/xero-ruby/models/finance/balance_sheet_account_detail.rb +262 -0
  25. data/lib/xero-ruby/models/finance/balance_sheet_account_group.rb +234 -0
  26. data/lib/xero-ruby/models/finance/balance_sheet_account_type.rb +244 -0
  27. data/lib/xero-ruby/models/finance/balance_sheet_response.rb +252 -0
  28. data/lib/xero-ruby/models/finance/bank_statement_response.rb +232 -0
  29. data/lib/xero-ruby/models/finance/cash_account_response.rb +262 -0
  30. data/lib/xero-ruby/models/finance/cash_balance.rb +242 -0
  31. data/lib/xero-ruby/models/finance/cash_validation_response.rb +262 -0
  32. data/lib/xero-ruby/models/finance/cashflow_account.rb +282 -0
  33. data/lib/xero-ruby/models/finance/cashflow_activity.rb +244 -0
  34. data/lib/xero-ruby/models/finance/cashflow_response.rb +254 -0
  35. data/lib/xero-ruby/models/finance/cashflow_type.rb +244 -0
  36. data/lib/xero-ruby/models/finance/contact_detail.rb +274 -0
  37. data/lib/xero-ruby/models/finance/contact_total_detail.rb +242 -0
  38. data/lib/xero-ruby/models/finance/contact_total_other.rb +252 -0
  39. data/lib/xero-ruby/models/finance/current_statement_response.rb +272 -0
  40. data/lib/xero-ruby/models/finance/data_source_response.rb +362 -0
  41. data/lib/xero-ruby/models/finance/history_record_response.rb +262 -0
  42. data/lib/xero-ruby/models/finance/income_by_contact_response.rb +284 -0
  43. data/lib/xero-ruby/models/finance/lock_history_model.rb +242 -0
  44. data/lib/xero-ruby/models/finance/lock_history_response.rb +244 -0
  45. data/lib/xero-ruby/models/finance/manual_journal_total.rb +222 -0
  46. data/lib/xero-ruby/models/finance/pnl_account.rb +272 -0
  47. data/lib/xero-ruby/models/finance/pnl_account_class.rb +234 -0
  48. data/lib/xero-ruby/models/finance/pnl_account_type.rb +244 -0
  49. data/lib/xero-ruby/models/finance/practice_response.rb +262 -0
  50. data/lib/xero-ruby/models/finance/problem.rb +252 -0
  51. data/lib/xero-ruby/models/finance/problem_type.rb +39 -0
  52. data/lib/xero-ruby/models/finance/profit_and_loss_response.rb +262 -0
  53. data/lib/xero-ruby/models/finance/report_history_model.rb +242 -0
  54. data/lib/xero-ruby/models/finance/report_history_response.rb +244 -0
  55. data/lib/xero-ruby/models/finance/statement_balance_response.rb +232 -0
  56. data/lib/xero-ruby/models/finance/statement_lines_response.rb +382 -0
  57. data/lib/xero-ruby/models/finance/total_detail.rb +242 -0
  58. data/lib/xero-ruby/models/finance/total_other.rb +242 -0
  59. data/lib/xero-ruby/models/finance/trial_balance_account.rb +312 -0
  60. data/lib/xero-ruby/models/finance/trial_balance_entry.rb +232 -0
  61. data/lib/xero-ruby/models/finance/trial_balance_movement.rb +252 -0
  62. data/lib/xero-ruby/models/finance/trial_balance_response.rb +244 -0
  63. data/lib/xero-ruby/models/finance/user_activities_response.rb +244 -0
  64. data/lib/xero-ruby/models/finance/user_response.rb +336 -0
  65. data/lib/xero-ruby/models/payroll_au/earnings_type.rb +2 -0
  66. data/lib/xero-ruby/models/payroll_au/employee.rb +30 -1
  67. data/lib/xero-ruby/models/payroll_au/manual_tax_type.rb +1 -0
  68. data/lib/xero-ruby/models/payroll_au/payroll_calendar.rb +11 -1
  69. data/lib/xero-ruby/models/payroll_uk/earnings_rate.rb +4 -4
  70. data/lib/xero-ruby/version.rb +6 -6
  71. data/lib/xero-ruby.rb +51 -0
  72. data/spec/api_client_spec.rb +5 -2
  73. data/spec/app_store/api/app_store_api_spec.rb +45 -0
  74. data/spec/app_store/models/plan_spec.rb +62 -0
  75. data/spec/app_store/models/price_spec.rb +52 -0
  76. data/spec/app_store/models/problem_details_spec.rb +70 -0
  77. data/spec/app_store/models/product_spec.rb +56 -0
  78. data/spec/app_store/models/subscription_item_spec.rb +70 -0
  79. data/spec/app_store/models/subscription_spec.rb +82 -0
  80. data/spec/configuration_spec.rb +1 -0
  81. data/spec/finance/api/finance_api_spec.rb +156 -0
  82. data/spec/finance/models/account_usage_response_spec.rb +58 -0
  83. data/spec/finance/models/account_usage_spec.rb +112 -0
  84. data/spec/finance/models/balance_sheet_account_detail_spec.rb +64 -0
  85. data/spec/finance/models/balance_sheet_account_group_spec.rb +46 -0
  86. data/spec/finance/models/balance_sheet_account_type_spec.rb +52 -0
  87. data/spec/finance/models/balance_sheet_response_spec.rb +58 -0
  88. data/spec/finance/models/bank_statement_response_spec.rb +46 -0
  89. data/spec/finance/models/cash_account_response_spec.rb +64 -0
  90. data/spec/finance/models/cash_balance_spec.rb +52 -0
  91. data/spec/finance/models/cash_validation_response_spec.rb +64 -0
  92. data/spec/finance/models/cashflow_account_spec.rb +76 -0
  93. data/spec/finance/models/cashflow_activity_spec.rb +52 -0
  94. data/spec/finance/models/cashflow_response_spec.rb +58 -0
  95. data/spec/finance/models/cashflow_type_spec.rb +52 -0
  96. data/spec/finance/models/current_statement_response_spec.rb +70 -0
  97. data/spec/finance/models/data_source_response_spec.rb +124 -0
  98. data/spec/finance/models/history_record_response_spec.rb +64 -0
  99. data/spec/finance/models/lock_history_model_spec.rb +52 -0
  100. data/spec/finance/models/lock_history_response_spec.rb +52 -0
  101. data/spec/finance/models/pnl_account_class_spec.rb +46 -0
  102. data/spec/finance/models/pnl_account_spec.rb +70 -0
  103. data/spec/finance/models/pnl_account_type_spec.rb +52 -0
  104. data/spec/finance/models/practice_response_spec.rb +64 -0
  105. data/spec/finance/models/problem_spec.rb +58 -0
  106. data/spec/finance/models/problem_type_spec.rb +34 -0
  107. data/spec/finance/models/profit_and_loss_response_spec.rb +64 -0
  108. data/spec/finance/models/report_history_model_spec.rb +52 -0
  109. data/spec/finance/models/report_history_response_spec.rb +52 -0
  110. data/spec/finance/models/statement_balance_response_spec.rb +46 -0
  111. data/spec/finance/models/statement_lines_response_spec.rb +136 -0
  112. data/spec/finance/models/trial_balance_account_spec.rb +94 -0
  113. data/spec/finance/models/trial_balance_entry_spec.rb +46 -0
  114. data/spec/finance/models/trial_balance_movement_spec.rb +58 -0
  115. data/spec/finance/models/trial_balance_response_spec.rb +52 -0
  116. data/spec/finance/models/user_activities_response_spec.rb +52 -0
  117. data/spec/finance/models/user_response_spec.rb +106 -0
  118. metadata +142 -3
@@ -0,0 +1,232 @@
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 StatementBalanceResponse
19
+ # Total closing balance of the account. This includes both reconciled and unreconciled bank statement lines. The closing balance will always be represented as a positive number, with it’s debit/credit status defined in the statementBalanceDebitCredit field.
20
+ attr_accessor :value
21
+
22
+ # The DEBIT or CREDIT status of the account. Cash accounts in credit have a negative balance.
23
+ attr_accessor :type
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'value' => :'value',
29
+ :'type' => :'type'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'value' => :'BigDecimal',
37
+ :'type' => :'String'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::StatementBalanceResponse` initialize method"
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::StatementBalanceResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+ h[k.to_sym] = v
54
+ }
55
+
56
+ if attributes.key?(:'value')
57
+ self.value = attributes[:'value']
58
+ end
59
+
60
+ if attributes.key?(:'type')
61
+ self.type = attributes[:'type']
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ value == o.value &&
84
+ type == o.type
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [value, type].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
117
+ end
118
+ elsif !attributes[self.class.attribute_map[key]].nil?
119
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
121
+ end
122
+
123
+ self
124
+ end
125
+
126
+ # Deserializes the data based on type
127
+ # @param string type Data type
128
+ # @param string value Value to be deserialized
129
+ # @return [Object] Deserialized data
130
+ def _deserialize(type, value)
131
+ case type.to_sym
132
+ when :DateTime
133
+ DateTime.parse(parse_date(value))
134
+ when :Date
135
+ Date.parse(parse_date(value))
136
+ when :String
137
+ value.to_s
138
+ when :Integer
139
+ value.to_i
140
+ when :Float
141
+ value.to_f
142
+ when :BigDecimal
143
+ BigDecimal(value.to_s)
144
+ when :Boolean
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ XeroRuby::Finance.const_get(type).build_from_hash(value)
166
+ end
167
+ end
168
+
169
+ # Returns the string representation of the object
170
+ # @return [String] String presentation of the object
171
+ def to_s
172
+ to_hash.to_s
173
+ end
174
+
175
+ # to_body is an alias to to_hash (backward compatibility)
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_body
178
+ to_hash
179
+ end
180
+
181
+ # Returns the object in the form of hash
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_hash(downcase: false)
184
+ hash = {}
185
+ self.class.attribute_map.each_pair do |attr, param|
186
+ value = self.send(attr)
187
+ next if value.nil?
188
+ key = downcase ? attr : param
189
+ hash[key] = _to_hash(value, downcase: downcase)
190
+ end
191
+ hash
192
+ end
193
+
194
+ # Returns the object in the form of hash with snake_case
195
+ def to_attributes
196
+ to_hash(downcase: true)
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value, downcase: false)
204
+ if value.is_a?(Array)
205
+ value.map do |v|
206
+ v.to_hash(downcase: downcase)
207
+ end
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash(downcase: downcase)
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ def parse_date(datestring)
220
+ if datestring.include?('Date')
221
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
222
+ original, date, timezone = *date_pattern.match(datestring)
223
+ date = (date.to_i / 1000)
224
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
225
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
226
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
227
+ else # handle date 'types' for small subset of payroll API's
228
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
229
+ end
230
+ end
231
+ end
232
+ end
@@ -0,0 +1,382 @@
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 StatementLinesResponse
19
+ # Sum of the amounts of all statement lines where both the reconciled flag is set to FALSE, and the amount is positive.
20
+ attr_accessor :unreconciled_amount_pos
21
+
22
+ # Sum of the amounts of all statement lines where both the reconciled flag is set to FALSE, and the amount is negative.
23
+ attr_accessor :unreconciled_amount_neg
24
+
25
+ # Count of all statement lines where the reconciled flag is set to FALSE.
26
+ attr_accessor :unreconciled_lines
27
+
28
+ # Sum-product of age of statement line in days multiplied by transaction amount, divided by the sum of transaction amount - in for those statement lines in which the reconciled flag is set to FALSE, and the amount is positive. Provides an indication of the age of unreconciled transactions.
29
+ attr_accessor :avg_days_unreconciled_pos
30
+
31
+ # Sum-product of age of statement line in days multiplied by transaction amount, divided by the sum of transaction amount - in for those statement lines in which the reconciled flag is set to FALSE, and the amount is negative. Provides an indication of the age of unreconciled transactions.
32
+ attr_accessor :avg_days_unreconciled_neg
33
+
34
+ # UTC Date which is the earliest transaction date of a statement line for which the reconciled flag is set to FALSE. This date is represented in ISO 8601 format.
35
+ attr_accessor :earliest_unreconciled_transaction
36
+
37
+ # UTC Date which is the latest transaction date of a statement line for which the reconciled flag is set to FALSE. This date is represented in ISO 8601 format.
38
+ attr_accessor :latest_unreconciled_transaction
39
+
40
+ # Sum of the amounts of all deleted statement lines. Transactions may be deleted due to duplication or otherwise.
41
+ attr_accessor :deleted_amount
42
+
43
+ # Sum of the amounts of all statement lines. This is used as a metric of comparison to the unreconciled figures above.
44
+ attr_accessor :total_amount
45
+
46
+
47
+ attr_accessor :data_source
48
+
49
+ # UTC Date which is the earliest transaction date of a statement line for which the reconciled flag is set to TRUE. This date is represented in ISO 8601 format.
50
+ attr_accessor :earliest_reconciled_transaction
51
+
52
+ # UTC Date which is the latest transaction date of a statement line for which the reconciled flag is set to TRUE. This date is represented in ISO 8601 format.
53
+ attr_accessor :latest_reconciled_transaction
54
+
55
+ # Sum of the amounts of all statement lines where both the reconciled flag is set to TRUE, and the amount is positive.
56
+ attr_accessor :reconciled_amount_pos
57
+
58
+ # Sum of the amounts of all statement lines where both the reconciled flag is set to TRUE, and the amount is negative.
59
+ attr_accessor :reconciled_amount_neg
60
+
61
+ # Count of all statement lines where the reconciled flag is set to TRUE
62
+ attr_accessor :reconciled_lines
63
+
64
+ # Sum of the amounts of all statement lines where the amount is positive
65
+ attr_accessor :total_amount_pos
66
+
67
+ # Sum of the amounts of all statement lines where the amount is negative.
68
+ attr_accessor :total_amount_neg
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'unreconciled_amount_pos' => :'unreconciledAmountPos',
74
+ :'unreconciled_amount_neg' => :'unreconciledAmountNeg',
75
+ :'unreconciled_lines' => :'unreconciledLines',
76
+ :'avg_days_unreconciled_pos' => :'avgDaysUnreconciledPos',
77
+ :'avg_days_unreconciled_neg' => :'avgDaysUnreconciledNeg',
78
+ :'earliest_unreconciled_transaction' => :'earliestUnreconciledTransaction',
79
+ :'latest_unreconciled_transaction' => :'latestUnreconciledTransaction',
80
+ :'deleted_amount' => :'deletedAmount',
81
+ :'total_amount' => :'totalAmount',
82
+ :'data_source' => :'dataSource',
83
+ :'earliest_reconciled_transaction' => :'earliestReconciledTransaction',
84
+ :'latest_reconciled_transaction' => :'latestReconciledTransaction',
85
+ :'reconciled_amount_pos' => :'reconciledAmountPos',
86
+ :'reconciled_amount_neg' => :'reconciledAmountNeg',
87
+ :'reconciled_lines' => :'reconciledLines',
88
+ :'total_amount_pos' => :'totalAmountPos',
89
+ :'total_amount_neg' => :'totalAmountNeg'
90
+ }
91
+ end
92
+
93
+ # Attribute type mapping.
94
+ def self.openapi_types
95
+ {
96
+ :'unreconciled_amount_pos' => :'BigDecimal',
97
+ :'unreconciled_amount_neg' => :'BigDecimal',
98
+ :'unreconciled_lines' => :'Integer',
99
+ :'avg_days_unreconciled_pos' => :'BigDecimal',
100
+ :'avg_days_unreconciled_neg' => :'BigDecimal',
101
+ :'earliest_unreconciled_transaction' => :'Date',
102
+ :'latest_unreconciled_transaction' => :'Date',
103
+ :'deleted_amount' => :'BigDecimal',
104
+ :'total_amount' => :'BigDecimal',
105
+ :'data_source' => :'DataSourceResponse',
106
+ :'earliest_reconciled_transaction' => :'Date',
107
+ :'latest_reconciled_transaction' => :'Date',
108
+ :'reconciled_amount_pos' => :'BigDecimal',
109
+ :'reconciled_amount_neg' => :'BigDecimal',
110
+ :'reconciled_lines' => :'Integer',
111
+ :'total_amount_pos' => :'BigDecimal',
112
+ :'total_amount_neg' => :'BigDecimal'
113
+ }
114
+ end
115
+
116
+ # Initializes the object
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ def initialize(attributes = {})
119
+ if (!attributes.is_a?(Hash))
120
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::StatementLinesResponse` initialize method"
121
+ end
122
+
123
+ # check to see if the attribute exists and convert string to symbol for hash key
124
+ attributes = attributes.each_with_object({}) { |(k, v), h|
125
+ if (!self.class.attribute_map.key?(k.to_sym))
126
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::StatementLinesResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
127
+ end
128
+ h[k.to_sym] = v
129
+ }
130
+
131
+ if attributes.key?(:'unreconciled_amount_pos')
132
+ self.unreconciled_amount_pos = attributes[:'unreconciled_amount_pos']
133
+ end
134
+
135
+ if attributes.key?(:'unreconciled_amount_neg')
136
+ self.unreconciled_amount_neg = attributes[:'unreconciled_amount_neg']
137
+ end
138
+
139
+ if attributes.key?(:'unreconciled_lines')
140
+ self.unreconciled_lines = attributes[:'unreconciled_lines']
141
+ end
142
+
143
+ if attributes.key?(:'avg_days_unreconciled_pos')
144
+ self.avg_days_unreconciled_pos = attributes[:'avg_days_unreconciled_pos']
145
+ end
146
+
147
+ if attributes.key?(:'avg_days_unreconciled_neg')
148
+ self.avg_days_unreconciled_neg = attributes[:'avg_days_unreconciled_neg']
149
+ end
150
+
151
+ if attributes.key?(:'earliest_unreconciled_transaction')
152
+ self.earliest_unreconciled_transaction = attributes[:'earliest_unreconciled_transaction']
153
+ end
154
+
155
+ if attributes.key?(:'latest_unreconciled_transaction')
156
+ self.latest_unreconciled_transaction = attributes[:'latest_unreconciled_transaction']
157
+ end
158
+
159
+ if attributes.key?(:'deleted_amount')
160
+ self.deleted_amount = attributes[:'deleted_amount']
161
+ end
162
+
163
+ if attributes.key?(:'total_amount')
164
+ self.total_amount = attributes[:'total_amount']
165
+ end
166
+
167
+ if attributes.key?(:'data_source')
168
+ self.data_source = attributes[:'data_source']
169
+ end
170
+
171
+ if attributes.key?(:'earliest_reconciled_transaction')
172
+ self.earliest_reconciled_transaction = attributes[:'earliest_reconciled_transaction']
173
+ end
174
+
175
+ if attributes.key?(:'latest_reconciled_transaction')
176
+ self.latest_reconciled_transaction = attributes[:'latest_reconciled_transaction']
177
+ end
178
+
179
+ if attributes.key?(:'reconciled_amount_pos')
180
+ self.reconciled_amount_pos = attributes[:'reconciled_amount_pos']
181
+ end
182
+
183
+ if attributes.key?(:'reconciled_amount_neg')
184
+ self.reconciled_amount_neg = attributes[:'reconciled_amount_neg']
185
+ end
186
+
187
+ if attributes.key?(:'reconciled_lines')
188
+ self.reconciled_lines = attributes[:'reconciled_lines']
189
+ end
190
+
191
+ if attributes.key?(:'total_amount_pos')
192
+ self.total_amount_pos = attributes[:'total_amount_pos']
193
+ end
194
+
195
+ if attributes.key?(:'total_amount_neg')
196
+ self.total_amount_neg = attributes[:'total_amount_neg']
197
+ end
198
+ end
199
+
200
+ # Show invalid properties with the reasons. Usually used together with valid?
201
+ # @return Array for valid properties with the reasons
202
+ def list_invalid_properties
203
+ invalid_properties = Array.new
204
+ invalid_properties
205
+ end
206
+
207
+ # Check to see if the all the properties in the model are valid
208
+ # @return true if the model is valid
209
+ def valid?
210
+ true
211
+ end
212
+
213
+ # Checks equality by comparing each attribute.
214
+ # @param [Object] Object to be compared
215
+ def ==(o)
216
+ return true if self.equal?(o)
217
+ self.class == o.class &&
218
+ unreconciled_amount_pos == o.unreconciled_amount_pos &&
219
+ unreconciled_amount_neg == o.unreconciled_amount_neg &&
220
+ unreconciled_lines == o.unreconciled_lines &&
221
+ avg_days_unreconciled_pos == o.avg_days_unreconciled_pos &&
222
+ avg_days_unreconciled_neg == o.avg_days_unreconciled_neg &&
223
+ earliest_unreconciled_transaction == o.earliest_unreconciled_transaction &&
224
+ latest_unreconciled_transaction == o.latest_unreconciled_transaction &&
225
+ deleted_amount == o.deleted_amount &&
226
+ total_amount == o.total_amount &&
227
+ data_source == o.data_source &&
228
+ earliest_reconciled_transaction == o.earliest_reconciled_transaction &&
229
+ latest_reconciled_transaction == o.latest_reconciled_transaction &&
230
+ reconciled_amount_pos == o.reconciled_amount_pos &&
231
+ reconciled_amount_neg == o.reconciled_amount_neg &&
232
+ reconciled_lines == o.reconciled_lines &&
233
+ total_amount_pos == o.total_amount_pos &&
234
+ total_amount_neg == o.total_amount_neg
235
+ end
236
+
237
+ # @see the `==` method
238
+ # @param [Object] Object to be compared
239
+ def eql?(o)
240
+ self == o
241
+ end
242
+
243
+ # Calculates hash code according to all attributes.
244
+ # @return [Integer] Hash code
245
+ def hash
246
+ [unreconciled_amount_pos, unreconciled_amount_neg, unreconciled_lines, avg_days_unreconciled_pos, avg_days_unreconciled_neg, earliest_unreconciled_transaction, latest_unreconciled_transaction, deleted_amount, total_amount, data_source, earliest_reconciled_transaction, latest_reconciled_transaction, reconciled_amount_pos, reconciled_amount_neg, reconciled_lines, total_amount_pos, total_amount_neg].hash
247
+ end
248
+
249
+ # Builds the object from hash
250
+ # @param [Hash] attributes Model attributes in the form of hash
251
+ # @return [Object] Returns the model itself
252
+ def self.build_from_hash(attributes)
253
+ new.build_from_hash(attributes)
254
+ end
255
+
256
+ # Builds the object from hash
257
+ # @param [Hash] attributes Model attributes in the form of hash
258
+ # @return [Object] Returns the model itself
259
+ def build_from_hash(attributes)
260
+ return nil unless attributes.is_a?(Hash)
261
+ self.class.openapi_types.each_pair do |key, type|
262
+ if type =~ /\AArray<(.*)>/i
263
+ # check to ensure the input is an array given that the attribute
264
+ # is documented as an array but the input is not
265
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
266
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
267
+ end
268
+ elsif !attributes[self.class.attribute_map[key]].nil?
269
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
270
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
271
+ end
272
+
273
+ self
274
+ end
275
+
276
+ # Deserializes the data based on type
277
+ # @param string type Data type
278
+ # @param string value Value to be deserialized
279
+ # @return [Object] Deserialized data
280
+ def _deserialize(type, value)
281
+ case type.to_sym
282
+ when :DateTime
283
+ DateTime.parse(parse_date(value))
284
+ when :Date
285
+ Date.parse(parse_date(value))
286
+ when :String
287
+ value.to_s
288
+ when :Integer
289
+ value.to_i
290
+ when :Float
291
+ value.to_f
292
+ when :BigDecimal
293
+ BigDecimal(value.to_s)
294
+ when :Boolean
295
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
296
+ true
297
+ else
298
+ false
299
+ end
300
+ when :Object
301
+ # generic object (usually a Hash), return directly
302
+ value
303
+ when /\AArray<(?<inner_type>.+)>\z/
304
+ inner_type = Regexp.last_match[:inner_type]
305
+ value.map { |v| _deserialize(inner_type, v) }
306
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
307
+ k_type = Regexp.last_match[:k_type]
308
+ v_type = Regexp.last_match[:v_type]
309
+ {}.tap do |hash|
310
+ value.each do |k, v|
311
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
312
+ end
313
+ end
314
+ else # model
315
+ XeroRuby::Finance.const_get(type).build_from_hash(value)
316
+ end
317
+ end
318
+
319
+ # Returns the string representation of the object
320
+ # @return [String] String presentation of the object
321
+ def to_s
322
+ to_hash.to_s
323
+ end
324
+
325
+ # to_body is an alias to to_hash (backward compatibility)
326
+ # @return [Hash] Returns the object in the form of hash
327
+ def to_body
328
+ to_hash
329
+ end
330
+
331
+ # Returns the object in the form of hash
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_hash(downcase: false)
334
+ hash = {}
335
+ self.class.attribute_map.each_pair do |attr, param|
336
+ value = self.send(attr)
337
+ next if value.nil?
338
+ key = downcase ? attr : param
339
+ hash[key] = _to_hash(value, downcase: downcase)
340
+ end
341
+ hash
342
+ end
343
+
344
+ # Returns the object in the form of hash with snake_case
345
+ def to_attributes
346
+ to_hash(downcase: true)
347
+ end
348
+
349
+ # Outputs non-array value in the form of hash
350
+ # For object, use to_hash. Otherwise, just return the value
351
+ # @param [Object] value Any valid value
352
+ # @return [Hash] Returns the value in the form of hash
353
+ def _to_hash(value, downcase: false)
354
+ if value.is_a?(Array)
355
+ value.map do |v|
356
+ v.to_hash(downcase: downcase)
357
+ end
358
+ elsif value.is_a?(Hash)
359
+ {}.tap do |hash|
360
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
361
+ end
362
+ elsif value.respond_to? :to_hash
363
+ value.to_hash(downcase: downcase)
364
+ else
365
+ value
366
+ end
367
+ end
368
+
369
+ def parse_date(datestring)
370
+ if datestring.include?('Date')
371
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
372
+ original, date, timezone = *date_pattern.match(datestring)
373
+ date = (date.to_i / 1000)
374
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
375
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
376
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
377
+ else # handle date 'types' for small subset of payroll API's
378
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
379
+ end
380
+ end
381
+ end
382
+ end