xero-ruby 18.3.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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xero-ruby/api/account_data_api.rb +419 -0
  3. data/lib/xero-ruby/api/feed_connections_api.rb +410 -0
  4. data/lib/xero-ruby/api_client.rb +19 -0
  5. data/lib/xero-ruby/configuration.rb +4 -0
  6. data/lib/xero-ruby/models/account_data/account.rb +351 -0
  7. data/lib/xero-ruby/models/account_data/account_balance.rb +287 -0
  8. data/lib/xero-ruby/models/account_data/account_balances_response.rb +229 -0
  9. data/lib/xero-ruby/models/account_data/account_movement.rb +347 -0
  10. data/lib/xero-ruby/models/account_data/account_movements_response.rb +229 -0
  11. data/lib/xero-ruby/models/account_data/account_transaction_line.rb +359 -0
  12. data/lib/xero-ruby/models/account_data/account_transactions_response.rb +269 -0
  13. data/lib/xero-ruby/models/account_data/account_transactions_response_pagination.rb +243 -0
  14. data/lib/xero-ruby/models/account_data/accounting_date_range.rb +242 -0
  15. data/lib/xero-ruby/models/account_data/field_problem.rb +273 -0
  16. data/lib/xero-ruby/models/account_data/gateway_problem.rb +285 -0
  17. data/lib/xero-ruby/models/account_data/ledger_decimal.rb +278 -0
  18. data/lib/xero-ruby/models/account_data/line_source.rb +273 -0
  19. data/lib/xero-ruby/models/account_data/line_tax_rate.rb +243 -0
  20. data/lib/xero-ruby/models/account_data/problem_details.rb +273 -0
  21. data/lib/xero-ruby/models/account_data/tracking_item_details.rb +257 -0
  22. data/lib/xero-ruby/models/account_data/transaction_account.rb +366 -0
  23. data/lib/xero-ruby/models/account_data/validation_problem.rb +275 -0
  24. data/lib/xero-ruby/models/accounting/budget.rb +25 -1
  25. data/lib/xero-ruby/models/accounting/budget_balance.rb +4 -39
  26. data/lib/xero-ruby/models/bankfeeds_v2/account_type.rb +36 -0
  27. data/lib/xero-ruby/models/bankfeeds_v2/bulk_feed_connection_response.rb +225 -0
  28. data/lib/xero-ruby/models/bankfeeds_v2/bulk_feed_connection_result.rb +300 -0
  29. data/lib/xero-ruby/models/bankfeeds_v2/delete_feed_connections_request.rb +229 -0
  30. data/lib/xero-ruby/models/bankfeeds_v2/existing_account_feed_connection.rb +373 -0
  31. data/lib/xero-ruby/models/bankfeeds_v2/existing_account_feed_connections_request.rb +229 -0
  32. data/lib/xero-ruby/models/bankfeeds_v2/feed_connection.rb +293 -0
  33. data/lib/xero-ruby/models/bankfeeds_v2/feed_connection_to_delete.rb +227 -0
  34. data/lib/xero-ruby/models/bankfeeds_v2/item_error.rb +358 -0
  35. data/lib/xero-ruby/models/bankfeeds_v2/new_account_feed_connection.rb +406 -0
  36. data/lib/xero-ruby/models/bankfeeds_v2/new_account_feed_connections_request.rb +229 -0
  37. data/lib/xero-ruby/models/bankfeeds_v2/paged_feed_connections.rb +234 -0
  38. data/lib/xero-ruby/models/bankfeeds_v2/pagination.rb +252 -0
  39. data/lib/xero-ruby/models/bankfeeds_v2/problem.rb +368 -0
  40. data/lib/xero-ruby/version.rb +2 -2
  41. data/lib/xero-ruby.rb +34 -0
  42. metadata +385 -351
@@ -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, unit_amount, notes].hash
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
@@ -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