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,294 @@
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
+ module Hubspot
14
+ module Oauth
15
+ module V3
16
+ class Configuration
17
+ # Defines url scheme
18
+ attr_accessor :scheme
19
+
20
+ # Defines url host
21
+ attr_accessor :host
22
+
23
+ # Defines url base path
24
+ attr_accessor :base_path
25
+
26
+ # Define server configuration index
27
+ attr_accessor :server_index
28
+
29
+ # Define server operation configuration index
30
+ attr_accessor :server_operation_index
31
+
32
+ # Default server variables
33
+ attr_accessor :server_variables
34
+
35
+ # Default server operation variables
36
+ attr_accessor :server_operation_variables
37
+
38
+ # Defines API keys used with API Key authentications.
39
+ #
40
+ # @return [Hash] key: parameter name, value: parameter value (API key)
41
+ #
42
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
43
+ # config.api_key['api_key'] = 'xxx'
44
+ attr_accessor :api_key
45
+
46
+ # Defines API key prefixes used with API Key authentications.
47
+ #
48
+ # @return [Hash] key: parameter name, value: API key prefix
49
+ #
50
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
51
+ # config.api_key_prefix['api_key'] = 'Token'
52
+ attr_accessor :api_key_prefix
53
+
54
+ # Defines the username used with HTTP basic authentication.
55
+ #
56
+ # @return [String]
57
+ attr_accessor :username
58
+
59
+ # Defines the password used with HTTP basic authentication.
60
+ #
61
+ # @return [String]
62
+ attr_accessor :password
63
+
64
+ # Defines the access token (Bearer) used with OAuth2.
65
+ attr_accessor :access_token
66
+
67
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
68
+ # details will be logged with `logger.debug` (see the `logger` attribute).
69
+ # Default to false.
70
+ #
71
+ # @return [true, false]
72
+ attr_accessor :debugging
73
+
74
+ # Defines the logger used for debugging.
75
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
76
+ #
77
+ # @return [#debug]
78
+ attr_accessor :logger
79
+
80
+ # Defines the temporary folder to store downloaded files
81
+ # (for API endpoints that have file response).
82
+ # Default to use `Tempfile`.
83
+ #
84
+ # @return [String]
85
+ attr_accessor :temp_folder_path
86
+
87
+ # The time limit for HTTP request in seconds.
88
+ # Default to 0 (never times out).
89
+ attr_accessor :timeout
90
+
91
+ # Set this to false to skip client side validation in the operation.
92
+ # Default to true.
93
+ # @return [true, false]
94
+ attr_accessor :client_side_validation
95
+
96
+ ### TLS/SSL setting
97
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
98
+ # Default to true.
99
+ #
100
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
101
+ #
102
+ # @return [true, false]
103
+ attr_accessor :verify_ssl
104
+
105
+ ### TLS/SSL setting
106
+ # Set this to false to skip verifying SSL host name
107
+ # Default to true.
108
+ #
109
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
110
+ #
111
+ # @return [true, false]
112
+ attr_accessor :verify_ssl_host
113
+
114
+ ### TLS/SSL setting
115
+ # Set this to customize the certificate file to verify the peer.
116
+ #
117
+ # @return [String] the path to the certificate file
118
+ #
119
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
120
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
121
+ attr_accessor :ssl_ca_cert
122
+
123
+ ### TLS/SSL setting
124
+ # Client certificate file (for client certificate)
125
+ attr_accessor :cert_file
126
+
127
+ ### TLS/SSL setting
128
+ # Client private key file (for client certificate)
129
+ attr_accessor :key_file
130
+
131
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
132
+ # Default to nil.
133
+ #
134
+ # @see The params_encoding option of Ethon. Related source code:
135
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
136
+ attr_accessor :params_encoding
137
+
138
+
139
+ attr_accessor :inject_format
140
+
141
+ attr_accessor :force_ending_format
142
+
143
+ attr_accessor :error_handler
144
+
145
+ def initialize
146
+ @scheme = 'https'
147
+ @host = 'api.hubapi.com'
148
+ @base_path = ''
149
+ @server_index = 0
150
+ @server_operation_index = {}
151
+ @server_variables = {}
152
+ @server_operation_variables = {}
153
+ @api_key = {}
154
+ @api_key_prefix = {}
155
+ @client_side_validation = true
156
+ @verify_ssl = true
157
+ @verify_ssl_host = true
158
+ @cert_file = nil
159
+ @key_file = nil
160
+ @timeout = 0
161
+ @params_encoding = nil
162
+ @debugging = false
163
+ @inject_format = false
164
+ @force_ending_format = false
165
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
166
+ # error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
167
+ @error_handler = {}
168
+
169
+ yield(self) if block_given?
170
+ end
171
+
172
+ # The default Configuration object.
173
+ def self.default
174
+ @@default ||= Configuration.new
175
+ end
176
+
177
+ def configure
178
+ yield(self) if block_given?
179
+ end
180
+
181
+ def scheme=(scheme)
182
+ # remove :// from scheme
183
+ @scheme = scheme.sub(/:\/\//, '')
184
+ end
185
+
186
+ def host=(host)
187
+ # remove http(s):// and anything after a slash
188
+ @host = host.sub(/https?:\/\//, '').split('/').first
189
+ end
190
+
191
+ def base_path=(base_path)
192
+ # Add leading and trailing slashes to base_path
193
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
194
+ @base_path = '' if @base_path == '/'
195
+ end
196
+
197
+ # Returns base URL for specified operation based on server settings
198
+ def base_url(operation = nil)
199
+ index = server_operation_index.fetch(operation, server_index)
200
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
201
+
202
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
203
+ end
204
+
205
+ # Gets API key (with prefix if set).
206
+ # @param [String] param_name the parameter name of API key auth
207
+ def api_key_with_prefix(param_name, param_alias = nil)
208
+ key = @api_key[param_name]
209
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
210
+ if @api_key_prefix[param_name]
211
+ "#{@api_key_prefix[param_name]} #{key}"
212
+ else
213
+ key
214
+ end
215
+ end
216
+
217
+ # Gets Basic Auth token string
218
+ def basic_auth_token
219
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
220
+ end
221
+
222
+ # Returns Auth Settings hash for api client.
223
+ def auth_settings
224
+ {
225
+ 'developer_hapikey' =>
226
+ {
227
+ type: 'api_key',
228
+ in: 'query',
229
+ key: 'hapikey',
230
+ value: api_key_with_prefix('developer_hapikey')
231
+ },
232
+ 'oauth2' =>
233
+ {
234
+ type: 'oauth2',
235
+ in: 'header',
236
+ key: 'Authorization',
237
+ value: "Bearer #{access_token}"
238
+ },
239
+ }
240
+ end
241
+
242
+ # Returns an array of Server setting
243
+ def server_settings
244
+ [
245
+ {
246
+ url: "https://api.hubapi.com",
247
+ description: "No description provided",
248
+ }
249
+ ]
250
+ end
251
+
252
+ def operation_server_settings
253
+ {
254
+ }
255
+ end
256
+
257
+ # Returns URL based on server settings
258
+ #
259
+ # @param index array index of the server settings
260
+ # @param variables hash of variable and the corresponding value
261
+ def server_url(index, variables = {}, servers = nil)
262
+ servers = server_settings if servers == nil
263
+
264
+ # check array index out of bound
265
+ if (index < 0 || index >= servers.size)
266
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
267
+ end
268
+
269
+ server = servers[index]
270
+ url = server[:url]
271
+
272
+ return url unless server.key? :variables
273
+
274
+ # go through variable and assign a value
275
+ server[:variables].each do |name, variable|
276
+ if variables.key?(name)
277
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
278
+ url.gsub! "{" + name.to_s + "}", variables[name]
279
+ else
280
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
281
+ end
282
+ else
283
+ # use default value
284
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
285
+ end
286
+ end
287
+
288
+ url
289
+ end
290
+
291
+ end
292
+ end
293
+ end
294
+ end
@@ -0,0 +1,358 @@
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 AccessTokenResponse
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 :refresh_token
29
+
30
+ attr_accessor :scopes
31
+
32
+ attr_accessor :token_type
33
+
34
+ attr_accessor :token_use
35
+
36
+ attr_accessor :user_id
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
+ :'access_token' => :'access_token',
64
+ :'expires_in' => :'expires_in',
65
+ :'hub_id' => :'hub_id',
66
+ :'id_token' => :'id_token',
67
+ :'refresh_token' => :'refresh_token',
68
+ :'scopes' => :'scopes',
69
+ :'token_type' => :'token_type',
70
+ :'token_use' => :'token_use',
71
+ :'user_id' => :'user_id'
72
+ }
73
+ end
74
+
75
+ # Returns all the JSON keys this model knows about
76
+ def self.acceptable_attributes
77
+ attribute_map.values
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.openapi_types
82
+ {
83
+ :'access_token' => :'String',
84
+ :'expires_in' => :'Integer',
85
+ :'hub_id' => :'Integer',
86
+ :'id_token' => :'String',
87
+ :'refresh_token' => :'String',
88
+ :'scopes' => :'Array<String>',
89
+ :'token_type' => :'String',
90
+ :'token_use' => :'String',
91
+ :'user_id' => :'Integer'
92
+ }
93
+ end
94
+
95
+ # List of attributes with nullable: true
96
+ def self.openapi_nullable
97
+ Set.new([
98
+ ])
99
+ end
100
+
101
+ # Initializes the object
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ def initialize(attributes = {})
104
+ if (!attributes.is_a?(Hash))
105
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Oauth::V3::AccessTokenResponse` initialize method"
106
+ end
107
+
108
+ # check to see if the attribute exists and convert string to symbol for hash key
109
+ attributes = attributes.each_with_object({}) { |(k, v), h|
110
+ if (!self.class.attribute_map.key?(k.to_sym))
111
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Oauth::V3::AccessTokenResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
112
+ end
113
+ h[k.to_sym] = v
114
+ }
115
+
116
+ if attributes.key?(:'access_token')
117
+ self.access_token = attributes[:'access_token']
118
+ end
119
+
120
+ if attributes.key?(:'expires_in')
121
+ self.expires_in = attributes[:'expires_in']
122
+ end
123
+
124
+ if attributes.key?(:'hub_id')
125
+ self.hub_id = attributes[:'hub_id']
126
+ end
127
+
128
+ if attributes.key?(:'id_token')
129
+ self.id_token = attributes[:'id_token']
130
+ end
131
+
132
+ if attributes.key?(:'refresh_token')
133
+ self.refresh_token = attributes[:'refresh_token']
134
+ end
135
+
136
+ if attributes.key?(:'scopes')
137
+ if (value = attributes[:'scopes']).is_a?(Array)
138
+ self.scopes = value
139
+ end
140
+ end
141
+
142
+ if attributes.key?(:'token_type')
143
+ self.token_type = attributes[:'token_type']
144
+ end
145
+
146
+ if attributes.key?(:'token_use')
147
+ self.token_use = attributes[:'token_use']
148
+ else
149
+ self.token_use = 'access_token'
150
+ end
151
+
152
+ if attributes.key?(:'user_id')
153
+ self.user_id = attributes[:'user_id']
154
+ end
155
+ end
156
+
157
+ # Show invalid properties with the reasons. Usually used together with valid?
158
+ # @return Array for valid properties with the reasons
159
+ def list_invalid_properties
160
+ invalid_properties = Array.new
161
+ if @access_token.nil?
162
+ invalid_properties.push('invalid value for "access_token", access_token cannot be nil.')
163
+ end
164
+
165
+ if @expires_in.nil?
166
+ invalid_properties.push('invalid value for "expires_in", expires_in cannot be nil.')
167
+ end
168
+
169
+ if @refresh_token.nil?
170
+ invalid_properties.push('invalid value for "refresh_token", refresh_token cannot be nil.')
171
+ end
172
+
173
+ if @token_type.nil?
174
+ invalid_properties.push('invalid value for "token_type", token_type cannot be nil.')
175
+ end
176
+
177
+ if @token_use.nil?
178
+ invalid_properties.push('invalid value for "token_use", token_use cannot be nil.')
179
+ end
180
+
181
+ invalid_properties
182
+ end
183
+
184
+ # Check to see if the all the properties in the model are valid
185
+ # @return true if the model is valid
186
+ def valid?
187
+ return false if @access_token.nil?
188
+ return false if @expires_in.nil?
189
+ return false if @refresh_token.nil?
190
+ return false if @token_type.nil?
191
+ return false if @token_use.nil?
192
+ token_use_validator = EnumAttributeValidator.new('String', ["access_token"])
193
+ return false unless token_use_validator.valid?(@token_use)
194
+ true
195
+ end
196
+
197
+ # Custom attribute writer method checking allowed values (enum).
198
+ # @param [Object] token_use Object to be assigned
199
+ def token_use=(token_use)
200
+ validator = EnumAttributeValidator.new('String', ["access_token"])
201
+ unless validator.valid?(token_use)
202
+ fail ArgumentError, "invalid value for \"token_use\", must be one of #{validator.allowable_values}."
203
+ end
204
+ @token_use = token_use
205
+ end
206
+
207
+ # Checks equality by comparing each attribute.
208
+ # @param [Object] Object to be compared
209
+ def ==(o)
210
+ return true if self.equal?(o)
211
+ self.class == o.class &&
212
+ access_token == o.access_token &&
213
+ expires_in == o.expires_in &&
214
+ hub_id == o.hub_id &&
215
+ id_token == o.id_token &&
216
+ refresh_token == o.refresh_token &&
217
+ scopes == o.scopes &&
218
+ token_type == o.token_type &&
219
+ token_use == o.token_use &&
220
+ user_id == o.user_id
221
+ end
222
+
223
+ # @see the `==` method
224
+ # @param [Object] Object to be compared
225
+ def eql?(o)
226
+ self == o
227
+ end
228
+
229
+ # Calculates hash code according to all attributes.
230
+ # @return [Integer] Hash code
231
+ def hash
232
+ [access_token, expires_in, hub_id, id_token, refresh_token, scopes, token_type, token_use, user_id].hash
233
+ end
234
+
235
+ # Builds the object from hash
236
+ # @param [Hash] attributes Model attributes in the form of hash
237
+ # @return [Object] Returns the model itself
238
+ def self.build_from_hash(attributes)
239
+ new.build_from_hash(attributes)
240
+ end
241
+
242
+ # Builds the object from hash
243
+ # @param [Hash] attributes Model attributes in the form of hash
244
+ # @return [Object] Returns the model itself
245
+ def build_from_hash(attributes)
246
+ return nil unless attributes.is_a?(Hash)
247
+ attributes = attributes.transform_keys(&:to_sym)
248
+ self.class.openapi_types.each_pair do |key, type|
249
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
250
+ self.send("#{key}=", nil)
251
+ elsif type =~ /\AArray<(.*)>/i
252
+ # check to ensure the input is an array given that the attribute
253
+ # is documented as an array but the input is not
254
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
255
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
256
+ end
257
+ elsif !attributes[self.class.attribute_map[key]].nil?
258
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
259
+ end
260
+ end
261
+
262
+ self
263
+ end
264
+
265
+ # Deserializes the data based on type
266
+ # @param string type Data type
267
+ # @param string value Value to be deserialized
268
+ # @return [Object] Deserialized data
269
+ def _deserialize(type, value)
270
+ case type.to_sym
271
+ when :Time
272
+ Time.parse(value)
273
+ when :Date
274
+ Date.parse(value)
275
+ when :String
276
+ value.to_s
277
+ when :Integer
278
+ value.to_i
279
+ when :Float
280
+ value.to_f
281
+ when :Boolean
282
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
283
+ true
284
+ else
285
+ false
286
+ end
287
+ when :Object
288
+ # generic object (usually a Hash), return directly
289
+ value
290
+ when /\AArray<(?<inner_type>.+)>\z/
291
+ inner_type = Regexp.last_match[:inner_type]
292
+ value.map { |v| _deserialize(inner_type, v) }
293
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
294
+ k_type = Regexp.last_match[:k_type]
295
+ v_type = Regexp.last_match[:v_type]
296
+ {}.tap do |hash|
297
+ value.each do |k, v|
298
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
299
+ end
300
+ end
301
+ else # model
302
+ # models (e.g. Pet) or oneOf
303
+ klass = Hubspot::Oauth::V3.const_get(type)
304
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
305
+ end
306
+ end
307
+
308
+ # Returns the string representation of the object
309
+ # @return [String] String presentation of the object
310
+ def to_s
311
+ to_hash.to_s
312
+ end
313
+
314
+ # to_body is an alias to to_hash (backward compatibility)
315
+ # @return [Hash] Returns the object in the form of hash
316
+ def to_body
317
+ to_hash
318
+ end
319
+
320
+ # Returns the object in the form of hash
321
+ # @return [Hash] Returns the object in the form of hash
322
+ def to_hash
323
+ hash = {}
324
+ self.class.attribute_map.each_pair do |attr, param|
325
+ value = self.send(attr)
326
+ if value.nil?
327
+ is_nullable = self.class.openapi_nullable.include?(attr)
328
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
329
+ end
330
+
331
+ hash[param] = _to_hash(value)
332
+ end
333
+ hash
334
+ end
335
+
336
+ # Outputs non-array value in the form of hash
337
+ # For object, use to_hash. Otherwise, just return the value
338
+ # @param [Object] value Any valid value
339
+ # @return [Hash] Returns the value in the form of hash
340
+ def _to_hash(value)
341
+ if value.is_a?(Array)
342
+ value.compact.map { |v| _to_hash(v) }
343
+ elsif value.is_a?(Hash)
344
+ {}.tap do |hash|
345
+ value.each { |k, v| hash[k] = _to_hash(v) }
346
+ end
347
+ elsif value.respond_to? :to_hash
348
+ value.to_hash
349
+ else
350
+ value
351
+ end
352
+ end
353
+
354
+ end
355
+
356
+ end
357
+ end
358
+ end