Class: Algolia::PersonalizationClient
- Inherits:
-
Object
- Object
- Algolia::PersonalizationClient
- Defined in:
- lib/algolia/api/personalization_client.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Class Method Summary collapse
Instance Method Summary collapse
- #add_user_agent_segment(segment, version = nil) ⇒ Object
- #custom_delete(path, parameters = nil, request_options = {}) ⇒ Object
-
#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
The response.
- #custom_get(path, parameters = nil, request_options = {}) ⇒ Object
-
#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
The response.
- #custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
-
#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
The response.
- #custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
-
#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
The response.
-
#delete_user_profile(user_token, request_options = {}) ⇒ DeleteUserProfileResponse
Deletes a user profile.
-
#delete_user_profile_with_http_info(user_token, request_options = {}) ⇒ Http::Response
Deletes a user profile.
-
#get_personalization_strategy(request_options = {}) ⇒ PersonalizationStrategyParams
Retrieves the current personalization strategy.
-
#get_personalization_strategy_with_http_info(request_options = {}) ⇒ Http::Response
Retrieves the current personalization strategy.
-
#get_user_token_profile(user_token, request_options = {}) ⇒ GetUserTokenResponse
Retrieves a user profile and their affinities for different facets.
-
#get_user_token_profile_with_http_info(user_token, request_options = {}) ⇒ Http::Response
Retrieves a user profile and their affinities for different facets.
-
#initialize(config = nil) ⇒ PersonalizationClient
constructor
A new instance of PersonalizationClient.
-
#set_client_api_key(api_key) ⇒ void
Helper method to switch the API key used to authenticate the requests.
-
#set_personalization_strategy(personalization_strategy_params, request_options = {}) ⇒ SetPersonalizationStrategyResponse
Creates a new personalization strategy.
-
#set_personalization_strategy_with_http_info(personalization_strategy_params, request_options = {}) ⇒ Http::Response
Creates a new personalization strategy.
Constructor Details
#initialize(config = nil) ⇒ PersonalizationClient
Returns a new instance of PersonalizationClient.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/algolia/api/personalization_client.rb', line 9 def initialize(config = nil) raise "`config` is missing." if config.nil? raise "`app_id` is missing." if config.app_id.nil? || config.app_id == "" raise "`api_key` is missing." if config.api_key.nil? || config.api_key == "" if config.connect_timeout.nil? config.connect_timeout = 2000 end if config.read_timeout.nil? config.read_timeout = 5000 end if config.write_timeout.nil? config.write_timeout = 30000 end @api_client = Algolia::ApiClient.new(config) end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
7 8 9 |
# File 'lib/algolia/api/personalization_client.rb', line 7 def api_client @api_client end |
Class Method Details
.create(app_id, api_key, region = nil, opts = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/algolia/api/personalization_client.rb', line 29 def self.create(app_id, api_key, region = nil, opts = {}) hosts = [] regions = ["eu", "us"] if region.is_a?(Hash) && (opts.nil? || opts.empty?) opts = region region = nil end if region.nil? || !region.is_a?(String) || !regions.include?(region) raise "`region` is required and must be one of the following: #{regions.join(", ")}" end hosts << Transport::StatefulHost.new( "personalization.{region}.algolia.com".sub("{region}", region), accept: CallType::READ | CallType::WRITE ) config = Algolia::Configuration.new(app_id, api_key, hosts, "Personalization", opts) new(config) end |
.create_with_config(config) ⇒ Object
52 53 54 |
# File 'lib/algolia/api/personalization_client.rb', line 52 def self.create_with_config(config) new(config) end |
Instance Method Details
#add_user_agent_segment(segment, version = nil) ⇒ Object
66 67 68 69 70 |
# File 'lib/algolia/api/personalization_client.rb', line 66 def add_user_agent_segment(segment, version = nil) @api_client.config.add_user_agent_segment(segment, version) self end |
#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object
114 115 116 117 |
# File 'lib/algolia/api/personalization_client.rb', line 114 def custom_delete(path, parameters = nil, = {}) response = custom_delete_with_http_info(path, parameters, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Returns the response.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/algolia/api/personalization_client.rb', line 78 def custom_delete_with_http_info(path, parameters = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_delete`." end # verify the required parameter 'path' is not empty if @api_client.config.client_side_validation && path.empty? raise ArgumentError, "Parameter `path` is required when calling `custom_delete`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"PersonalizationClient.custom_delete", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:DELETE, path, ) end |
#custom_get(path, parameters = nil, request_options = {}) ⇒ Object
161 162 163 164 |
# File 'lib/algolia/api/personalization_client.rb', line 161 def custom_get(path, parameters = nil, = {}) response = custom_get_with_http_info(path, parameters, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response
Returns the response.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/algolia/api/personalization_client.rb', line 125 def custom_get_with_http_info(path, parameters = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_get`." end # verify the required parameter 'path' is not empty if @api_client.config.client_side_validation && path.empty? raise ArgumentError, "Parameter `path` is required when calling `custom_get`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"PersonalizationClient.custom_get", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:GET, path, ) end |
#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
210 211 212 213 |
# File 'lib/algolia/api/personalization_client.rb', line 210 def custom_post(path, parameters = nil, body = nil, = {}) response = custom_post_with_http_info(path, parameters, body, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Returns the response.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/algolia/api/personalization_client.rb', line 173 def custom_post_with_http_info(path, parameters = nil, body = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_post`." end # verify the required parameter 'path' is not empty if @api_client.config.client_side_validation && path.empty? raise ArgumentError, "Parameter `path` is required when calling `custom_post`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(body) = .merge( :operation => :"PersonalizationClient.custom_post", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:POST, path, ) end |
#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object
259 260 261 262 |
# File 'lib/algolia/api/personalization_client.rb', line 259 def custom_put(path, parameters = nil, body = nil, = {}) response = custom_put_with_http_info(path, parameters, body, ) @api_client.deserialize(response.body, [:debug_return_type] || "Object") end |
#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response
Returns the response.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/algolia/api/personalization_client.rb', line 222 def custom_put_with_http_info(path, parameters = nil, body = nil, = {}) # verify the required parameter 'path' is set if @api_client.config.client_side_validation && path.nil? raise ArgumentError, "Parameter `path` is required when calling `custom_put`." end # verify the required parameter 'path' is not empty if @api_client.config.client_side_validation && path.empty? raise ArgumentError, "Parameter `path` is required when calling `custom_put`." end path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(body) = .merge( :operation => :"PersonalizationClient.custom_put", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:PUT, path, ) end |
#delete_user_profile(user_token, request_options = {}) ⇒ DeleteUserProfileResponse
Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
Required API Key ACLs:
- recommendation
307 308 309 310 311 312 313 |
# File 'lib/algolia/api/personalization_client.rb', line 307 def delete_user_profile(user_token, = {}) response = delete_user_profile_with_http_info(user_token, ) @api_client.deserialize( response.body, [:debug_return_type] || "Personalization::DeleteUserProfileResponse" ) end |
#delete_user_profile_with_http_info(user_token, request_options = {}) ⇒ Http::Response
Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
Required API Key ACLs:
- recommendation
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/algolia/api/personalization_client.rb', line 271 def delete_user_profile_with_http_info(user_token, = {}) # verify the required parameter 'user_token' is set if @api_client.config.client_side_validation && user_token.nil? raise ArgumentError, "Parameter `user_token` is required when calling `delete_user_profile`." end # verify the required parameter 'user_token' is not empty if @api_client.config.client_side_validation && user_token.empty? raise ArgumentError, "Parameter `user_token` is required when calling `delete_user_profile`." end path = "/1/profiles/{userToken}".sub("{" + "userToken" + "}", Transport.encode_uri(user_token.to_s)) query_params = {} query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"PersonalizationClient.delete_user_profile", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:DELETE, path, ) end |
#get_personalization_strategy(request_options = {}) ⇒ PersonalizationStrategyParams
Retrieves the current personalization strategy.
Required API Key ACLs:
- recommendation
347 348 349 350 351 352 353 |
# File 'lib/algolia/api/personalization_client.rb', line 347 def get_personalization_strategy( = {}) response = get_personalization_strategy_with_http_info() @api_client.deserialize( response.body, [:debug_return_type] || "Personalization::PersonalizationStrategyParams" ) end |
#get_personalization_strategy_with_http_info(request_options = {}) ⇒ Http::Response
Retrieves the current personalization strategy.
Required API Key ACLs:
- recommendation
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/algolia/api/personalization_client.rb', line 321 def get_personalization_strategy_with_http_info( = {}) path = "/1/strategies/personalization" query_params = {} query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"PersonalizationClient.get_personalization_strategy", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:GET, path, ) end |
#get_user_token_profile(user_token, request_options = {}) ⇒ GetUserTokenResponse
Retrieves a user profile and their affinities for different facets.
Required API Key ACLs:
- recommendation
401 402 403 404 405 406 407 |
# File 'lib/algolia/api/personalization_client.rb', line 401 def get_user_token_profile(user_token, = {}) response = get_user_token_profile_with_http_info(user_token, ) @api_client.deserialize( response.body, [:debug_return_type] || "Personalization::GetUserTokenResponse" ) end |
#get_user_token_profile_with_http_info(user_token, request_options = {}) ⇒ Http::Response
Retrieves a user profile and their affinities for different facets.
Required API Key ACLs:
- recommendation
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/algolia/api/personalization_client.rb', line 362 def get_user_token_profile_with_http_info(user_token, = {}) # verify the required parameter 'user_token' is set if @api_client.config.client_side_validation && user_token.nil? raise ArgumentError, "Parameter `user_token` is required when calling `get_user_token_profile`." end # verify the required parameter 'user_token' is not empty if @api_client.config.client_side_validation && user_token.empty? raise ArgumentError, "Parameter `user_token` is required when calling `get_user_token_profile`." end path = "/1/profiles/personalization/{userToken}".sub( "{" + "userToken" + "}", Transport.encode_uri(user_token.to_s) ) query_params = {} query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] = .merge( :operation => :"PersonalizationClient.get_user_token_profile", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:GET, path, ) end |
#set_client_api_key(api_key) ⇒ void
This method returns an undefined value.
Helper method to switch the API key used to authenticate the requests.
60 61 62 63 64 |
# File 'lib/algolia/api/personalization_client.rb', line 60 def set_client_api_key(api_key) @api_client.set_client_api_key(api_key) self end |
#set_personalization_strategy(personalization_strategy_params, request_options = {}) ⇒ SetPersonalizationStrategyResponse
Creates a new personalization strategy.
Required API Key ACLs:
- recommendation
451 452 453 454 455 456 457 |
# File 'lib/algolia/api/personalization_client.rb', line 451 def set_personalization_strategy(personalization_strategy_params, = {}) response = set_personalization_strategy_with_http_info(personalization_strategy_params, ) @api_client.deserialize( response.body, [:debug_return_type] || "Personalization::SetPersonalizationStrategyResponse" ) end |
#set_personalization_strategy_with_http_info(personalization_strategy_params, request_options = {}) ⇒ Http::Response
Creates a new personalization strategy.
Required API Key ACLs:
- recommendation
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/algolia/api/personalization_client.rb', line 416 def set_personalization_strategy_with_http_info(personalization_strategy_params, = {}) # verify the required parameter 'personalization_strategy_params' is set if @api_client.config.client_side_validation && personalization_strategy_params.nil? raise( ArgumentError, "Parameter `personalization_strategy_params` is required when calling `set_personalization_strategy`." ) end path = "/1/strategies/personalization" query_params = {} query_params = query_params.merge([:query_params]) unless [:query_params].nil? header_params = {} header_params = header_params.merge([:header_params]) unless [:header_params].nil? post_body = [:debug_body] || @api_client.object_to_http_body(personalization_strategy_params) = .merge( :operation => :"PersonalizationClient.set_personalization_strategy", :header_params => header_params, :query_params => query_params, :body => post_body, :use_read_transporter => false ) @api_client.call_api(:POST, path, ) end |