xero-ruby 18.4.0 → 18.5.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 +9 -0
- data/lib/xero-ruby/configuration.rb +2 -0
- 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/bankfeeds_v2/bulk_feed_connection_response.rb +225 -0
- 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/bankfeeds_v2/feed_connection.rb +293 -0
- data/lib/xero-ruby/models/bankfeeds_v2/feed_connection_to_delete.rb +227 -0
- 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/bankfeeds_v2/new_account_feed_connections_request.rb +229 -0
- data/lib/xero-ruby/models/bankfeeds_v2/paged_feed_connections.rb +234 -0
- data/lib/xero-ruby/models/bankfeeds_v2/pagination.rb +252 -0
- data/lib/xero-ruby/models/bankfeeds_v2/problem.rb +368 -0
- data/lib/xero-ruby/version.rb +2 -2
- data/lib/xero-ruby.rb +15 -0
- metadata +366 -351
|
@@ -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
|
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
# One result per request item, in request order.
|
|
17
|
+
require 'bigdecimal'
|
|
18
|
+
|
|
19
|
+
class BulkFeedConnectionResponse
|
|
20
|
+
|
|
21
|
+
attr_accessor :items
|
|
22
|
+
|
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
24
|
+
def self.attribute_map
|
|
25
|
+
{
|
|
26
|
+
:'items' => :'items'
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Attribute type mapping.
|
|
31
|
+
def self.openapi_types
|
|
32
|
+
{
|
|
33
|
+
:'items' => :'Array<BulkFeedConnectionResult>'
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Initializes the object
|
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
39
|
+
def initialize(attributes = {})
|
|
40
|
+
if (!attributes.is_a?(Hash))
|
|
41
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `XeroRuby::BankfeedsV2::BulkFeedConnectionResponse` initialize method"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
45
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
46
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
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
|
|
48
|
+
end
|
|
49
|
+
h[k.to_sym] = v
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if attributes.key?(:'items')
|
|
53
|
+
if (value = attributes[:'items']).is_a?(Array)
|
|
54
|
+
self.items = value
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
60
|
+
# @return Array for valid properties with the reasons
|
|
61
|
+
def list_invalid_properties
|
|
62
|
+
invalid_properties = Array.new
|
|
63
|
+
invalid_properties
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Check to see if the all the properties in the model are valid
|
|
67
|
+
# @return true if the model is valid
|
|
68
|
+
def valid?
|
|
69
|
+
true
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Checks equality by comparing each attribute.
|
|
73
|
+
# @param [Object] Object to be compared
|
|
74
|
+
def ==(o)
|
|
75
|
+
return true if self.equal?(o)
|
|
76
|
+
self.class == o.class &&
|
|
77
|
+
items == o.items
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# @see the `==` method
|
|
81
|
+
# @param [Object] Object to be compared
|
|
82
|
+
def eql?(o)
|
|
83
|
+
self == o
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Calculates hash code according to all attributes.
|
|
87
|
+
# @return [Integer] Hash code
|
|
88
|
+
def hash
|
|
89
|
+
[items].hash
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Builds the object from hash
|
|
93
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
94
|
+
# @return [Object] Returns the model itself
|
|
95
|
+
def self.build_from_hash(attributes)
|
|
96
|
+
new.build_from_hash(attributes)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Builds the object from hash
|
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
101
|
+
# @return [Object] Returns the model itself
|
|
102
|
+
def build_from_hash(attributes)
|
|
103
|
+
return nil unless attributes.is_a?(Hash)
|
|
104
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
105
|
+
if type =~ /\AArray<(.*)>/i
|
|
106
|
+
# check to ensure the input is an array given that the attribute
|
|
107
|
+
# is documented as an array but the input is not
|
|
108
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
109
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
110
|
+
end
|
|
111
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
112
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
113
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
self
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Deserializes the data based on type
|
|
120
|
+
# @param string type Data type
|
|
121
|
+
# @param string value Value to be deserialized
|
|
122
|
+
# @return [Object] Deserialized data
|
|
123
|
+
def _deserialize(type, value)
|
|
124
|
+
case type.to_sym
|
|
125
|
+
when :DateTime
|
|
126
|
+
DateTime.parse(parse_date(value))
|
|
127
|
+
when :Date
|
|
128
|
+
Date.parse(parse_date(value))
|
|
129
|
+
when :String
|
|
130
|
+
value.to_s
|
|
131
|
+
when :Integer
|
|
132
|
+
value.to_i
|
|
133
|
+
when :Float
|
|
134
|
+
value.to_f
|
|
135
|
+
when :BigDecimal
|
|
136
|
+
BigDecimal(value.to_s)
|
|
137
|
+
when :Boolean
|
|
138
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
139
|
+
true
|
|
140
|
+
else
|
|
141
|
+
false
|
|
142
|
+
end
|
|
143
|
+
when :Object
|
|
144
|
+
# generic object (usually a Hash), return directly
|
|
145
|
+
value
|
|
146
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
147
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
148
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
149
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
150
|
+
k_type = Regexp.last_match[:k_type]
|
|
151
|
+
v_type = Regexp.last_match[:v_type]
|
|
152
|
+
{}.tap do |hash|
|
|
153
|
+
value.each do |k, v|
|
|
154
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
else # model
|
|
158
|
+
XeroRuby::BankfeedsV2.const_get(type).build_from_hash(value)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Returns the string representation of the object
|
|
163
|
+
# @return [String] String presentation of the object
|
|
164
|
+
def to_s
|
|
165
|
+
to_hash.to_s
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
169
|
+
# @return [Hash] Returns the object in the form of hash
|
|
170
|
+
def to_body
|
|
171
|
+
to_hash
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Returns the object in the form of hash
|
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
|
176
|
+
def to_hash(downcase: false)
|
|
177
|
+
hash = {}
|
|
178
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
179
|
+
value = self.send(attr)
|
|
180
|
+
next if value.nil?
|
|
181
|
+
key = downcase ? attr : param
|
|
182
|
+
hash[key] = _to_hash(value, downcase: downcase)
|
|
183
|
+
end
|
|
184
|
+
hash
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Returns the object in the form of hash with snake_case
|
|
188
|
+
def to_attributes
|
|
189
|
+
to_hash(downcase: true)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Outputs non-array value in the form of hash
|
|
193
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
194
|
+
# @param [Object] value Any valid value
|
|
195
|
+
# @return [Hash] Returns the value in the form of hash
|
|
196
|
+
def _to_hash(value, downcase: false)
|
|
197
|
+
if value.is_a?(Array)
|
|
198
|
+
value.map do |v|
|
|
199
|
+
v.to_hash(downcase: downcase)
|
|
200
|
+
end
|
|
201
|
+
elsif value.is_a?(Hash)
|
|
202
|
+
{}.tap do |hash|
|
|
203
|
+
value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
|
|
204
|
+
end
|
|
205
|
+
elsif value.respond_to? :to_hash
|
|
206
|
+
value.to_hash(downcase: downcase)
|
|
207
|
+
else
|
|
208
|
+
value
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def parse_date(datestring)
|
|
213
|
+
if datestring.include?('Date')
|
|
214
|
+
date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
|
|
215
|
+
original, date, timezone = *date_pattern.match(datestring)
|
|
216
|
+
date = (date.to_i / 1000)
|
|
217
|
+
Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
|
|
218
|
+
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
|
|
219
|
+
Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
220
|
+
else # handle date 'types' for small subset of payroll API's
|
|
221
|
+
Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
@@ -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
|