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,344 @@
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 ClientCredentialsTokenResponse
20
+ attr_accessor :access_token
21
+
22
+ attr_accessor :expires_in
23
+
24
+ attr_accessor :hub_id
25
+
26
+ attr_accessor :id_token
27
+
28
+ attr_accessor :scopes
29
+
30
+ attr_accessor :token_type
31
+
32
+ attr_accessor :token_use
33
+
34
+ attr_accessor :user_id
35
+
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'access_token' => :'access_token',
62
+ :'expires_in' => :'expires_in',
63
+ :'hub_id' => :'hub_id',
64
+ :'id_token' => :'id_token',
65
+ :'scopes' => :'scopes',
66
+ :'token_type' => :'token_type',
67
+ :'token_use' => :'token_use',
68
+ :'user_id' => :'user_id'
69
+ }
70
+ end
71
+
72
+ # Returns all the JSON keys this model knows about
73
+ def self.acceptable_attributes
74
+ attribute_map.values
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'access_token' => :'String',
81
+ :'expires_in' => :'Integer',
82
+ :'hub_id' => :'Integer',
83
+ :'id_token' => :'String',
84
+ :'scopes' => :'Array<String>',
85
+ :'token_type' => :'String',
86
+ :'token_use' => :'String',
87
+ :'user_id' => :'Integer'
88
+ }
89
+ end
90
+
91
+ # List of attributes with nullable: true
92
+ def self.openapi_nullable
93
+ Set.new([
94
+ ])
95
+ end
96
+
97
+ # Initializes the object
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ def initialize(attributes = {})
100
+ if (!attributes.is_a?(Hash))
101
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Oauth::V3::ClientCredentialsTokenResponse` initialize method"
102
+ end
103
+
104
+ # check to see if the attribute exists and convert string to symbol for hash key
105
+ attributes = attributes.each_with_object({}) { |(k, v), h|
106
+ if (!self.class.attribute_map.key?(k.to_sym))
107
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Oauth::V3::ClientCredentialsTokenResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
108
+ end
109
+ h[k.to_sym] = v
110
+ }
111
+
112
+ if attributes.key?(:'access_token')
113
+ self.access_token = attributes[:'access_token']
114
+ end
115
+
116
+ if attributes.key?(:'expires_in')
117
+ self.expires_in = attributes[:'expires_in']
118
+ end
119
+
120
+ if attributes.key?(:'hub_id')
121
+ self.hub_id = attributes[:'hub_id']
122
+ end
123
+
124
+ if attributes.key?(:'id_token')
125
+ self.id_token = attributes[:'id_token']
126
+ end
127
+
128
+ if attributes.key?(:'scopes')
129
+ if (value = attributes[:'scopes']).is_a?(Array)
130
+ self.scopes = value
131
+ end
132
+ end
133
+
134
+ if attributes.key?(:'token_type')
135
+ self.token_type = attributes[:'token_type']
136
+ end
137
+
138
+ if attributes.key?(:'token_use')
139
+ self.token_use = attributes[:'token_use']
140
+ else
141
+ self.token_use = 'client_credentials'
142
+ end
143
+
144
+ if attributes.key?(:'user_id')
145
+ self.user_id = attributes[:'user_id']
146
+ end
147
+ end
148
+
149
+ # Show invalid properties with the reasons. Usually used together with valid?
150
+ # @return Array for valid properties with the reasons
151
+ def list_invalid_properties
152
+ invalid_properties = Array.new
153
+ if @access_token.nil?
154
+ invalid_properties.push('invalid value for "access_token", access_token cannot be nil.')
155
+ end
156
+
157
+ if @expires_in.nil?
158
+ invalid_properties.push('invalid value for "expires_in", expires_in cannot be nil.')
159
+ end
160
+
161
+ if @token_type.nil?
162
+ invalid_properties.push('invalid value for "token_type", token_type cannot be nil.')
163
+ end
164
+
165
+ if @token_use.nil?
166
+ invalid_properties.push('invalid value for "token_use", token_use cannot be nil.')
167
+ end
168
+
169
+ invalid_properties
170
+ end
171
+
172
+ # Check to see if the all the properties in the model are valid
173
+ # @return true if the model is valid
174
+ def valid?
175
+ return false if @access_token.nil?
176
+ return false if @expires_in.nil?
177
+ return false if @token_type.nil?
178
+ return false if @token_use.nil?
179
+ token_use_validator = EnumAttributeValidator.new('String', ["client_credentials"])
180
+ return false unless token_use_validator.valid?(@token_use)
181
+ true
182
+ end
183
+
184
+ # Custom attribute writer method checking allowed values (enum).
185
+ # @param [Object] token_use Object to be assigned
186
+ def token_use=(token_use)
187
+ validator = EnumAttributeValidator.new('String', ["client_credentials"])
188
+ unless validator.valid?(token_use)
189
+ fail ArgumentError, "invalid value for \"token_use\", must be one of #{validator.allowable_values}."
190
+ end
191
+ @token_use = token_use
192
+ end
193
+
194
+ # Checks equality by comparing each attribute.
195
+ # @param [Object] Object to be compared
196
+ def ==(o)
197
+ return true if self.equal?(o)
198
+ self.class == o.class &&
199
+ access_token == o.access_token &&
200
+ expires_in == o.expires_in &&
201
+ hub_id == o.hub_id &&
202
+ id_token == o.id_token &&
203
+ scopes == o.scopes &&
204
+ token_type == o.token_type &&
205
+ token_use == o.token_use &&
206
+ user_id == o.user_id
207
+ end
208
+
209
+ # @see the `==` method
210
+ # @param [Object] Object to be compared
211
+ def eql?(o)
212
+ self == o
213
+ end
214
+
215
+ # Calculates hash code according to all attributes.
216
+ # @return [Integer] Hash code
217
+ def hash
218
+ [access_token, expires_in, hub_id, id_token, scopes, token_type, token_use, user_id].hash
219
+ end
220
+
221
+ # Builds the object from hash
222
+ # @param [Hash] attributes Model attributes in the form of hash
223
+ # @return [Object] Returns the model itself
224
+ def self.build_from_hash(attributes)
225
+ new.build_from_hash(attributes)
226
+ end
227
+
228
+ # Builds the object from hash
229
+ # @param [Hash] attributes Model attributes in the form of hash
230
+ # @return [Object] Returns the model itself
231
+ def build_from_hash(attributes)
232
+ return nil unless attributes.is_a?(Hash)
233
+ attributes = attributes.transform_keys(&:to_sym)
234
+ self.class.openapi_types.each_pair do |key, type|
235
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
236
+ self.send("#{key}=", nil)
237
+ elsif type =~ /\AArray<(.*)>/i
238
+ # check to ensure the input is an array given that the attribute
239
+ # is documented as an array but the input is not
240
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
241
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
242
+ end
243
+ elsif !attributes[self.class.attribute_map[key]].nil?
244
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
245
+ end
246
+ end
247
+
248
+ self
249
+ end
250
+
251
+ # Deserializes the data based on type
252
+ # @param string type Data type
253
+ # @param string value Value to be deserialized
254
+ # @return [Object] Deserialized data
255
+ def _deserialize(type, value)
256
+ case type.to_sym
257
+ when :Time
258
+ Time.parse(value)
259
+ when :Date
260
+ Date.parse(value)
261
+ when :String
262
+ value.to_s
263
+ when :Integer
264
+ value.to_i
265
+ when :Float
266
+ value.to_f
267
+ when :Boolean
268
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
269
+ true
270
+ else
271
+ false
272
+ end
273
+ when :Object
274
+ # generic object (usually a Hash), return directly
275
+ value
276
+ when /\AArray<(?<inner_type>.+)>\z/
277
+ inner_type = Regexp.last_match[:inner_type]
278
+ value.map { |v| _deserialize(inner_type, v) }
279
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
280
+ k_type = Regexp.last_match[:k_type]
281
+ v_type = Regexp.last_match[:v_type]
282
+ {}.tap do |hash|
283
+ value.each do |k, v|
284
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
285
+ end
286
+ end
287
+ else # model
288
+ # models (e.g. Pet) or oneOf
289
+ klass = Hubspot::Oauth::V3.const_get(type)
290
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
291
+ end
292
+ end
293
+
294
+ # Returns the string representation of the object
295
+ # @return [String] String presentation of the object
296
+ def to_s
297
+ to_hash.to_s
298
+ end
299
+
300
+ # to_body is an alias to to_hash (backward compatibility)
301
+ # @return [Hash] Returns the object in the form of hash
302
+ def to_body
303
+ to_hash
304
+ end
305
+
306
+ # Returns the object in the form of hash
307
+ # @return [Hash] Returns the object in the form of hash
308
+ def to_hash
309
+ hash = {}
310
+ self.class.attribute_map.each_pair do |attr, param|
311
+ value = self.send(attr)
312
+ if value.nil?
313
+ is_nullable = self.class.openapi_nullable.include?(attr)
314
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
315
+ end
316
+
317
+ hash[param] = _to_hash(value)
318
+ end
319
+ hash
320
+ end
321
+
322
+ # Outputs non-array value in the form of hash
323
+ # For object, use to_hash. Otherwise, just return the value
324
+ # @param [Object] value Any valid value
325
+ # @return [Hash] Returns the value in the form of hash
326
+ def _to_hash(value)
327
+ if value.is_a?(Array)
328
+ value.compact.map { |v| _to_hash(v) }
329
+ elsif value.is_a?(Hash)
330
+ {}.tap do |hash|
331
+ value.each { |k, v| hash[k] = _to_hash(v) }
332
+ end
333
+ elsif value.respond_to? :to_hash
334
+ value.to_hash
335
+ else
336
+ value
337
+ end
338
+ end
339
+
340
+ end
341
+
342
+ end
343
+ end
344
+ end
@@ -0,0 +1,306 @@
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
+ # Represents an error response returned by the API when an operation fails. This component is used in various endpoints to provide detailed information about the error encountered.
20
+ class Error
21
+ # The error category
22
+ attr_accessor :category
23
+
24
+ # Context about the error condition
25
+ attr_accessor :context
26
+
27
+ # A unique identifier for the request. Include this value with any error reports or support tickets
28
+ attr_accessor :correlation_id
29
+
30
+ # further information about the error
31
+ attr_accessor :errors
32
+
33
+ # A map of link names to associated URIs containing documentation about the error or recommended remediation steps
34
+ attr_accessor :links
35
+
36
+ # A human readable message describing the error along with remediation steps where appropriate
37
+ attr_accessor :message
38
+
39
+ # A specific category that contains more specific detail about the error
40
+ attr_accessor :sub_category
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'category' => :'category',
46
+ :'context' => :'context',
47
+ :'correlation_id' => :'correlationId',
48
+ :'errors' => :'errors',
49
+ :'links' => :'links',
50
+ :'message' => :'message',
51
+ :'sub_category' => :'subCategory'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'category' => :'String',
64
+ :'context' => :'Hash<String, Array<String>>',
65
+ :'correlation_id' => :'String',
66
+ :'errors' => :'Array<ErrorDetail>',
67
+ :'links' => :'Hash<String, String>',
68
+ :'message' => :'String',
69
+ :'sub_category' => :'String'
70
+ }
71
+ end
72
+
73
+ # List of attributes with nullable: true
74
+ def self.openapi_nullable
75
+ Set.new([
76
+ ])
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ if (!attributes.is_a?(Hash))
83
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Oauth::V3::Error` initialize method"
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ attributes = attributes.each_with_object({}) { |(k, v), h|
88
+ if (!self.class.attribute_map.key?(k.to_sym))
89
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Oauth::V3::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
90
+ end
91
+ h[k.to_sym] = v
92
+ }
93
+
94
+ if attributes.key?(:'category')
95
+ self.category = attributes[:'category']
96
+ end
97
+
98
+ if attributes.key?(:'context')
99
+ if (value = attributes[:'context']).is_a?(Hash)
100
+ self.context = value
101
+ end
102
+ end
103
+
104
+ if attributes.key?(:'correlation_id')
105
+ self.correlation_id = attributes[:'correlation_id']
106
+ end
107
+
108
+ if attributes.key?(:'errors')
109
+ if (value = attributes[:'errors']).is_a?(Array)
110
+ self.errors = value
111
+ end
112
+ end
113
+
114
+ if attributes.key?(:'links')
115
+ if (value = attributes[:'links']).is_a?(Hash)
116
+ self.links = value
117
+ end
118
+ end
119
+
120
+ if attributes.key?(:'message')
121
+ self.message = attributes[:'message']
122
+ end
123
+
124
+ if attributes.key?(:'sub_category')
125
+ self.sub_category = attributes[:'sub_category']
126
+ end
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properties with the reasons
131
+ def list_invalid_properties
132
+ invalid_properties = Array.new
133
+ if @category.nil?
134
+ invalid_properties.push('invalid value for "category", category cannot be nil.')
135
+ end
136
+
137
+ if @correlation_id.nil?
138
+ invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
139
+ end
140
+
141
+ if @message.nil?
142
+ invalid_properties.push('invalid value for "message", message cannot be nil.')
143
+ end
144
+
145
+ invalid_properties
146
+ end
147
+
148
+ # Check to see if the all the properties in the model are valid
149
+ # @return true if the model is valid
150
+ def valid?
151
+ return false if @category.nil?
152
+ return false if @correlation_id.nil?
153
+ return false if @message.nil?
154
+ true
155
+ end
156
+
157
+ # Checks equality by comparing each attribute.
158
+ # @param [Object] Object to be compared
159
+ def ==(o)
160
+ return true if self.equal?(o)
161
+ self.class == o.class &&
162
+ category == o.category &&
163
+ context == o.context &&
164
+ correlation_id == o.correlation_id &&
165
+ errors == o.errors &&
166
+ links == o.links &&
167
+ message == o.message &&
168
+ sub_category == o.sub_category
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Integer] Hash code
179
+ def hash
180
+ [category, context, correlation_id, errors, links, message, sub_category].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def self.build_from_hash(attributes)
187
+ new.build_from_hash(attributes)
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def build_from_hash(attributes)
194
+ return nil unless attributes.is_a?(Hash)
195
+ attributes = attributes.transform_keys(&:to_sym)
196
+ self.class.openapi_types.each_pair do |key, type|
197
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
198
+ self.send("#{key}=", nil)
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
203
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
204
+ end
205
+ elsif !attributes[self.class.attribute_map[key]].nil?
206
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
207
+ end
208
+ end
209
+
210
+ self
211
+ end
212
+
213
+ # Deserializes the data based on type
214
+ # @param string type Data type
215
+ # @param string value Value to be deserialized
216
+ # @return [Object] Deserialized data
217
+ def _deserialize(type, value)
218
+ case type.to_sym
219
+ when :Time
220
+ Time.parse(value)
221
+ when :Date
222
+ Date.parse(value)
223
+ when :String
224
+ value.to_s
225
+ when :Integer
226
+ value.to_i
227
+ when :Float
228
+ value.to_f
229
+ when :Boolean
230
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
231
+ true
232
+ else
233
+ false
234
+ end
235
+ when :Object
236
+ # generic object (usually a Hash), return directly
237
+ value
238
+ when /\AArray<(?<inner_type>.+)>\z/
239
+ inner_type = Regexp.last_match[:inner_type]
240
+ value.map { |v| _deserialize(inner_type, v) }
241
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
242
+ k_type = Regexp.last_match[:k_type]
243
+ v_type = Regexp.last_match[:v_type]
244
+ {}.tap do |hash|
245
+ value.each do |k, v|
246
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
247
+ end
248
+ end
249
+ else # model
250
+ # models (e.g. Pet) or oneOf
251
+ klass = Hubspot::Oauth::V3.const_get(type)
252
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ if value.nil?
275
+ is_nullable = self.class.openapi_nullable.include?(attr)
276
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
277
+ end
278
+
279
+ hash[param] = _to_hash(value)
280
+ end
281
+ hash
282
+ end
283
+
284
+ # Outputs non-array value in the form of hash
285
+ # For object, use to_hash. Otherwise, just return the value
286
+ # @param [Object] value Any valid value
287
+ # @return [Hash] Returns the value in the form of hash
288
+ def _to_hash(value)
289
+ if value.is_a?(Array)
290
+ value.compact.map { |v| _to_hash(v) }
291
+ elsif value.is_a?(Hash)
292
+ {}.tap do |hash|
293
+ value.each { |k, v| hash[k] = _to_hash(v) }
294
+ end
295
+ elsif value.respond_to? :to_hash
296
+ value.to_hash
297
+ else
298
+ value
299
+ end
300
+ end
301
+
302
+ end
303
+
304
+ end
305
+ end
306
+ end