# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. module Algolia class PersonalizationClient attr_accessor :api_client 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 == "" @api_client = Algolia::ApiClient.new(config) end 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) create_with_config(config) end def self.create_with_config(config) new(config) end # Helper method to switch the API key used to authenticate the requests. # # @param api_key [String] the new API key to use. # @return [void] def set_client_api_key(api_key) @api_client.set_client_api_key(api_key) end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def custom_delete_with_http_info(path, parameters = nil, request_options = {}) # 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 path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] new_options = request_options.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, new_options) end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Object] def custom_delete(path, parameters = nil, request_options = {}) response = custom_delete_with_http_info(path, parameters, request_options) @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def custom_get_with_http_info(path, parameters = nil, request_options = {}) # 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 path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] new_options = request_options.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, new_options) end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Object] def custom_get(path, parameters = nil, request_options = {}) response = custom_get_with_http_info(path, parameters, request_options) @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param body [Object] Parameters to send with the custom request. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) # 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 path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] || @api_client.object_to_http_body(body) new_options = request_options.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, new_options) end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param body [Object] Parameters to send with the custom request. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Object] def custom_post(path, parameters = nil, body = nil, request_options = {}) response = custom_post_with_http_info(path, parameters, body, request_options) @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param body [Object] Parameters to send with the custom request. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) # 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 path = "/{path}".sub("{" + "path" + "}", path.to_s) query_params = {} query_params = query_params.merge(parameters) unless parameters.nil? query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] || @api_client.object_to_http_body(body) new_options = request_options.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, new_options) end # This method allow you to send requests to the Algolia REST API. # @param path [String] Path of the endpoint, anything after \"/1\" must be specified. (required) # @param parameters [Hash] Query parameters to apply to the current query. # @param body [Object] Parameters to send with the custom request. # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Object] def custom_put(path, parameters = nil, body = nil, request_options = {}) response = custom_put_with_http_info(path, parameters, body, request_options) @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object") end # 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 # @param user_token [String] Unique identifier representing a user for which to fetch the personalization profile. (required) # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def delete_user_profile_with_http_info(user_token, request_options = {}) # 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 path = "/1/profiles/{userToken}".sub("{" + "userToken" + "}", Transport.encode_uri(user_token.to_s)) query_params = {} query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] new_options = request_options.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, new_options) end # 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 # @param user_token [String] Unique identifier representing a user for which to fetch the personalization profile. (required) # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [DeleteUserProfileResponse] def delete_user_profile(user_token, request_options = {}) response = delete_user_profile_with_http_info(user_token, request_options) @api_client.deserialize( response.body, request_options[:debug_return_type] || "Personalization::DeleteUserProfileResponse" ) end # Retrieves the current personalization strategy. # # Required API Key ACLs: # - recommendation # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def get_personalization_strategy_with_http_info(request_options = {}) path = "/1/strategies/personalization" query_params = {} query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] new_options = request_options.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, new_options) end # Retrieves the current personalization strategy. # # Required API Key ACLs: # - recommendation # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [PersonalizationStrategyParams] def get_personalization_strategy(request_options = {}) response = get_personalization_strategy_with_http_info(request_options) @api_client.deserialize( response.body, request_options[:debug_return_type] || "Personalization::PersonalizationStrategyParams" ) end # Retrieves a user profile and their affinities for different facets. # # Required API Key ACLs: # - recommendation # @param user_token [String] Unique identifier representing a user for which to fetch the personalization profile. (required) # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def get_user_token_profile_with_http_info(user_token, request_options = {}) # 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 path = "/1/profiles/personalization/{userToken}".sub( "{" + "userToken" + "}", Transport.encode_uri(user_token.to_s) ) query_params = {} query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] new_options = request_options.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, new_options) end # Retrieves a user profile and their affinities for different facets. # # Required API Key ACLs: # - recommendation # @param user_token [String] Unique identifier representing a user for which to fetch the personalization profile. (required) # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [GetUserTokenResponse] def get_user_token_profile(user_token, request_options = {}) response = get_user_token_profile_with_http_info(user_token, request_options) @api_client.deserialize( response.body, request_options[:debug_return_type] || "Personalization::GetUserTokenResponse" ) end # Creates a new personalization strategy. # # Required API Key ACLs: # - recommendation # @param personalization_strategy_params [PersonalizationStrategyParams] (required) # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [Http::Response] the response def set_personalization_strategy_with_http_info(personalization_strategy_params, request_options = {}) # 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(request_options[:query_params]) unless request_options[:query_params].nil? header_params = {} header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil? post_body = request_options[:debug_body] || @api_client.object_to_http_body(personalization_strategy_params) new_options = request_options.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, new_options) end # Creates a new personalization strategy. # # Required API Key ACLs: # - recommendation # @param personalization_strategy_params [PersonalizationStrategyParams] (required) # @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional) # @return [SetPersonalizationStrategyResponse] def set_personalization_strategy(personalization_strategy_params, request_options = {}) response = set_personalization_strategy_with_http_info(personalization_strategy_params, request_options) @api_client.deserialize( response.body, request_options[:debug_return_type] || "Personalization::SetPersonalizationStrategyResponse" ) end end end