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,244 @@
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 UserActivitiesResponse
19
+ # The requested Organisation to which the data pertains
20
+ attr_accessor :organisation_id
21
+
22
+ # The month of the report
23
+ attr_accessor :data_month
24
+
25
+
26
+ attr_accessor :users
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'organisation_id' => :'organisationId',
32
+ :'data_month' => :'dataMonth',
33
+ :'users' => :'users'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'organisation_id' => :'String',
41
+ :'data_month' => :'String',
42
+ :'users' => :'Array<UserResponse>'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::UserActivitiesResponse` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::UserActivitiesResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'organisation_id')
62
+ self.organisation_id = attributes[:'organisation_id']
63
+ end
64
+
65
+ if attributes.key?(:'data_month')
66
+ self.data_month = attributes[:'data_month']
67
+ end
68
+
69
+ if attributes.key?(:'users')
70
+ if (value = attributes[:'users']).is_a?(Array)
71
+ self.users = value
72
+ end
73
+ end
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properties with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ organisation_id == o.organisation_id &&
95
+ data_month == o.data_month &&
96
+ users == o.users
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [organisation_id, data_month, users].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ new.build_from_hash(attributes)
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.openapi_types.each_pair do |key, type|
124
+ if type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
129
+ end
130
+ elsif !attributes[self.class.attribute_map[key]].nil?
131
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
133
+ end
134
+
135
+ self
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :DateTime
145
+ DateTime.parse(parse_date(value))
146
+ when :Date
147
+ Date.parse(parse_date(value))
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :BigDecimal
155
+ BigDecimal(value.to_s)
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ XeroRuby::Finance.const_get(type).build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash(downcase: false)
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ next if value.nil?
200
+ key = downcase ? attr : param
201
+ hash[key] = _to_hash(value, downcase: downcase)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Returns the object in the form of hash with snake_case
207
+ def to_attributes
208
+ to_hash(downcase: true)
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value, downcase: false)
216
+ if value.is_a?(Array)
217
+ value.map do |v|
218
+ v.to_hash(downcase: downcase)
219
+ end
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash(downcase: downcase)
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ def parse_date(datestring)
232
+ if datestring.include?('Date')
233
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
234
+ original, date, timezone = *date_pattern.match(datestring)
235
+ date = (date.to_i / 1000)
236
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
237
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
238
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
239
+ else # handle date 'types' for small subset of payroll API's
240
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
241
+ end
242
+ end
243
+ end
244
+ end
@@ -0,0 +1,336 @@
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 UserResponse
19
+ # The Xero identifier for the user
20
+ attr_accessor :user_id
21
+
22
+ # Timestamp of user creation.
23
+ attr_accessor :user_created_date_utc
24
+
25
+ # Timestamp of user last login
26
+ attr_accessor :last_login_date_utc
27
+
28
+ # User is external partner.
29
+ attr_accessor :is_external_partner
30
+
31
+ # User has Accountant role.
32
+ attr_accessor :has_accountant_role
33
+
34
+ # Month period in format yyyy-MM.
35
+ attr_accessor :month_period
36
+
37
+ # Number of times the user has logged in.
38
+ attr_accessor :number_of_logins
39
+
40
+ # Number of documents created.
41
+ attr_accessor :number_of_documents_created
42
+
43
+ # Net value of documents created.
44
+ attr_accessor :net_value_documents_created
45
+
46
+ # Absolute value of documents created.
47
+ attr_accessor :absolute_value_documents_created
48
+
49
+
50
+ attr_accessor :attached_practices
51
+
52
+
53
+ attr_accessor :history_records
54
+
55
+ # Attribute mapping from ruby-style variable name to JSON key.
56
+ def self.attribute_map
57
+ {
58
+ :'user_id' => :'userId',
59
+ :'user_created_date_utc' => :'userCreatedDateUtc',
60
+ :'last_login_date_utc' => :'lastLoginDateUtc',
61
+ :'is_external_partner' => :'isExternalPartner',
62
+ :'has_accountant_role' => :'hasAccountantRole',
63
+ :'month_period' => :'monthPeriod',
64
+ :'number_of_logins' => :'numberOfLogins',
65
+ :'number_of_documents_created' => :'numberOfDocumentsCreated',
66
+ :'net_value_documents_created' => :'netValueDocumentsCreated',
67
+ :'absolute_value_documents_created' => :'absoluteValueDocumentsCreated',
68
+ :'attached_practices' => :'attachedPractices',
69
+ :'history_records' => :'historyRecords'
70
+ }
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.openapi_types
75
+ {
76
+ :'user_id' => :'String',
77
+ :'user_created_date_utc' => :'DateTime',
78
+ :'last_login_date_utc' => :'DateTime',
79
+ :'is_external_partner' => :'Boolean',
80
+ :'has_accountant_role' => :'Boolean',
81
+ :'month_period' => :'String',
82
+ :'number_of_logins' => :'Integer',
83
+ :'number_of_documents_created' => :'Integer',
84
+ :'net_value_documents_created' => :'BigDecimal',
85
+ :'absolute_value_documents_created' => :'BigDecimal',
86
+ :'attached_practices' => :'Array<PracticeResponse>',
87
+ :'history_records' => :'Array<HistoryRecordResponse>'
88
+ }
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::UserResponse` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::UserResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'user_id')
107
+ self.user_id = attributes[:'user_id']
108
+ end
109
+
110
+ if attributes.key?(:'user_created_date_utc')
111
+ self.user_created_date_utc = attributes[:'user_created_date_utc']
112
+ end
113
+
114
+ if attributes.key?(:'last_login_date_utc')
115
+ self.last_login_date_utc = attributes[:'last_login_date_utc']
116
+ end
117
+
118
+ if attributes.key?(:'is_external_partner')
119
+ self.is_external_partner = attributes[:'is_external_partner']
120
+ end
121
+
122
+ if attributes.key?(:'has_accountant_role')
123
+ self.has_accountant_role = attributes[:'has_accountant_role']
124
+ end
125
+
126
+ if attributes.key?(:'month_period')
127
+ self.month_period = attributes[:'month_period']
128
+ end
129
+
130
+ if attributes.key?(:'number_of_logins')
131
+ self.number_of_logins = attributes[:'number_of_logins']
132
+ end
133
+
134
+ if attributes.key?(:'number_of_documents_created')
135
+ self.number_of_documents_created = attributes[:'number_of_documents_created']
136
+ end
137
+
138
+ if attributes.key?(:'net_value_documents_created')
139
+ self.net_value_documents_created = attributes[:'net_value_documents_created']
140
+ end
141
+
142
+ if attributes.key?(:'absolute_value_documents_created')
143
+ self.absolute_value_documents_created = attributes[:'absolute_value_documents_created']
144
+ end
145
+
146
+ if attributes.key?(:'attached_practices')
147
+ if (value = attributes[:'attached_practices']).is_a?(Array)
148
+ self.attached_practices = value
149
+ end
150
+ end
151
+
152
+ if attributes.key?(:'history_records')
153
+ if (value = attributes[:'history_records']).is_a?(Array)
154
+ self.history_records = value
155
+ end
156
+ end
157
+ end
158
+
159
+ # Show invalid properties with the reasons. Usually used together with valid?
160
+ # @return Array for valid properties with the reasons
161
+ def list_invalid_properties
162
+ invalid_properties = Array.new
163
+ invalid_properties
164
+ end
165
+
166
+ # Check to see if the all the properties in the model are valid
167
+ # @return true if the model is valid
168
+ def valid?
169
+ true
170
+ end
171
+
172
+ # Checks equality by comparing each attribute.
173
+ # @param [Object] Object to be compared
174
+ def ==(o)
175
+ return true if self.equal?(o)
176
+ self.class == o.class &&
177
+ user_id == o.user_id &&
178
+ user_created_date_utc == o.user_created_date_utc &&
179
+ last_login_date_utc == o.last_login_date_utc &&
180
+ is_external_partner == o.is_external_partner &&
181
+ has_accountant_role == o.has_accountant_role &&
182
+ month_period == o.month_period &&
183
+ number_of_logins == o.number_of_logins &&
184
+ number_of_documents_created == o.number_of_documents_created &&
185
+ net_value_documents_created == o.net_value_documents_created &&
186
+ absolute_value_documents_created == o.absolute_value_documents_created &&
187
+ attached_practices == o.attached_practices &&
188
+ history_records == o.history_records
189
+ end
190
+
191
+ # @see the `==` method
192
+ # @param [Object] Object to be compared
193
+ def eql?(o)
194
+ self == o
195
+ end
196
+
197
+ # Calculates hash code according to all attributes.
198
+ # @return [Integer] Hash code
199
+ def hash
200
+ [user_id, user_created_date_utc, last_login_date_utc, is_external_partner, has_accountant_role, month_period, number_of_logins, number_of_documents_created, net_value_documents_created, absolute_value_documents_created, attached_practices, history_records].hash
201
+ end
202
+
203
+ # Builds the object from hash
204
+ # @param [Hash] attributes Model attributes in the form of hash
205
+ # @return [Object] Returns the model itself
206
+ def self.build_from_hash(attributes)
207
+ new.build_from_hash(attributes)
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ self.class.openapi_types.each_pair do |key, type|
216
+ if type =~ /\AArray<(.*)>/i
217
+ # check to ensure the input is an array given that the attribute
218
+ # is documented as an array but the input is not
219
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
220
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
221
+ end
222
+ elsif !attributes[self.class.attribute_map[key]].nil?
223
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
224
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
225
+ end
226
+
227
+ self
228
+ end
229
+
230
+ # Deserializes the data based on type
231
+ # @param string type Data type
232
+ # @param string value Value to be deserialized
233
+ # @return [Object] Deserialized data
234
+ def _deserialize(type, value)
235
+ case type.to_sym
236
+ when :DateTime
237
+ DateTime.parse(parse_date(value))
238
+ when :Date
239
+ Date.parse(parse_date(value))
240
+ when :String
241
+ value.to_s
242
+ when :Integer
243
+ value.to_i
244
+ when :Float
245
+ value.to_f
246
+ when :BigDecimal
247
+ BigDecimal(value.to_s)
248
+ when :Boolean
249
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
250
+ true
251
+ else
252
+ false
253
+ end
254
+ when :Object
255
+ # generic object (usually a Hash), return directly
256
+ value
257
+ when /\AArray<(?<inner_type>.+)>\z/
258
+ inner_type = Regexp.last_match[:inner_type]
259
+ value.map { |v| _deserialize(inner_type, v) }
260
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
261
+ k_type = Regexp.last_match[:k_type]
262
+ v_type = Regexp.last_match[:v_type]
263
+ {}.tap do |hash|
264
+ value.each do |k, v|
265
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
266
+ end
267
+ end
268
+ else # model
269
+ XeroRuby::Finance.const_get(type).build_from_hash(value)
270
+ end
271
+ end
272
+
273
+ # Returns the string representation of the object
274
+ # @return [String] String presentation of the object
275
+ def to_s
276
+ to_hash.to_s
277
+ end
278
+
279
+ # to_body is an alias to to_hash (backward compatibility)
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_body
282
+ to_hash
283
+ end
284
+
285
+ # Returns the object in the form of hash
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_hash(downcase: false)
288
+ hash = {}
289
+ self.class.attribute_map.each_pair do |attr, param|
290
+ value = self.send(attr)
291
+ next if value.nil?
292
+ key = downcase ? attr : param
293
+ hash[key] = _to_hash(value, downcase: downcase)
294
+ end
295
+ hash
296
+ end
297
+
298
+ # Returns the object in the form of hash with snake_case
299
+ def to_attributes
300
+ to_hash(downcase: true)
301
+ end
302
+
303
+ # Outputs non-array value in the form of hash
304
+ # For object, use to_hash. Otherwise, just return the value
305
+ # @param [Object] value Any valid value
306
+ # @return [Hash] Returns the value in the form of hash
307
+ def _to_hash(value, downcase: false)
308
+ if value.is_a?(Array)
309
+ value.map do |v|
310
+ v.to_hash(downcase: downcase)
311
+ end
312
+ elsif value.is_a?(Hash)
313
+ {}.tap do |hash|
314
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
315
+ end
316
+ elsif value.respond_to? :to_hash
317
+ value.to_hash(downcase: downcase)
318
+ else
319
+ value
320
+ end
321
+ end
322
+
323
+ def parse_date(datestring)
324
+ if datestring.include?('Date')
325
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
326
+ original, date, timezone = *date_pattern.match(datestring)
327
+ date = (date.to_i / 1000)
328
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
329
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
330
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
331
+ else # handle date 'types' for small subset of payroll API's
332
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
333
+ end
334
+ end
335
+ end
336
+ end
@@ -3,13 +3,13 @@
3
3
 
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
- Contact: api@xero.com
7
- Generated by: https://openapi-generator.tech
8
- OpenAPI Generator version: 4.3.1
6
+ # Contact: api@xero.com
7
+ # Generated by: https://openapi-generator.tech
8
+ # OpenAPI Generator version: 4.3.1
9
9
 
10
- The version of the XeroOpenAPI document: 2.17.1
10
+ # The version of the XeroOpenAPI document: 2.17.2
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '3.4.0'
15
- end
14
+ VERSION = '3.5.0'
15
+ end
data/lib/xero-ruby.rb CHANGED
@@ -18,6 +18,49 @@ require 'xero-ruby/version'
18
18
  require 'xero-ruby/configuration'
19
19
 
20
20
  # Models
21
+ require 'xero-ruby/models/finance/account_usage'
22
+ require 'xero-ruby/models/finance/account_usage_response'
23
+ require 'xero-ruby/models/finance/balance_sheet_account_detail'
24
+ require 'xero-ruby/models/finance/balance_sheet_account_group'
25
+ require 'xero-ruby/models/finance/balance_sheet_account_type'
26
+ require 'xero-ruby/models/finance/balance_sheet_response'
27
+ require 'xero-ruby/models/finance/bank_statement_response'
28
+ require 'xero-ruby/models/finance/cash_account_response'
29
+ require 'xero-ruby/models/finance/cash_balance'
30
+ require 'xero-ruby/models/finance/cash_validation_response'
31
+ require 'xero-ruby/models/finance/cashflow_account'
32
+ require 'xero-ruby/models/finance/cashflow_activity'
33
+ require 'xero-ruby/models/finance/cashflow_response'
34
+ require 'xero-ruby/models/finance/cashflow_type'
35
+ require 'xero-ruby/models/finance/contact_detail'
36
+ require 'xero-ruby/models/finance/contact_total_detail'
37
+ require 'xero-ruby/models/finance/contact_total_other'
38
+ require 'xero-ruby/models/finance/current_statement_response'
39
+ require 'xero-ruby/models/finance/data_source_response'
40
+ require 'xero-ruby/models/finance/history_record_response'
41
+ require 'xero-ruby/models/finance/income_by_contact_response'
42
+ require 'xero-ruby/models/finance/lock_history_model'
43
+ require 'xero-ruby/models/finance/lock_history_response'
44
+ require 'xero-ruby/models/finance/manual_journal_total'
45
+ require 'xero-ruby/models/finance/pnl_account'
46
+ require 'xero-ruby/models/finance/pnl_account_class'
47
+ require 'xero-ruby/models/finance/pnl_account_type'
48
+ require 'xero-ruby/models/finance/practice_response'
49
+ require 'xero-ruby/models/finance/problem'
50
+ require 'xero-ruby/models/finance/problem_type'
51
+ require 'xero-ruby/models/finance/profit_and_loss_response'
52
+ require 'xero-ruby/models/finance/report_history_model'
53
+ require 'xero-ruby/models/finance/report_history_response'
54
+ require 'xero-ruby/models/finance/statement_balance_response'
55
+ require 'xero-ruby/models/finance/statement_lines_response'
56
+ require 'xero-ruby/models/finance/total_detail'
57
+ require 'xero-ruby/models/finance/total_other'
58
+ require 'xero-ruby/models/finance/trial_balance_account'
59
+ require 'xero-ruby/models/finance/trial_balance_entry'
60
+ require 'xero-ruby/models/finance/trial_balance_movement'
61
+ require 'xero-ruby/models/finance/trial_balance_response'
62
+ require 'xero-ruby/models/finance/user_activities_response'
63
+ require 'xero-ruby/models/finance/user_response'
21
64
  require 'xero-ruby/models/app_store/plan'
22
65
  require 'xero-ruby/models/app_store/price'
23
66
  require 'xero-ruby/models/app_store/problem_details'
@@ -462,6 +505,7 @@ require 'xero-ruby/models/accounting/users'
462
505
  require 'xero-ruby/models/accounting/validation_error'
463
506
 
464
507
  # APIs
508
+ require 'xero-ruby/api/finance_api'
465
509
  require 'xero-ruby/api/app_store_api'
466
510
  require 'xero-ruby/api/payroll_uk_api'
467
511
  require 'xero-ruby/api/payroll_nz_api'
@@ -174,6 +174,9 @@ describe XeroRuby::ApiClient do
174
174
 
175
175
  api_client.payroll_uk_api
176
176
  expect(api_client.config.base_url).to eq('https://api.xero.com/payroll.xro/2.0/')
177
+
178
+ api_client.finance_api
179
+ expect(api_client.config.base_url).to eq('https://api.xero.com/finance.xro/1.0/')
177
180
 
178
181
  api_client.connections
179
182
  expect(api_client.config.base_url).to eq('https://api.xero.com')
@@ -12,7 +12,7 @@ OpenAPI Generator version: 4.3.1
12
12
  require 'spec_helper'
13
13
  require 'json'
14
14
 
15
- # Unit tests for XeroRuby::AppStore::AppStoreApi
15
+ # Unit tests for XeroRuby::AppStoreApi
16
16
  # Automatically generated by openapi-generator (https://openapi-generator.tech)
17
17
  # Please update as you see appropriate
18
18
  describe 'AppStoreApi' do
@@ -14,6 +14,7 @@ describe XeroRuby::Configuration do
14
14
  expect(config.payroll_au_url).to eq('https://api.xero.com/payroll.xro/1.0/')
15
15
  expect(config.payroll_nz_url).to eq('https://api.xero.com/payroll.xro/2.0/')
16
16
  expect(config.payroll_uk_url).to eq('https://api.xero.com/payroll.xro/2.0/')
17
+ expect(config.finance_url).to eq('https://api.xero.com/finance.xro/1.0/')
17
18
  end
18
19
  end
19
20