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.
- checksums.yaml +4 -4
- data/lib/xero-ruby/api/feed_connections_api.rb +410 -0
- data/lib/xero-ruby/api_client.rb +42 -24
- data/lib/xero-ruby/configuration.rb +10 -6
- data/lib/xero-ruby/models/accounting/budget.rb +25 -1
- data/lib/xero-ruby/models/accounting/budget_balance.rb +4 -39
- data/lib/xero-ruby/models/bankfeeds_v2/account_type.rb +36 -0
- data/lib/xero-ruby/models/{finance/lock_history_response.rb → bankfeeds_v2/bulk_feed_connection_response.rb} +16 -35
- data/lib/xero-ruby/models/bankfeeds_v2/bulk_feed_connection_result.rb +300 -0
- data/lib/xero-ruby/models/bankfeeds_v2/delete_feed_connections_request.rb +229 -0
- data/lib/xero-ruby/models/bankfeeds_v2/existing_account_feed_connection.rb +373 -0
- data/lib/xero-ruby/models/bankfeeds_v2/existing_account_feed_connections_request.rb +229 -0
- data/lib/xero-ruby/models/{finance/account_usage.rb → bankfeeds_v2/feed_connection.rb} +59 -108
- data/lib/xero-ruby/models/{finance/account_usage_response.rb → bankfeeds_v2/feed_connection_to_delete.rb} +20 -47
- data/lib/xero-ruby/models/bankfeeds_v2/item_error.rb +358 -0
- data/lib/xero-ruby/models/bankfeeds_v2/new_account_feed_connection.rb +406 -0
- data/lib/xero-ruby/models/{finance/user_activities_response.rb → bankfeeds_v2/new_account_feed_connections_request.rb} +21 -36
- data/lib/xero-ruby/models/{finance/report_history_response.rb → bankfeeds_v2/paged_feed_connections.rb} +22 -32
- data/lib/xero-ruby/models/{finance/practice_response.rb → bankfeeds_v2/pagination.rb} +36 -46
- data/lib/xero-ruby/models/bankfeeds_v2/problem.rb +368 -0
- data/lib/xero-ruby/version.rb +2 -2
- data/lib/xero-ruby.rb +143 -128
- metadata +369 -364
- data/lib/xero-ruby/models/finance/history_record_response.rb +0 -262
- data/lib/xero-ruby/models/finance/lock_history_model.rb +0 -242
- data/lib/xero-ruby/models/finance/report_history_model.rb +0 -242
- data/lib/xero-ruby/models/finance/user_response.rb +0 -336
|
@@ -19,6 +19,11 @@ module XeroRuby::Accounting
|
|
|
19
19
|
# Xero identifier
|
|
20
20
|
attr_accessor :budget_id
|
|
21
21
|
|
|
22
|
+
# The tool used to create the budget
|
|
23
|
+
attr_accessor :created_in
|
|
24
|
+
XERO_ANALYTICS ||= "XERO_ANALYTICS".freeze
|
|
25
|
+
BUDGETS_MANAGER ||= "BUDGETS_MANAGER".freeze
|
|
26
|
+
|
|
22
27
|
# Type of Budget. OVERALL or TRACKING
|
|
23
28
|
attr_accessor :type
|
|
24
29
|
OVERALL ||= "OVERALL".freeze
|
|
@@ -62,6 +67,7 @@ module XeroRuby::Accounting
|
|
|
62
67
|
def self.attribute_map
|
|
63
68
|
{
|
|
64
69
|
:'budget_id' => :'BudgetID',
|
|
70
|
+
:'created_in' => :'CreatedIn',
|
|
65
71
|
:'type' => :'Type',
|
|
66
72
|
:'description' => :'Description',
|
|
67
73
|
:'updated_date_utc' => :'UpdatedDateUTC',
|
|
@@ -74,6 +80,7 @@ module XeroRuby::Accounting
|
|
|
74
80
|
def self.openapi_types
|
|
75
81
|
{
|
|
76
82
|
:'budget_id' => :'String',
|
|
83
|
+
:'created_in' => :'String',
|
|
77
84
|
:'type' => :'String',
|
|
78
85
|
:'description' => :'String',
|
|
79
86
|
:'updated_date_utc' => :'DateTime',
|
|
@@ -101,6 +108,10 @@ module XeroRuby::Accounting
|
|
|
101
108
|
self.budget_id = attributes[:'budget_id']
|
|
102
109
|
end
|
|
103
110
|
|
|
111
|
+
if attributes.key?(:'created_in')
|
|
112
|
+
self.created_in = attributes[:'created_in']
|
|
113
|
+
end
|
|
114
|
+
|
|
104
115
|
if attributes.key?(:'type')
|
|
105
116
|
self.type = attributes[:'type']
|
|
106
117
|
end
|
|
@@ -140,12 +151,24 @@ module XeroRuby::Accounting
|
|
|
140
151
|
# Check to see if the all the properties in the model are valid
|
|
141
152
|
# @return true if the model is valid
|
|
142
153
|
def valid?
|
|
154
|
+
created_in_validator = EnumAttributeValidator.new('String', ["XERO_ANALYTICS", "BUDGETS_MANAGER"])
|
|
155
|
+
return false unless created_in_validator.valid?(@created_in)
|
|
143
156
|
type_validator = EnumAttributeValidator.new('String', ["OVERALL", "TRACKING"])
|
|
144
157
|
return false unless type_validator.valid?(@type)
|
|
145
158
|
return false if !@description.nil? && @description.to_s.length > 255
|
|
146
159
|
true
|
|
147
160
|
end
|
|
148
161
|
|
|
162
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
163
|
+
# @param [Object] created_in Object to be assigned
|
|
164
|
+
def created_in=(created_in)
|
|
165
|
+
validator = EnumAttributeValidator.new('String', ["XERO_ANALYTICS", "BUDGETS_MANAGER"])
|
|
166
|
+
unless validator.valid?(created_in)
|
|
167
|
+
fail ArgumentError, "invalid value for \"created_in\", must be one of #{validator.allowable_values}."
|
|
168
|
+
end
|
|
169
|
+
@created_in = created_in
|
|
170
|
+
end
|
|
171
|
+
|
|
149
172
|
# Custom attribute writer method checking allowed values (enum).
|
|
150
173
|
# @param [Object] type Object to be assigned
|
|
151
174
|
def type=(type)
|
|
@@ -172,6 +195,7 @@ module XeroRuby::Accounting
|
|
|
172
195
|
return true if self.equal?(o)
|
|
173
196
|
self.class == o.class &&
|
|
174
197
|
budget_id == o.budget_id &&
|
|
198
|
+
created_in == o.created_in &&
|
|
175
199
|
type == o.type &&
|
|
176
200
|
description == o.description &&
|
|
177
201
|
updated_date_utc == o.updated_date_utc &&
|
|
@@ -188,7 +212,7 @@ module XeroRuby::Accounting
|
|
|
188
212
|
# Calculates hash code according to all attributes.
|
|
189
213
|
# @return [Integer] Hash code
|
|
190
214
|
def hash
|
|
191
|
-
[budget_id, type, description, updated_date_utc, budget_lines, tracking].hash
|
|
215
|
+
[budget_id, created_in, type, description, updated_date_utc, budget_lines, tracking].hash
|
|
192
216
|
end
|
|
193
217
|
|
|
194
218
|
# Builds the object from hash
|
|
@@ -22,19 +22,11 @@ module XeroRuby::Accounting
|
|
|
22
22
|
# LineItem Quantity
|
|
23
23
|
attr_accessor :amount
|
|
24
24
|
|
|
25
|
-
# Budgeted amount
|
|
26
|
-
attr_accessor :unit_amount
|
|
27
|
-
|
|
28
|
-
# Any footnotes associated with this balance
|
|
29
|
-
attr_accessor :notes
|
|
30
|
-
|
|
31
25
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
32
26
|
def self.attribute_map
|
|
33
27
|
{
|
|
34
28
|
:'period' => :'Period',
|
|
35
|
-
:'amount' => :'Amount'
|
|
36
|
-
:'unit_amount' => :'UnitAmount',
|
|
37
|
-
:'notes' => :'Notes'
|
|
29
|
+
:'amount' => :'Amount'
|
|
38
30
|
}
|
|
39
31
|
end
|
|
40
32
|
|
|
@@ -42,9 +34,7 @@ module XeroRuby::Accounting
|
|
|
42
34
|
def self.openapi_types
|
|
43
35
|
{
|
|
44
36
|
:'period' => :'Date',
|
|
45
|
-
:'amount' => :'BigDecimal'
|
|
46
|
-
:'unit_amount' => :'BigDecimal',
|
|
47
|
-
:'notes' => :'String'
|
|
37
|
+
:'amount' => :'BigDecimal'
|
|
48
38
|
}
|
|
49
39
|
end
|
|
50
40
|
|
|
@@ -70,53 +60,28 @@ module XeroRuby::Accounting
|
|
|
70
60
|
if attributes.key?(:'amount')
|
|
71
61
|
self.amount = attributes[:'amount']
|
|
72
62
|
end
|
|
73
|
-
|
|
74
|
-
if attributes.key?(:'unit_amount')
|
|
75
|
-
self.unit_amount = attributes[:'unit_amount']
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
if attributes.key?(:'notes')
|
|
79
|
-
self.notes = attributes[:'notes']
|
|
80
|
-
end
|
|
81
63
|
end
|
|
82
64
|
|
|
83
65
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
84
66
|
# @return Array for valid properties with the reasons
|
|
85
67
|
def list_invalid_properties
|
|
86
68
|
invalid_properties = Array.new
|
|
87
|
-
if !@notes.nil? && @notes.to_s.length > 255
|
|
88
|
-
invalid_properties.push('invalid value for "notes", the character length must be smaller than or equal to 255.')
|
|
89
|
-
end
|
|
90
|
-
|
|
91
69
|
invalid_properties
|
|
92
70
|
end
|
|
93
71
|
|
|
94
72
|
# Check to see if the all the properties in the model are valid
|
|
95
73
|
# @return true if the model is valid
|
|
96
74
|
def valid?
|
|
97
|
-
return false if !@notes.nil? && @notes.to_s.length > 255
|
|
98
75
|
true
|
|
99
76
|
end
|
|
100
77
|
|
|
101
|
-
# Custom attribute writer method with validation
|
|
102
|
-
# @param [Object] notes Value to be assigned
|
|
103
|
-
def notes=(notes)
|
|
104
|
-
if !notes.nil? && notes.to_s.length > 255
|
|
105
|
-
fail ArgumentError, 'invalid value for "notes", the character length must be smaller than or equal to 255.'
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
@notes = notes
|
|
109
|
-
end
|
|
110
|
-
|
|
111
78
|
# Checks equality by comparing each attribute.
|
|
112
79
|
# @param [Object] Object to be compared
|
|
113
80
|
def ==(o)
|
|
114
81
|
return true if self.equal?(o)
|
|
115
82
|
self.class == o.class &&
|
|
116
83
|
period == o.period &&
|
|
117
|
-
amount == o.amount
|
|
118
|
-
unit_amount == o.unit_amount &&
|
|
119
|
-
notes == o.notes
|
|
84
|
+
amount == o.amount
|
|
120
85
|
end
|
|
121
86
|
|
|
122
87
|
# @see the `==` method
|
|
@@ -128,7 +93,7 @@ module XeroRuby::Accounting
|
|
|
128
93
|
# Calculates hash code according to all attributes.
|
|
129
94
|
# @return [Integer] Hash code
|
|
130
95
|
def hash
|
|
131
|
-
[period, amount
|
|
96
|
+
[period, amount].hash
|
|
132
97
|
end
|
|
133
98
|
|
|
134
99
|
# Builds the object from hash
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
class AccountType
|
|
17
|
+
BANK ||= "BANK".freeze
|
|
18
|
+
CREDITCARD ||= "CREDITCARD".freeze
|
|
19
|
+
|
|
20
|
+
# Builds the enum from string
|
|
21
|
+
# @param [String] The enum value in the form of the string
|
|
22
|
+
# @return [String] The enum value
|
|
23
|
+
def self.build_from_hash(value)
|
|
24
|
+
new.build_from_hash(value)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Builds the enum from string
|
|
28
|
+
# @param [String] The enum value in the form of the string
|
|
29
|
+
# @return [String] The enum value
|
|
30
|
+
def build_from_hash(value)
|
|
31
|
+
constantValues = AccountType.constants.select { |c| AccountType::const_get(c) == value }
|
|
32
|
+
raise "Invalid ENUM value #{value} for class #AccountType" if constantValues.empty?
|
|
33
|
+
value
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
|
-
#Xero
|
|
2
|
+
#Xero Bank Feeds API v2
|
|
3
3
|
|
|
4
|
-
#The
|
|
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,34 +12,25 @@ OpenAPI Generator version: 4.3.1
|
|
|
12
12
|
require 'time'
|
|
13
13
|
require 'date'
|
|
14
14
|
|
|
15
|
-
module XeroRuby::
|
|
15
|
+
module XeroRuby::BankfeedsV2
|
|
16
|
+
# One result per request item, in request order.
|
|
16
17
|
require 'bigdecimal'
|
|
17
18
|
|
|
18
|
-
class
|
|
19
|
-
# The requested Organisation to which the data pertains
|
|
20
|
-
attr_accessor :organisation_id
|
|
21
|
-
|
|
22
|
-
# The end date of the report
|
|
23
|
-
attr_accessor :end_date
|
|
24
|
-
|
|
19
|
+
class BulkFeedConnectionResponse
|
|
25
20
|
|
|
26
|
-
attr_accessor :
|
|
21
|
+
attr_accessor :items
|
|
27
22
|
|
|
28
23
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
29
24
|
def self.attribute_map
|
|
30
25
|
{
|
|
31
|
-
:'
|
|
32
|
-
:'end_date' => :'endDate',
|
|
33
|
-
:'lock_dates' => :'lockDates'
|
|
26
|
+
:'items' => :'items'
|
|
34
27
|
}
|
|
35
28
|
end
|
|
36
29
|
|
|
37
30
|
# Attribute type mapping.
|
|
38
31
|
def self.openapi_types
|
|
39
32
|
{
|
|
40
|
-
:'
|
|
41
|
-
:'end_date' => :'Date',
|
|
42
|
-
:'lock_dates' => :'Array<LockHistoryModel>'
|
|
33
|
+
:'items' => :'Array<BulkFeedConnectionResult>'
|
|
43
34
|
}
|
|
44
35
|
end
|
|
45
36
|
|
|
@@ -47,28 +38,20 @@ module XeroRuby::Finance
|
|
|
47
38
|
# @param [Hash] attributes Model attributes in the form of hash
|
|
48
39
|
def initialize(attributes = {})
|
|
49
40
|
if (!attributes.is_a?(Hash))
|
|
50
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::
|
|
41
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::BankfeedsV2::BulkFeedConnectionResponse` initialize method"
|
|
51
42
|
end
|
|
52
43
|
|
|
53
44
|
# check to see if the attribute exists and convert string to symbol for hash key
|
|
54
45
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
55
46
|
if (!self.class.attribute_map.key?(k.to_sym))
|
|
56
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::
|
|
47
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::BankfeedsV2::BulkFeedConnectionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
57
48
|
end
|
|
58
49
|
h[k.to_sym] = v
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
if attributes.key?(:'
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if attributes.key?(:'end_date')
|
|
66
|
-
self.end_date = attributes[:'end_date']
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
if attributes.key?(:'lock_dates')
|
|
70
|
-
if (value = attributes[:'lock_dates']).is_a?(Array)
|
|
71
|
-
self.lock_dates = value
|
|
52
|
+
if attributes.key?(:'items')
|
|
53
|
+
if (value = attributes[:'items']).is_a?(Array)
|
|
54
|
+
self.items = value
|
|
72
55
|
end
|
|
73
56
|
end
|
|
74
57
|
end
|
|
@@ -91,9 +74,7 @@ module XeroRuby::Finance
|
|
|
91
74
|
def ==(o)
|
|
92
75
|
return true if self.equal?(o)
|
|
93
76
|
self.class == o.class &&
|
|
94
|
-
|
|
95
|
-
end_date == o.end_date &&
|
|
96
|
-
lock_dates == o.lock_dates
|
|
77
|
+
items == o.items
|
|
97
78
|
end
|
|
98
79
|
|
|
99
80
|
# @see the `==` method
|
|
@@ -105,7 +86,7 @@ module XeroRuby::Finance
|
|
|
105
86
|
# Calculates hash code according to all attributes.
|
|
106
87
|
# @return [Integer] Hash code
|
|
107
88
|
def hash
|
|
108
|
-
[
|
|
89
|
+
[items].hash
|
|
109
90
|
end
|
|
110
91
|
|
|
111
92
|
# Builds the object from hash
|
|
@@ -174,7 +155,7 @@ module XeroRuby::Finance
|
|
|
174
155
|
end
|
|
175
156
|
end
|
|
176
157
|
else # model
|
|
177
|
-
XeroRuby::
|
|
158
|
+
XeroRuby::BankfeedsV2.const_get(type).build_from_hash(value)
|
|
178
159
|
end
|
|
179
160
|
end
|
|
180
161
|
|
|
@@ -0,0 +1,300 @@
|
|
|
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
|
+
# The outcome for a single request item. Read `status` rather than inferring the outcome from the presence of `error`. On a termination an item can have both `SUCCESS` and an `error`, when the identifier did not match a connection to terminate. Read `statusCode` per item as well, rather than deriving it from the envelope: it is the number the envelope itself is computed from. A `statusCode` of `204` is an idempotent no-op, not a failure; one of `500` on a `partial-failure-*` type is not a server fault to retry blindly. The item's `error` does not repeat the number as `status`.
|
|
17
|
+
require 'bigdecimal'
|
|
18
|
+
|
|
19
|
+
class BulkFeedConnectionResult
|
|
20
|
+
# On a create, Xero's identifier for the new Feed Connection; absent when the item was rejected, since nothing was created. On a termination, the identifier supplied in the request, echoed back; absent only when the item did not include a usable identifier.
|
|
21
|
+
attr_accessor :id
|
|
22
|
+
|
|
23
|
+
# The `accountToken` supplied in the request, echoed back, including on a rejected item. Not returned on a termination.
|
|
24
|
+
attr_accessor :account_token
|
|
25
|
+
|
|
26
|
+
# `SUCCESS` means the item reached the state the request asked for — on a create the connection exists, on a termination it is gone, including the idempotent case where it was already gone. `REJECTED` means nothing was written, or Xero confirmed that nothing took effect. A `4xx` item needs correcting before it is sent again, and a `500` item can be resent as it is. `error` says why. `PARTIAL_FAILURE` means the item did not complete, and the state it left behind needs attention or could not be confirmed. `error.subtype` says which, `error.detail` describes it, and the item needs attention that neither of the other two values implies. A client deserialising this into a closed set of `SUCCESS` and `REJECTED` will fail on `PARTIAL_FAILURE`. That is intended rather than an oversight: binding it silently to either of the other two would hide state that the partner has to act on.
|
|
27
|
+
attr_accessor :status
|
|
28
|
+
SUCCESS ||= "SUCCESS".freeze
|
|
29
|
+
REJECTED ||= "REJECTED".freeze
|
|
30
|
+
PARTIAL_FAILURE ||= "PARTIAL_FAILURE".freeze
|
|
31
|
+
|
|
32
|
+
# The numeric status of this item: `201` on a created connection, `204` on a terminated or already-absent one, a 4xx on a rejection, `500` on a partial failure or on a rejection whose error is `internal-error` or `too-many-requests`. The response envelope is computed from the items' `statusCode` values: all 2xx is `200`, all 4xx is `400`, anything else is `207`. So a partner can size up one item without reading `status` and `error` together. Never `202` and never `207`: those are envelope-only, and an item-level `207` would be numerically inside 2xx, so a batch of partial failures could be reported as `200`.
|
|
33
|
+
attr_accessor :status_code
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
attr_accessor :error
|
|
37
|
+
|
|
38
|
+
class EnumAttributeValidator
|
|
39
|
+
attr_reader :datatype
|
|
40
|
+
attr_reader :allowable_values
|
|
41
|
+
|
|
42
|
+
def initialize(datatype, allowable_values)
|
|
43
|
+
@allowable_values = allowable_values.map do |value|
|
|
44
|
+
case datatype.to_s
|
|
45
|
+
when /Integer/i
|
|
46
|
+
value.to_i
|
|
47
|
+
when /Float/i
|
|
48
|
+
value.to_f
|
|
49
|
+
else
|
|
50
|
+
value
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def valid?(value)
|
|
56
|
+
!value || allowable_values.include?(value)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
61
|
+
def self.attribute_map
|
|
62
|
+
{
|
|
63
|
+
:'id' => :'id',
|
|
64
|
+
:'account_token' => :'accountToken',
|
|
65
|
+
:'status' => :'status',
|
|
66
|
+
:'status_code' => :'statusCode',
|
|
67
|
+
:'error' => :'error'
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Attribute type mapping.
|
|
72
|
+
def self.openapi_types
|
|
73
|
+
{
|
|
74
|
+
:'id' => :'String',
|
|
75
|
+
:'account_token' => :'String',
|
|
76
|
+
:'status' => :'String',
|
|
77
|
+
:'status_code' => :'Integer',
|
|
78
|
+
:'error' => :'ItemError'
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Initializes the object
|
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
84
|
+
def initialize(attributes = {})
|
|
85
|
+
if (!attributes.is_a?(Hash))
|
|
86
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::BankfeedsV2::BulkFeedConnectionResult` initialize method"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
90
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
91
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
92
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `XeroRuby::BankfeedsV2::BulkFeedConnectionResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
93
|
+
end
|
|
94
|
+
h[k.to_sym] = v
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'id')
|
|
98
|
+
self.id = attributes[:'id']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'account_token')
|
|
102
|
+
self.account_token = attributes[:'account_token']
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if attributes.key?(:'status')
|
|
106
|
+
self.status = attributes[:'status']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'status_code')
|
|
110
|
+
self.status_code = attributes[:'status_code']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'error')
|
|
114
|
+
self.error = attributes[:'error']
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
119
|
+
# @return Array for valid properties with the reasons
|
|
120
|
+
def list_invalid_properties
|
|
121
|
+
invalid_properties = Array.new
|
|
122
|
+
invalid_properties
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Check to see if the all the properties in the model are valid
|
|
126
|
+
# @return true if the model is valid
|
|
127
|
+
def valid?
|
|
128
|
+
status_validator = EnumAttributeValidator.new('String', ["SUCCESS", "REJECTED", "PARTIAL_FAILURE"])
|
|
129
|
+
return false unless status_validator.valid?(@status)
|
|
130
|
+
true
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
134
|
+
# @param [Object] status Object to be assigned
|
|
135
|
+
def status=(status)
|
|
136
|
+
validator = EnumAttributeValidator.new('String', ["SUCCESS", "REJECTED", "PARTIAL_FAILURE"])
|
|
137
|
+
unless validator.valid?(status)
|
|
138
|
+
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
|
139
|
+
end
|
|
140
|
+
@status = status
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Checks equality by comparing each attribute.
|
|
144
|
+
# @param [Object] Object to be compared
|
|
145
|
+
def ==(o)
|
|
146
|
+
return true if self.equal?(o)
|
|
147
|
+
self.class == o.class &&
|
|
148
|
+
id == o.id &&
|
|
149
|
+
account_token == o.account_token &&
|
|
150
|
+
status == o.status &&
|
|
151
|
+
status_code == o.status_code &&
|
|
152
|
+
error == o.error
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# @see the `==` method
|
|
156
|
+
# @param [Object] Object to be compared
|
|
157
|
+
def eql?(o)
|
|
158
|
+
self == o
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Calculates hash code according to all attributes.
|
|
162
|
+
# @return [Integer] Hash code
|
|
163
|
+
def hash
|
|
164
|
+
[id, account_token, status, status_code, error].hash
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Builds the object from hash
|
|
168
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
169
|
+
# @return [Object] Returns the model itself
|
|
170
|
+
def self.build_from_hash(attributes)
|
|
171
|
+
new.build_from_hash(attributes)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Builds the object from hash
|
|
175
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
176
|
+
# @return [Object] Returns the model itself
|
|
177
|
+
def build_from_hash(attributes)
|
|
178
|
+
return nil unless attributes.is_a?(Hash)
|
|
179
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
180
|
+
if type =~ /\AArray<(.*)>/i
|
|
181
|
+
# check to ensure the input is an array given that the attribute
|
|
182
|
+
# is documented as an array but the input is not
|
|
183
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
184
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
185
|
+
end
|
|
186
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
187
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
188
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
self
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Deserializes the data based on type
|
|
195
|
+
# @param string type Data type
|
|
196
|
+
# @param string value Value to be deserialized
|
|
197
|
+
# @return [Object] Deserialized data
|
|
198
|
+
def _deserialize(type, value)
|
|
199
|
+
case type.to_sym
|
|
200
|
+
when :DateTime
|
|
201
|
+
DateTime.parse(parse_date(value))
|
|
202
|
+
when :Date
|
|
203
|
+
Date.parse(parse_date(value))
|
|
204
|
+
when :String
|
|
205
|
+
value.to_s
|
|
206
|
+
when :Integer
|
|
207
|
+
value.to_i
|
|
208
|
+
when :Float
|
|
209
|
+
value.to_f
|
|
210
|
+
when :BigDecimal
|
|
211
|
+
BigDecimal(value.to_s)
|
|
212
|
+
when :Boolean
|
|
213
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
214
|
+
true
|
|
215
|
+
else
|
|
216
|
+
false
|
|
217
|
+
end
|
|
218
|
+
when :Object
|
|
219
|
+
# generic object (usually a Hash), return directly
|
|
220
|
+
value
|
|
221
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
222
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
223
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
224
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
225
|
+
k_type = Regexp.last_match[:k_type]
|
|
226
|
+
v_type = Regexp.last_match[:v_type]
|
|
227
|
+
{}.tap do |hash|
|
|
228
|
+
value.each do |k, v|
|
|
229
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
else # model
|
|
233
|
+
XeroRuby::BankfeedsV2.const_get(type).build_from_hash(value)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Returns the string representation of the object
|
|
238
|
+
# @return [String] String presentation of the object
|
|
239
|
+
def to_s
|
|
240
|
+
to_hash.to_s
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
244
|
+
# @return [Hash] Returns the object in the form of hash
|
|
245
|
+
def to_body
|
|
246
|
+
to_hash
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Returns the object in the form of hash
|
|
250
|
+
# @return [Hash] Returns the object in the form of hash
|
|
251
|
+
def to_hash(downcase: false)
|
|
252
|
+
hash = {}
|
|
253
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
254
|
+
value = self.send(attr)
|
|
255
|
+
next if value.nil?
|
|
256
|
+
key = downcase ? attr : param
|
|
257
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
|
258
|
+
end
|
|
259
|
+
hash
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# Returns the object in the form of hash with snake_case
|
|
263
|
+
def to_attributes
|
|
264
|
+
to_hash(downcase: true)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Outputs non-array value in the form of hash
|
|
268
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
269
|
+
# @param [Object] value Any valid value
|
|
270
|
+
# @return [Hash] Returns the value in the form of hash
|
|
271
|
+
def _to_hash(value, downcase: false)
|
|
272
|
+
if value.is_a?(Array)
|
|
273
|
+
value.map do |v|
|
|
274
|
+
v.to_hash(downcase: downcase)
|
|
275
|
+
end
|
|
276
|
+
elsif value.is_a?(Hash)
|
|
277
|
+
{}.tap do |hash|
|
|
278
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
|
279
|
+
end
|
|
280
|
+
elsif value.respond_to? :to_hash
|
|
281
|
+
value.to_hash(downcase: downcase)
|
|
282
|
+
else
|
|
283
|
+
value
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def parse_date(datestring)
|
|
288
|
+
if datestring.include?('Date')
|
|
289
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
|
290
|
+
original, date, timezone = *date_pattern.match(datestring)
|
|
291
|
+
date = (date.to_i / 1000)
|
|
292
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
|
293
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
|
294
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
295
|
+
else # handle date 'types' for small subset of payroll API's
|
|
296
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
end
|