hubspot-api-client 20.0.0 → 20.1.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.
@@ -0,0 +1,396 @@
1
+ =begin
2
+ #Auth Oauth
3
+
4
+ #Basepom for all HubSpot Projects
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Hubspot
17
+ module Oauth
18
+ module V3
19
+ class PublicRefreshTokenInfoResponse
20
+ attr_accessor :active
21
+
22
+ attr_accessor :app_id
23
+
24
+ attr_accessor :client_id
25
+
26
+ attr_accessor :hub_domain
27
+
28
+ attr_accessor :hub_id
29
+
30
+ attr_accessor :scopes
31
+
32
+ attr_accessor :token
33
+
34
+ attr_accessor :token_type
35
+
36
+ attr_accessor :token_use
37
+
38
+ attr_accessor :user
39
+
40
+ attr_accessor :user_id
41
+
42
+ class EnumAttributeValidator
43
+ attr_reader :datatype
44
+ attr_reader :allowable_values
45
+
46
+ def initialize(datatype, allowable_values)
47
+ @allowable_values = allowable_values.map do |value|
48
+ case datatype.to_s
49
+ when /Integer/i
50
+ value.to_i
51
+ when /Float/i
52
+ value.to_f
53
+ else
54
+ value
55
+ end
56
+ end
57
+ end
58
+
59
+ def valid?(value)
60
+ !value || allowable_values.include?(value)
61
+ end
62
+ end
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'active' => :'active',
68
+ :'app_id' => :'app_id',
69
+ :'client_id' => :'client_id',
70
+ :'hub_domain' => :'hub_domain',
71
+ :'hub_id' => :'hub_id',
72
+ :'scopes' => :'scopes',
73
+ :'token' => :'token',
74
+ :'token_type' => :'token_type',
75
+ :'token_use' => :'token_use',
76
+ :'user' => :'user',
77
+ :'user_id' => :'user_id'
78
+ }
79
+ end
80
+
81
+ # Returns all the JSON keys this model knows about
82
+ def self.acceptable_attributes
83
+ attribute_map.values
84
+ end
85
+
86
+ # Attribute type mapping.
87
+ def self.openapi_types
88
+ {
89
+ :'active' => :'Boolean',
90
+ :'app_id' => :'Integer',
91
+ :'client_id' => :'String',
92
+ :'hub_domain' => :'String',
93
+ :'hub_id' => :'Integer',
94
+ :'scopes' => :'Array<String>',
95
+ :'token' => :'String',
96
+ :'token_type' => :'String',
97
+ :'token_use' => :'String',
98
+ :'user' => :'String',
99
+ :'user_id' => :'Integer'
100
+ }
101
+ end
102
+
103
+ # List of attributes with nullable: true
104
+ def self.openapi_nullable
105
+ Set.new([
106
+ ])
107
+ end
108
+
109
+ # Initializes the object
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ def initialize(attributes = {})
112
+ if (!attributes.is_a?(Hash))
113
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Oauth::V3::PublicRefreshTokenInfoResponse` initialize method"
114
+ end
115
+
116
+ # check to see if the attribute exists and convert string to symbol for hash key
117
+ attributes = attributes.each_with_object({}) { |(k, v), h|
118
+ if (!self.class.attribute_map.key?(k.to_sym))
119
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Oauth::V3::PublicRefreshTokenInfoResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
120
+ end
121
+ h[k.to_sym] = v
122
+ }
123
+
124
+ if attributes.key?(:'active')
125
+ self.active = attributes[:'active']
126
+ end
127
+
128
+ if attributes.key?(:'app_id')
129
+ self.app_id = attributes[:'app_id']
130
+ end
131
+
132
+ if attributes.key?(:'client_id')
133
+ self.client_id = attributes[:'client_id']
134
+ end
135
+
136
+ if attributes.key?(:'hub_domain')
137
+ self.hub_domain = attributes[:'hub_domain']
138
+ end
139
+
140
+ if attributes.key?(:'hub_id')
141
+ self.hub_id = attributes[:'hub_id']
142
+ end
143
+
144
+ if attributes.key?(:'scopes')
145
+ if (value = attributes[:'scopes']).is_a?(Array)
146
+ self.scopes = value
147
+ end
148
+ end
149
+
150
+ if attributes.key?(:'token')
151
+ self.token = attributes[:'token']
152
+ end
153
+
154
+ if attributes.key?(:'token_type')
155
+ self.token_type = attributes[:'token_type']
156
+ end
157
+
158
+ if attributes.key?(:'token_use')
159
+ self.token_use = attributes[:'token_use']
160
+ else
161
+ self.token_use = 'refresh_token'
162
+ end
163
+
164
+ if attributes.key?(:'user')
165
+ self.user = attributes[:'user']
166
+ end
167
+
168
+ if attributes.key?(:'user_id')
169
+ self.user_id = attributes[:'user_id']
170
+ end
171
+ end
172
+
173
+ # Show invalid properties with the reasons. Usually used together with valid?
174
+ # @return Array for valid properties with the reasons
175
+ def list_invalid_properties
176
+ invalid_properties = Array.new
177
+ if @active.nil?
178
+ invalid_properties.push('invalid value for "active", active cannot be nil.')
179
+ end
180
+
181
+ if @app_id.nil?
182
+ invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
183
+ end
184
+
185
+ if @client_id.nil?
186
+ invalid_properties.push('invalid value for "client_id", client_id cannot be nil.')
187
+ end
188
+
189
+ if @hub_id.nil?
190
+ invalid_properties.push('invalid value for "hub_id", hub_id cannot be nil.')
191
+ end
192
+
193
+ if @scopes.nil?
194
+ invalid_properties.push('invalid value for "scopes", scopes cannot be nil.')
195
+ end
196
+
197
+ if @token.nil?
198
+ invalid_properties.push('invalid value for "token", token cannot be nil.')
199
+ end
200
+
201
+ if @token_type.nil?
202
+ invalid_properties.push('invalid value for "token_type", token_type cannot be nil.')
203
+ end
204
+
205
+ if @token_use.nil?
206
+ invalid_properties.push('invalid value for "token_use", token_use cannot be nil.')
207
+ end
208
+
209
+ if @user_id.nil?
210
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
211
+ end
212
+
213
+ invalid_properties
214
+ end
215
+
216
+ # Check to see if the all the properties in the model are valid
217
+ # @return true if the model is valid
218
+ def valid?
219
+ return false if @active.nil?
220
+ return false if @app_id.nil?
221
+ return false if @client_id.nil?
222
+ return false if @hub_id.nil?
223
+ return false if @scopes.nil?
224
+ return false if @token.nil?
225
+ return false if @token_type.nil?
226
+ return false if @token_use.nil?
227
+ token_use_validator = EnumAttributeValidator.new('String', ["refresh_token"])
228
+ return false unless token_use_validator.valid?(@token_use)
229
+ return false if @user_id.nil?
230
+ true
231
+ end
232
+
233
+ # Custom attribute writer method checking allowed values (enum).
234
+ # @param [Object] token_use Object to be assigned
235
+ def token_use=(token_use)
236
+ validator = EnumAttributeValidator.new('String', ["refresh_token"])
237
+ unless validator.valid?(token_use)
238
+ fail ArgumentError, "invalid value for \"token_use\", must be one of #{validator.allowable_values}."
239
+ end
240
+ @token_use = token_use
241
+ end
242
+
243
+ # Checks equality by comparing each attribute.
244
+ # @param [Object] Object to be compared
245
+ def ==(o)
246
+ return true if self.equal?(o)
247
+ self.class == o.class &&
248
+ active == o.active &&
249
+ app_id == o.app_id &&
250
+ client_id == o.client_id &&
251
+ hub_domain == o.hub_domain &&
252
+ hub_id == o.hub_id &&
253
+ scopes == o.scopes &&
254
+ token == o.token &&
255
+ token_type == o.token_type &&
256
+ token_use == o.token_use &&
257
+ user == o.user &&
258
+ user_id == o.user_id
259
+ end
260
+
261
+ # @see the `==` method
262
+ # @param [Object] Object to be compared
263
+ def eql?(o)
264
+ self == o
265
+ end
266
+
267
+ # Calculates hash code according to all attributes.
268
+ # @return [Integer] Hash code
269
+ def hash
270
+ [active, app_id, client_id, hub_domain, hub_id, scopes, token, token_type, token_use, user, user_id].hash
271
+ end
272
+
273
+ # Builds the object from hash
274
+ # @param [Hash] attributes Model attributes in the form of hash
275
+ # @return [Object] Returns the model itself
276
+ def self.build_from_hash(attributes)
277
+ new.build_from_hash(attributes)
278
+ end
279
+
280
+ # Builds the object from hash
281
+ # @param [Hash] attributes Model attributes in the form of hash
282
+ # @return [Object] Returns the model itself
283
+ def build_from_hash(attributes)
284
+ return nil unless attributes.is_a?(Hash)
285
+ attributes = attributes.transform_keys(&:to_sym)
286
+ self.class.openapi_types.each_pair do |key, type|
287
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
288
+ self.send("#{key}=", nil)
289
+ elsif type =~ /\AArray<(.*)>/i
290
+ # check to ensure the input is an array given that the attribute
291
+ # is documented as an array but the input is not
292
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
293
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
294
+ end
295
+ elsif !attributes[self.class.attribute_map[key]].nil?
296
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
297
+ end
298
+ end
299
+
300
+ self
301
+ end
302
+
303
+ # Deserializes the data based on type
304
+ # @param string type Data type
305
+ # @param string value Value to be deserialized
306
+ # @return [Object] Deserialized data
307
+ def _deserialize(type, value)
308
+ case type.to_sym
309
+ when :Time
310
+ Time.parse(value)
311
+ when :Date
312
+ Date.parse(value)
313
+ when :String
314
+ value.to_s
315
+ when :Integer
316
+ value.to_i
317
+ when :Float
318
+ value.to_f
319
+ when :Boolean
320
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
321
+ true
322
+ else
323
+ false
324
+ end
325
+ when :Object
326
+ # generic object (usually a Hash), return directly
327
+ value
328
+ when /\AArray<(?<inner_type>.+)>\z/
329
+ inner_type = Regexp.last_match[:inner_type]
330
+ value.map { |v| _deserialize(inner_type, v) }
331
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
332
+ k_type = Regexp.last_match[:k_type]
333
+ v_type = Regexp.last_match[:v_type]
334
+ {}.tap do |hash|
335
+ value.each do |k, v|
336
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
337
+ end
338
+ end
339
+ else # model
340
+ # models (e.g. Pet) or oneOf
341
+ klass = Hubspot::Oauth::V3.const_get(type)
342
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
343
+ end
344
+ end
345
+
346
+ # Returns the string representation of the object
347
+ # @return [String] String presentation of the object
348
+ def to_s
349
+ to_hash.to_s
350
+ end
351
+
352
+ # to_body is an alias to to_hash (backward compatibility)
353
+ # @return [Hash] Returns the object in the form of hash
354
+ def to_body
355
+ to_hash
356
+ end
357
+
358
+ # Returns the object in the form of hash
359
+ # @return [Hash] Returns the object in the form of hash
360
+ def to_hash
361
+ hash = {}
362
+ self.class.attribute_map.each_pair do |attr, param|
363
+ value = self.send(attr)
364
+ if value.nil?
365
+ is_nullable = self.class.openapi_nullable.include?(attr)
366
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
367
+ end
368
+
369
+ hash[param] = _to_hash(value)
370
+ end
371
+ hash
372
+ end
373
+
374
+ # Outputs non-array value in the form of hash
375
+ # For object, use to_hash. Otherwise, just return the value
376
+ # @param [Object] value Any valid value
377
+ # @return [Hash] Returns the value in the form of hash
378
+ def _to_hash(value)
379
+ if value.is_a?(Array)
380
+ value.compact.map { |v| _to_hash(v) }
381
+ elsif value.is_a?(Hash)
382
+ {}.tap do |hash|
383
+ value.each { |k, v| hash[k] = _to_hash(v) }
384
+ end
385
+ elsif value.respond_to? :to_hash
386
+ value.to_hash
387
+ else
388
+ value
389
+ end
390
+ end
391
+
392
+ end
393
+
394
+ end
395
+ end
396
+ end