xero-ruby 18.4.0 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/feed_connections_api.rb +410 -0
  3. data/lib/xero-ruby/api_client.rb +42 -24
  4. data/lib/xero-ruby/configuration.rb +10 -6
  5. data/lib/xero-ruby/models/accounting/budget.rb +25 -1
  6. data/lib/xero-ruby/models/accounting/budget_balance.rb +4 -39
  7. data/lib/xero-ruby/models/bankfeeds_v2/account_type.rb +36 -0
  8. data/lib/xero-ruby/models/{finance/lock_history_response.rb → bankfeeds_v2/bulk_feed_connection_response.rb} +16 -35
  9. data/lib/xero-ruby/models/bankfeeds_v2/bulk_feed_connection_result.rb +300 -0
  10. data/lib/xero-ruby/models/bankfeeds_v2/delete_feed_connections_request.rb +229 -0
  11. data/lib/xero-ruby/models/bankfeeds_v2/existing_account_feed_connection.rb +373 -0
  12. data/lib/xero-ruby/models/bankfeeds_v2/existing_account_feed_connections_request.rb +229 -0
  13. data/lib/xero-ruby/models/{finance/account_usage.rb → bankfeeds_v2/feed_connection.rb} +59 -108
  14. data/lib/xero-ruby/models/{finance/account_usage_response.rb → bankfeeds_v2/feed_connection_to_delete.rb} +20 -47
  15. data/lib/xero-ruby/models/bankfeeds_v2/item_error.rb +358 -0
  16. data/lib/xero-ruby/models/bankfeeds_v2/new_account_feed_connection.rb +406 -0
  17. data/lib/xero-ruby/models/{finance/user_activities_response.rb → bankfeeds_v2/new_account_feed_connections_request.rb} +21 -36
  18. data/lib/xero-ruby/models/{finance/report_history_response.rb → bankfeeds_v2/paged_feed_connections.rb} +22 -32
  19. data/lib/xero-ruby/models/{finance/practice_response.rb → bankfeeds_v2/pagination.rb} +36 -46
  20. data/lib/xero-ruby/models/bankfeeds_v2/problem.rb +368 -0
  21. data/lib/xero-ruby/version.rb +2 -2
  22. data/lib/xero-ruby.rb +143 -128
  23. metadata +369 -364
  24. data/lib/xero-ruby/models/finance/history_record_response.rb +0 -262
  25. data/lib/xero-ruby/models/finance/lock_history_model.rb +0 -242
  26. data/lib/xero-ruby/models/finance/report_history_model.rb +0 -242
  27. data/lib/xero-ruby/models/finance/user_response.rb +0 -336
@@ -1,7 +1,7 @@
1
1
  =begin
2
- #Xero Finance API
2
+ #Xero Bank Feeds API v2
3
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.
4
+ #The Bank Feeds API is available to financial institutions with a Xero partnership and approved app partners. For non-bank apps, it automates statement imports into Xero bank and credit card accounts; it does not create a direct bank feed. Feed Connections 2.0 is intended to replace 1.0. The customer chooses whether to connect an existing Xero account or create a new one. Use ExistingAccount with the chosen accountId, or NewAccount to create an account; Xero does not guess which account to connect or silently change an account name. The GET and delete operations also use 2.0. Statements continue to use 1.0. Partial failures are rare, and nearly all are recoverable by your app with no need to contact Xero support. If an item in a write response has `status` `PARTIAL_FAILURE`, handle only that item and read its `error.type`. For `partial-failure-new-account-creation`, do not resend the NewAccount item: connect `error.accountId` with `POST /FeedConnections/ExistingAccount`. For `partial-failure-new-account-existence-not-confirmed`, the account named in `error.accountName` may or may not exist. Use the Accounting API to check whether an account with that name exists. If it does, connect it with `POST /FeedConnections/ExistingAccount`. If it does not, resend the NewAccount item. If your app has a user, you can show them this message instead: \"Something went wrong. Please check whether your chosen account name now exists. If it does, connect it. If not, try creating the new one again.\" For any other `partial-failure-*` type, resend the same item. If the recovery request for `partial-failure-new-account-creation`, `partial-failure-previous-connection-deletion` or `partial-failure-connection-creation` returns 409 `feed-already-connected-in-current-organisation`, the earlier attempt succeeded: treat the item as created and use `GET /FeedConnections` to find its `id`. `error.subtype` is optional diagnostics; do not branch on it, and never parse `title` or `detail`. Full detail: https://developer.xero.com/documentation/api/bankfeeds/feedconnections-2-0-errors/#partial-failures
5
5
 
6
6
  Contact: api@xero.com
7
7
  Generated by: https://openapi-generator.tech
@@ -12,44 +12,39 @@ OpenAPI Generator version: 4.3.1
12
12
  require 'time'
13
13
  require 'date'
14
14
 
15
- module XeroRuby::Finance
15
+ module XeroRuby::BankfeedsV2
16
16
  require 'bigdecimal'
17
17
 
18
- class PracticeResponse
19
- # Year of becoming a partner.
20
- attr_accessor :xero_partner_since
18
+ class Pagination
19
+ # The page returned, echoing the request.
20
+ attr_accessor :page
21
21
 
22
- # Customer tier e.g. Silver
23
- attr_accessor :tier
22
+ # How many pages the collection spans in total.
23
+ attr_accessor :page_count
24
24
 
25
- # Country of location.
26
- attr_accessor :location
25
+ # The page size used, echoing the request.
26
+ attr_accessor :page_size
27
27
 
28
- # Organisation count.
29
- attr_accessor :organisation_count
30
-
31
- # Staff certified (true/false).
32
- attr_accessor :staff_certified
28
+ # How many Feed Connections are on this page. This is not the size of the whole collection, which is not returned.
29
+ attr_accessor :item_count
33
30
 
34
31
  # Attribute mapping from ruby-style variable name to JSON key.
35
32
  def self.attribute_map
36
33
  {
37
- :'xero_partner_since' => :'xeroPartnerSince',
38
- :'tier' => :'tier',
39
- :'location' => :'location',
40
- :'organisation_count' => :'organisationCount',
41
- :'staff_certified' => :'staffCertified'
34
+ :'page' => :'page',
35
+ :'page_count' => :'pageCount',
36
+ :'page_size' => :'pageSize',
37
+ :'item_count' => :'itemCount'
42
38
  }
43
39
  end
44
40
 
45
41
  # Attribute type mapping.
46
42
  def self.openapi_types
47
43
  {
48
- :'xero_partner_since' => :'Integer',
49
- :'tier' => :'String',
50
- :'location' => :'String',
51
- :'organisation_count' => :'Integer',
52
- :'staff_certified' => :'Boolean'
44
+ :'page' => :'Integer',
45
+ :'page_count' => :'Integer',
46
+ :'page_size' => :'Integer',
47
+ :'item_count' => :'Integer'
53
48
  }
54
49
  end
55
50
 
@@ -57,35 +52,31 @@ module XeroRuby::Finance
57
52
  # @param [Hash] attributes Model attributes in the form of hash
58
53
  def initialize(attributes = {})
59
54
  if (!attributes.is_a?(Hash))
60
- fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::Finance::PracticeResponse` initialize method"
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::BankfeedsV2::Pagination` initialize method"
61
56
  end
62
57
 
63
58
  # check to see if the attribute exists and convert string to symbol for hash key
64
59
  attributes = attributes.each_with_object({}) { |(k, v), h|
65
60
  if (!self.class.attribute_map.key?(k.to_sym))
66
- fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::Finance::PracticeResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::BankfeedsV2::Pagination`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
62
  end
68
63
  h[k.to_sym] = v
69
64
  }
70
65
 
71
- if attributes.key?(:'xero_partner_since')
72
- self.xero_partner_since = attributes[:'xero_partner_since']
73
- end
74
-
75
- if attributes.key?(:'tier')
76
- self.tier = attributes[:'tier']
66
+ if attributes.key?(:'page')
67
+ self.page = attributes[:'page']
77
68
  end
78
69
 
79
- if attributes.key?(:'location')
80
- self.location = attributes[:'location']
70
+ if attributes.key?(:'page_count')
71
+ self.page_count = attributes[:'page_count']
81
72
  end
82
73
 
83
- if attributes.key?(:'organisation_count')
84
- self.organisation_count = attributes[:'organisation_count']
74
+ if attributes.key?(:'page_size')
75
+ self.page_size = attributes[:'page_size']
85
76
  end
86
77
 
87
- if attributes.key?(:'staff_certified')
88
- self.staff_certified = attributes[:'staff_certified']
78
+ if attributes.key?(:'item_count')
79
+ self.item_count = attributes[:'item_count']
89
80
  end
90
81
  end
91
82
 
@@ -107,11 +98,10 @@ module XeroRuby::Finance
107
98
  def ==(o)
108
99
  return true if self.equal?(o)
109
100
  self.class == o.class &&
110
- xero_partner_since == o.xero_partner_since &&
111
- tier == o.tier &&
112
- location == o.location &&
113
- organisation_count == o.organisation_count &&
114
- staff_certified == o.staff_certified
101
+ page == o.page &&
102
+ page_count == o.page_count &&
103
+ page_size == o.page_size &&
104
+ item_count == o.item_count
115
105
  end
116
106
 
117
107
  # @see the `==` method
@@ -123,7 +113,7 @@ module XeroRuby::Finance
123
113
  # Calculates hash code according to all attributes.
124
114
  # @return [Integer] Hash code
125
115
  def hash
126
- [xero_partner_since, tier, location, organisation_count, staff_certified].hash
116
+ [page, page_count, page_size, item_count].hash
127
117
  end
128
118
 
129
119
  # Builds the object from hash
@@ -192,7 +182,7 @@ module XeroRuby::Finance
192
182
  end
193
183
  end
194
184
  else # model
195
- XeroRuby::Finance.const_get(type).build_from_hash(value)
185
+ XeroRuby::BankfeedsV2.const_get(type).build_from_hash(value)
196
186
  end
197
187
  end
198
188
 
@@ -0,0 +1,368 @@
1
+ =begin
2
+ #Xero Bank Feeds API v2
3
+
4
+ #The Bank Feeds API is available to financial institutions with a Xero partnership and approved app partners. For non-bank apps, it automates statement imports into Xero bank and credit card accounts; it does not create a direct bank feed. Feed Connections 2.0 is intended to replace 1.0. The customer chooses whether to connect an existing Xero account or create a new one. Use ExistingAccount with the chosen accountId, or NewAccount to create an account; Xero does not guess which account to connect or silently change an account name. The GET and delete operations also use 2.0. Statements continue to use 1.0. Partial failures are rare, and nearly all are recoverable by your app with no need to contact Xero support. If an item in a write response has `status` `PARTIAL_FAILURE`, handle only that item and read its `error.type`. For `partial-failure-new-account-creation`, do not resend the NewAccount item: connect `error.accountId` with `POST /FeedConnections/ExistingAccount`. For `partial-failure-new-account-existence-not-confirmed`, the account named in `error.accountName` may or may not exist. Use the Accounting API to check whether an account with that name exists. If it does, connect it with `POST /FeedConnections/ExistingAccount`. If it does not, resend the NewAccount item. If your app has a user, you can show them this message instead: \"Something went wrong. Please check whether your chosen account name now exists. If it does, connect it. If not, try creating the new one again.\" For any other `partial-failure-*` type, resend the same item. If the recovery request for `partial-failure-new-account-creation`, `partial-failure-previous-connection-deletion` or `partial-failure-connection-creation` returns 409 `feed-already-connected-in-current-organisation`, the earlier attempt succeeded: treat the item as created and use `GET /FeedConnections` to find its `id`. `error.subtype` is optional diagnostics; do not branch on it, and never parse `title` or `detail`. Full detail: https://developer.xero.com/documentation/api/bankfeeds/feedconnections-2-0-errors/#partial-failures
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::BankfeedsV2
16
+ # An error. Served as `application/problem+json` when it describes the request as a whole. The `error` of an item result is an `ItemError`, which has the same fields except `status`.
17
+ require 'bigdecimal'
18
+
19
+ class Problem
20
+ # Identifies the error.
21
+ attr_accessor :type
22
+ INVALID_REQUEST ||= "invalid-request".freeze
23
+ INVALID_APPLICATION ||= "invalid-application".freeze
24
+ SUSPENDED_OR_TERMINATED_APPLICATION ||= "suspended-or-terminated-application".freeze
25
+ INVALID_ORGANISATION_BANK_FEEDS ||= "invalid-organisation-bank-feeds".freeze
26
+ INVALID_ORGANISATION_MULTI_CURRENCY ||= "invalid-organisation-multi-currency".freeze
27
+ INVALID_FEED_CONNECTION_FOR_ORGANISATION ||= "invalid-feed-connection-for-organisation".freeze
28
+ INVALID_USER_ROLE ||= "invalid-user-role".freeze
29
+ INVALID_ACCOUNT_TOKEN ||= "invalid-account-token".freeze
30
+ MISSING_IDENTIFYING_FIELDS ||= "missing-identifying-fields".freeze
31
+ INVALID_COUNTRY_SPECIFIED ||= "invalid-country-specified".freeze
32
+ ACCOUNT_NOT_VALID ||= "account-not-valid".freeze
33
+ FEED_ALREADY_CONNECTED_IN_CURRENT_ORGANISATION ||= "feed-already-connected-in-current-organisation".freeze
34
+ ACCOUNT_NAME_ALREADY_EXISTS ||= "account-name-already-exists".freeze
35
+ BANK_FEED_NOT_FOUND ||= "bank-feed-not-found".freeze
36
+ FEED_NOT_FOUND_OR_ALREADY_DELETED ||= "feed-not-found-or-already-deleted".freeze
37
+ PARTIAL_FAILURE_NEW_ACCOUNT_CREATION ||= "partial-failure-new-account-creation".freeze
38
+ PARTIAL_FAILURE_PREVIOUS_CONNECTION_DELETION ||= "partial-failure-previous-connection-deletion".freeze
39
+ PARTIAL_FAILURE_CONNECTION_CREATION ||= "partial-failure-connection-creation".freeze
40
+ PARTIAL_FAILURE_CONNECTION_DELETION ||= "partial-failure-connection-deletion".freeze
41
+ PARTIAL_FAILURE_NEW_ACCOUNT_EXISTENCE_NOT_CONFIRMED ||= "partial-failure-new-account-existence-not-confirmed".freeze
42
+ TOO_MANY_REQUESTS ||= "too-many-requests".freeze
43
+ INTERNAL_ERROR ||= "internal-error".freeze
44
+
45
+ # Present only on a partial failure (a `partial-failure-*` `type`). Names the exact cause within the `type`. Reading it is optional: the `type` alone fixes the recovery action and which identifier fields are present, so branch on `type` and use `subtype` for diagnostics.
46
+ attr_accessor :subtype
47
+ CONNECTION_PHASE_FAILED ||= "connection-phase-failed".freeze
48
+ DELETION_PHASE_FAILED ||= "deletion-phase-failed".freeze
49
+ DELETION_PHASE_NOT_CONFIRMED ||= "deletion-phase-not-confirmed".freeze
50
+ CONNECTION_EXISTENCE_NOT_CONFIRMED ||= "connection-existence-not-confirmed".freeze
51
+ CONNECTION_EXISTS_WITHOUT_FEED_CONNECTION ||= "connection-exists-without-feed-connection".freeze
52
+ FEED_CONNECTION_EXISTENCE_NOT_CONFIRMED_CAN_CHECK_OR_RETRY ||= "feed-connection-existence-not-confirmed-can-check-or-retry".freeze
53
+ CHECK_ACCOUNTS_OR_PROMPT_USER_RETRY ||= "check-accounts-or-prompt-user-retry".freeze
54
+
55
+ # A short human-readable summary of the error.
56
+ attr_accessor :title
57
+
58
+ # The HTTP status this error corresponds to. It is the status of the response. An item result does not repeat it in its `error`: read the item's `statusCode` instead.
59
+ attr_accessor :status
60
+
61
+ # A human-readable explanation specific to this occurrence.
62
+ attr_accessor :detail
63
+
64
+ # Present only on a partial failure. The Xero Bank Account the item concerns. On `partial-failure-new-account-creation`, the account that was created: connect it through `POST /FeedConnections/ExistingAccount`. On `partial-failure-previous-connection-deletion` and `partial-failure-connection-creation`, the account being connected. Absent on `partial-failure-connection-deletion` and `partial-failure-new-account-existence-not-confirmed`, where the account may not exist.
65
+ attr_accessor :account_id
66
+
67
+ # Present only on a partial failure of type `partial-failure-new-account-creation` or `partial-failure-new-account-existence-not-confirmed`. The name of the account that was created, which is now taken; on `partial-failure-new-account-existence-not-confirmed`, the name of the account that may have been created.
68
+ attr_accessor :account_name
69
+
70
+ # Present only on a partial failure. On `partial-failure-previous-connection-deletion`, the previous connection on the account (removed, or being removed). On `partial-failure-connection-creation`, the connection this request created or was creating: the id it was given before the create (the Feed Connection `id` if it was recorded). When the subtype is `connection-existence-not-confirmed`, the create's outcome is unknown and the connection may not exist in Xero. On `partial-failure-connection-deletion`, the connection being deleted (the item `id` also echoes it). Absent on `partial-failure-new-account-creation` and `partial-failure-new-account-existence-not-confirmed`.
71
+ attr_accessor :connection_id
72
+
73
+ class EnumAttributeValidator
74
+ attr_reader :datatype
75
+ attr_reader :allowable_values
76
+
77
+ def initialize(datatype, allowable_values)
78
+ @allowable_values = allowable_values.map do |value|
79
+ case datatype.to_s
80
+ when /Integer/i
81
+ value.to_i
82
+ when /Float/i
83
+ value.to_f
84
+ else
85
+ value
86
+ end
87
+ end
88
+ end
89
+
90
+ def valid?(value)
91
+ !value || allowable_values.include?(value)
92
+ end
93
+ end
94
+
95
+ # Attribute mapping from ruby-style variable name to JSON key.
96
+ def self.attribute_map
97
+ {
98
+ :'type' => :'type',
99
+ :'subtype' => :'subtype',
100
+ :'title' => :'title',
101
+ :'status' => :'status',
102
+ :'detail' => :'detail',
103
+ :'account_id' => :'accountId',
104
+ :'account_name' => :'accountName',
105
+ :'connection_id' => :'connectionId'
106
+ }
107
+ end
108
+
109
+ # Attribute type mapping.
110
+ def self.openapi_types
111
+ {
112
+ :'type' => :'String',
113
+ :'subtype' => :'String',
114
+ :'title' => :'String',
115
+ :'status' => :'Integer',
116
+ :'detail' => :'String',
117
+ :'account_id' => :'String',
118
+ :'account_name' => :'String',
119
+ :'connection_id' => :'String'
120
+ }
121
+ end
122
+
123
+ # Initializes the object
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ def initialize(attributes = {})
126
+ if (!attributes.is_a?(Hash))
127
+ fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::BankfeedsV2::Problem` initialize method"
128
+ end
129
+
130
+ # check to see if the attribute exists and convert string to symbol for hash key
131
+ attributes = attributes.each_with_object({}) { |(k, v), h|
132
+ if (!self.class.attribute_map.key?(k.to_sym))
133
+ fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::BankfeedsV2::Problem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
134
+ end
135
+ h[k.to_sym] = v
136
+ }
137
+
138
+ if attributes.key?(:'type')
139
+ self.type = attributes[:'type']
140
+ end
141
+
142
+ if attributes.key?(:'subtype')
143
+ self.subtype = attributes[:'subtype']
144
+ end
145
+
146
+ if attributes.key?(:'title')
147
+ self.title = attributes[:'title']
148
+ end
149
+
150
+ if attributes.key?(:'status')
151
+ self.status = attributes[:'status']
152
+ end
153
+
154
+ if attributes.key?(:'detail')
155
+ self.detail = attributes[:'detail']
156
+ end
157
+
158
+ if attributes.key?(:'account_id')
159
+ self.account_id = attributes[:'account_id']
160
+ end
161
+
162
+ if attributes.key?(:'account_name')
163
+ self.account_name = attributes[:'account_name']
164
+ end
165
+
166
+ if attributes.key?(:'connection_id')
167
+ self.connection_id = attributes[:'connection_id']
168
+ end
169
+ end
170
+
171
+ # Show invalid properties with the reasons. Usually used together with valid?
172
+ # @return Array for valid properties with the reasons
173
+ def list_invalid_properties
174
+ invalid_properties = Array.new
175
+ invalid_properties
176
+ end
177
+
178
+ # Check to see if the all the properties in the model are valid
179
+ # @return true if the model is valid
180
+ def valid?
181
+ type_validator = EnumAttributeValidator.new('String', ["invalid-request", "invalid-application", "suspended-or-terminated-application", "invalid-organisation-bank-feeds", "invalid-organisation-multi-currency", "invalid-feed-connection-for-organisation", "invalid-user-role", "invalid-account-token", "missing-identifying-fields", "invalid-country-specified", "account-not-valid", "feed-already-connected-in-current-organisation", "account-name-already-exists", "bank-feed-not-found", "feed-not-found-or-already-deleted", "partial-failure-new-account-creation", "partial-failure-previous-connection-deletion", "partial-failure-connection-creation", "partial-failure-connection-deletion", "partial-failure-new-account-existence-not-confirmed", "too-many-requests", "internal-error"])
182
+ return false unless type_validator.valid?(@type)
183
+ subtype_validator = EnumAttributeValidator.new('String', ["connection-phase-failed", "deletion-phase-failed", "deletion-phase-not-confirmed", "connection-existence-not-confirmed", "connection-exists-without-feed-connection", "feed-connection-existence-not-confirmed-can-check-or-retry", "check-accounts-or-prompt-user-retry"])
184
+ return false unless subtype_validator.valid?(@subtype)
185
+ true
186
+ end
187
+
188
+ # Custom attribute writer method checking allowed values (enum).
189
+ # @param [Object] type Object to be assigned
190
+ def type=(type)
191
+ validator = EnumAttributeValidator.new('String', ["invalid-request", "invalid-application", "suspended-or-terminated-application", "invalid-organisation-bank-feeds", "invalid-organisation-multi-currency", "invalid-feed-connection-for-organisation", "invalid-user-role", "invalid-account-token", "missing-identifying-fields", "invalid-country-specified", "account-not-valid", "feed-already-connected-in-current-organisation", "account-name-already-exists", "bank-feed-not-found", "feed-not-found-or-already-deleted", "partial-failure-new-account-creation", "partial-failure-previous-connection-deletion", "partial-failure-connection-creation", "partial-failure-connection-deletion", "partial-failure-new-account-existence-not-confirmed", "too-many-requests", "internal-error"])
192
+ unless validator.valid?(type)
193
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
194
+ end
195
+ @type = type
196
+ end
197
+
198
+ # Custom attribute writer method checking allowed values (enum).
199
+ # @param [Object] subtype Object to be assigned
200
+ def subtype=(subtype)
201
+ validator = EnumAttributeValidator.new('String', ["connection-phase-failed", "deletion-phase-failed", "deletion-phase-not-confirmed", "connection-existence-not-confirmed", "connection-exists-without-feed-connection", "feed-connection-existence-not-confirmed-can-check-or-retry", "check-accounts-or-prompt-user-retry"])
202
+ unless validator.valid?(subtype)
203
+ fail ArgumentError, "invalid value for \"subtype\", must be one of #{validator.allowable_values}."
204
+ end
205
+ @subtype = subtype
206
+ end
207
+
208
+ # Checks equality by comparing each attribute.
209
+ # @param [Object] Object to be compared
210
+ def ==(o)
211
+ return true if self.equal?(o)
212
+ self.class == o.class &&
213
+ type == o.type &&
214
+ subtype == o.subtype &&
215
+ title == o.title &&
216
+ status == o.status &&
217
+ detail == o.detail &&
218
+ account_id == o.account_id &&
219
+ account_name == o.account_name &&
220
+ connection_id == o.connection_id
221
+ end
222
+
223
+ # @see the `==` method
224
+ # @param [Object] Object to be compared
225
+ def eql?(o)
226
+ self == o
227
+ end
228
+
229
+ # Calculates hash code according to all attributes.
230
+ # @return [Integer] Hash code
231
+ def hash
232
+ [type, subtype, title, status, detail, account_id, account_name, connection_id].hash
233
+ end
234
+
235
+ # Builds the object from hash
236
+ # @param [Hash] attributes Model attributes in the form of hash
237
+ # @return [Object] Returns the model itself
238
+ def self.build_from_hash(attributes)
239
+ new.build_from_hash(attributes)
240
+ end
241
+
242
+ # Builds the object from hash
243
+ # @param [Hash] attributes Model attributes in the form of hash
244
+ # @return [Object] Returns the model itself
245
+ def build_from_hash(attributes)
246
+ return nil unless attributes.is_a?(Hash)
247
+ self.class.openapi_types.each_pair do |key, type|
248
+ if type =~ /\AArray<(.*)>/i
249
+ # check to ensure the input is an array given that the attribute
250
+ # is documented as an array but the input is not
251
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
252
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
253
+ end
254
+ elsif !attributes[self.class.attribute_map[key]].nil?
255
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
256
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
257
+ end
258
+
259
+ self
260
+ end
261
+
262
+ # Deserializes the data based on type
263
+ # @param string type Data type
264
+ # @param string value Value to be deserialized
265
+ # @return [Object] Deserialized data
266
+ def _deserialize(type, value)
267
+ case type.to_sym
268
+ when :DateTime
269
+ DateTime.parse(parse_date(value))
270
+ when :Date
271
+ Date.parse(parse_date(value))
272
+ when :String
273
+ value.to_s
274
+ when :Integer
275
+ value.to_i
276
+ when :Float
277
+ value.to_f
278
+ when :BigDecimal
279
+ BigDecimal(value.to_s)
280
+ when :Boolean
281
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
282
+ true
283
+ else
284
+ false
285
+ end
286
+ when :Object
287
+ # generic object (usually a Hash), return directly
288
+ value
289
+ when /\AArray<(?<inner_type>.+)>\z/
290
+ inner_type = Regexp.last_match[:inner_type]
291
+ value.map { |v| _deserialize(inner_type, v) }
292
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
293
+ k_type = Regexp.last_match[:k_type]
294
+ v_type = Regexp.last_match[:v_type]
295
+ {}.tap do |hash|
296
+ value.each do |k, v|
297
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
298
+ end
299
+ end
300
+ else # model
301
+ XeroRuby::BankfeedsV2.const_get(type).build_from_hash(value)
302
+ end
303
+ end
304
+
305
+ # Returns the string representation of the object
306
+ # @return [String] String presentation of the object
307
+ def to_s
308
+ to_hash.to_s
309
+ end
310
+
311
+ # to_body is an alias to to_hash (backward compatibility)
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_body
314
+ to_hash
315
+ end
316
+
317
+ # Returns the object in the form of hash
318
+ # @return [Hash] Returns the object in the form of hash
319
+ def to_hash(downcase: false)
320
+ hash = {}
321
+ self.class.attribute_map.each_pair do |attr, param|
322
+ value = self.send(attr)
323
+ next if value.nil?
324
+ key = downcase ? attr : param
325
+ hash[key] = _to_hash(value, downcase: downcase)
326
+ end
327
+ hash
328
+ end
329
+
330
+ # Returns the object in the form of hash with snake_case
331
+ def to_attributes
332
+ to_hash(downcase: true)
333
+ end
334
+
335
+ # Outputs non-array value in the form of hash
336
+ # For object, use to_hash. Otherwise, just return the value
337
+ # @param [Object] value Any valid value
338
+ # @return [Hash] Returns the value in the form of hash
339
+ def _to_hash(value, downcase: false)
340
+ if value.is_a?(Array)
341
+ value.map do |v|
342
+ v.to_hash(downcase: downcase)
343
+ end
344
+ elsif value.is_a?(Hash)
345
+ {}.tap do |hash|
346
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
347
+ end
348
+ elsif value.respond_to? :to_hash
349
+ value.to_hash(downcase: downcase)
350
+ else
351
+ value
352
+ end
353
+ end
354
+
355
+ def parse_date(datestring)
356
+ if datestring.include?('Date')
357
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
358
+ original, date, timezone = *date_pattern.match(datestring)
359
+ date = (date.to_i / 1000)
360
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
361
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
362
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
363
+ else # handle date 'types' for small subset of payroll API's
364
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
365
+ end
366
+ end
367
+ end
368
+ end
@@ -7,9 +7,9 @@ Contact: api@xero.com
7
7
  Generated by: https://openapi-generator.tech
8
8
  OpenAPI Generator version: 4.3.1
9
9
 
10
- The version of the XeroOpenAPI document: 20.0.1
10
+ The version of the XeroOpenAPI document: 20.1.0
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '18.4.0'
14
+ VERSION = '19.0.0'
15
15
  end