xero-ruby 3.14.0 → 3.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,230 @@
1
+ =begin
2
+ #Xero AppStore API
3
+
4
+ #These endpoints are for Xero Partners to interact with the App Store Billing platform
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::AppStore
16
+ # Response to get usage record
17
+ require 'bigdecimal'
18
+
19
+ class UsageRecordsList
20
+ # A collection of usage records
21
+ attr_accessor :usage_records
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'usage_records' => :'usageRecords'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.openapi_types
32
+ {
33
+ :'usage_records' => :'Array<UsageRecord>'
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::AppStore::UsageRecordsList` 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::AppStore::UsageRecordsList`. 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?(:'usage_records')
53
+ if (value = attributes[:'usage_records']).is_a?(Array)
54
+ self.usage_records = 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
+ if @usage_records.nil?
64
+ invalid_properties.push('invalid value for "usage_records", usage_records cannot be nil.')
65
+ end
66
+
67
+ invalid_properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ return false if @usage_records.nil?
74
+ true
75
+ end
76
+
77
+ # Checks equality by comparing each attribute.
78
+ # @param [Object] Object to be compared
79
+ def ==(o)
80
+ return true if self.equal?(o)
81
+ self.class == o.class &&
82
+ usage_records == o.usage_records
83
+ end
84
+
85
+ # @see the `==` method
86
+ # @param [Object] Object to be compared
87
+ def eql?(o)
88
+ self == o
89
+ end
90
+
91
+ # Calculates hash code according to all attributes.
92
+ # @return [Integer] Hash code
93
+ def hash
94
+ [usage_records].hash
95
+ end
96
+
97
+ # Builds the object from hash
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ # @return [Object] Returns the model itself
100
+ def self.build_from_hash(attributes)
101
+ new.build_from_hash(attributes)
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def build_from_hash(attributes)
108
+ return nil unless attributes.is_a?(Hash)
109
+ self.class.openapi_types.each_pair do |key, type|
110
+ if type =~ /\AArray<(.*)>/i
111
+ # check to ensure the input is an array given that the attribute
112
+ # is documented as an array but the input is not
113
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
114
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
115
+ end
116
+ elsif !attributes[self.class.attribute_map[key]].nil?
117
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
118
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
119
+ end
120
+
121
+ self
122
+ end
123
+
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
128
+ def _deserialize(type, value)
129
+ case type.to_sym
130
+ when :DateTime
131
+ DateTime.parse(parse_date(value))
132
+ when :Date
133
+ Date.parse(parse_date(value))
134
+ when :String
135
+ value.to_s
136
+ when :Integer
137
+ value.to_i
138
+ when :Float
139
+ value.to_f
140
+ when :BigDecimal
141
+ BigDecimal(value.to_s)
142
+ when :Boolean
143
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
144
+ true
145
+ else
146
+ false
147
+ end
148
+ when :Object
149
+ # generic object (usually a Hash), return directly
150
+ value
151
+ when /\AArray<(?<inner_type>.+)>\z/
152
+ inner_type = Regexp.last_match[:inner_type]
153
+ value.map { |v| _deserialize(inner_type, v) }
154
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
+ k_type = Regexp.last_match[:k_type]
156
+ v_type = Regexp.last_match[:v_type]
157
+ {}.tap do |hash|
158
+ value.each do |k, v|
159
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
+ end
161
+ end
162
+ else # model
163
+ XeroRuby::AppStore.const_get(type).build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash(downcase: false)
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ next if value.nil?
186
+ key = downcase ? attr : param
187
+ hash[key] = _to_hash(value, downcase: downcase)
188
+ end
189
+ hash
190
+ end
191
+
192
+ # Returns the object in the form of hash with snake_case
193
+ def to_attributes
194
+ to_hash(downcase: true)
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value, downcase: false)
202
+ if value.is_a?(Array)
203
+ value.map do |v|
204
+ v.to_hash(downcase: downcase)
205
+ end
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.map { |k, v| hash[k] = _to_hash(v, downcase: downcase) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash(downcase: downcase)
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ def parse_date(datestring)
218
+ if datestring.include?('Date')
219
+ date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\//
220
+ original, date, timezone = *date_pattern.match(datestring)
221
+ date = (date.to_i / 1000)
222
+ Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s
223
+ elsif /(\d\d\d\d)-(\d\d)/.match(datestring) # handles dates w/out Days: YYYY-MM*-DD
224
+ Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
225
+ else # handle date 'types' for small subset of payroll API's
226
+ Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
227
+ end
228
+ end
229
+ end
230
+ 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: 2.30.2
10
+ The version of the XeroOpenAPI document: 2.31.0
11
11
  =end
12
12
 
13
13
  module XeroRuby
14
- VERSION = '3.14.0'
14
+ VERSION = '3.15.0'
15
15
  end
data/lib/xero-ruby.rb CHANGED
@@ -72,12 +72,16 @@ require 'xero-ruby/models/finance/trial_balance_movement'
72
72
  require 'xero-ruby/models/finance/trial_balance_response'
73
73
  require 'xero-ruby/models/finance/user_activities_response'
74
74
  require 'xero-ruby/models/finance/user_response'
75
+ require 'xero-ruby/models/app_store/create_usage_record'
75
76
  require 'xero-ruby/models/app_store/plan'
76
77
  require 'xero-ruby/models/app_store/price'
77
78
  require 'xero-ruby/models/app_store/problem_details'
78
79
  require 'xero-ruby/models/app_store/product'
79
80
  require 'xero-ruby/models/app_store/subscription'
80
81
  require 'xero-ruby/models/app_store/subscription_item'
82
+ require 'xero-ruby/models/app_store/update_usage_record'
83
+ require 'xero-ruby/models/app_store/usage_record'
84
+ require 'xero-ruby/models/app_store/usage_records_list'
81
85
  require 'xero-ruby/models/payroll_uk/account'
82
86
  require 'xero-ruby/models/payroll_uk/accounts'
83
87
  require 'xero-ruby/models/payroll_uk/address'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xero-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.0
4
+ version: 3.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xero API Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-07 00:00:00.000000000 Z
11
+ date: 2022-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -244,12 +244,16 @@ files:
244
244
  - lib/xero-ruby/models/accounting/user.rb
245
245
  - lib/xero-ruby/models/accounting/users.rb
246
246
  - lib/xero-ruby/models/accounting/validation_error.rb
247
+ - lib/xero-ruby/models/app_store/create_usage_record.rb
247
248
  - lib/xero-ruby/models/app_store/plan.rb
248
249
  - lib/xero-ruby/models/app_store/price.rb
249
250
  - lib/xero-ruby/models/app_store/problem_details.rb
250
251
  - lib/xero-ruby/models/app_store/product.rb
251
252
  - lib/xero-ruby/models/app_store/subscription.rb
252
253
  - lib/xero-ruby/models/app_store/subscription_item.rb
254
+ - lib/xero-ruby/models/app_store/update_usage_record.rb
255
+ - lib/xero-ruby/models/app_store/usage_record.rb
256
+ - lib/xero-ruby/models/app_store/usage_records_list.rb
253
257
  - lib/xero-ruby/models/assets/asset.rb
254
258
  - lib/xero-ruby/models/assets/asset_status.rb
255
259
  - lib/xero-ruby/models/assets/asset_status_query_param.rb