/// <summary> /// Generates a secured and public API Key from a query parameters and an optional user token identifying the current user /// </summary> /// <param name="privateApiKey">Your private API Key</param> /// <param name="query">The query parameters applied to the query (used as security)</param> /// <param name="userToken">An optional token identifying the current user</param> /// <returns></returns> public string GenerateSecuredApiKey(String privateApiKey, Query query, String userToken = null) { if (userToken != null) { query.SetUserToken(userToken); } string queryStr = query.GetQueryString(); byte[] content = System.Text.Encoding.UTF8.GetBytes(string.Format("{0}{1}", Hmac(privateApiKey, queryStr), queryStr)); return(System.Convert.ToBase64String(content)); }
/// <summary> /// Search inside the index. /// </summary> /// <param name="q">The query.</param> public Task <JObject> SearchAsync(Query q) { string paramsString = q.GetQueryString(); if (paramsString.Length > 0) { Dictionary <string, object> body = new Dictionary <string, object>(); body["params"] = paramsString; return(_client.ExecuteRequest(AlgoliaClient.callType.Search, "POST", string.Format("/1/indexes/{0}/query", _urlIndexName), body)); } else { return(_client.ExecuteRequest(AlgoliaClient.callType.Search, "GET", string.Format("/1/indexes/{0}", _urlIndexName))); } }
/// <summary> /// Generates a secured and public API Key from a query parameters and an optional user token identifying the current user /// </summary> /// <param name="privateApiKey">Your private API Key</param> /// <param name="query">The query parameters applied to the query (used as security)</param> /// <param name="userToken">An optional token identifying the current user</param> /// <returns></returns> public string GenerateSecuredApiKey(String privateApiKey, Query query, String userToken = null) { return GenerateSecuredApiKey(privateApiKey, query.GetQueryString(), userToken); }
/// <summary> /// Generates a secured and public API Key from a query parameters and an optional user token identifying the current user /// </summary> /// <param name="privateApiKey">Your private API Key</param> /// <param name="query">The query parameters applied to the query (used as security)</param> /// <param name="userToken">An optional token identifying the current user</param> /// <returns></returns> public string GenerateSecuredApiKey(String privateApiKey, Query query, String userToken = null) { return(GenerateSecuredApiKey(privateApiKey, query.GetQueryString(), userToken)); }
/// <summary> /// Generates a secured and public API Key from a query parameters and an optional user token identifying the current user /// </summary> /// <param name="privateApiKey">Your private API Key</param> /// <param name="query">The query parameters applied to the query (used as security)</param> /// <param name="userToken">An optional token identifying the current user</param> /// <returns></returns> public string GenerateSecuredApiKey(String privateApiKey, Query query, String userToken = null) { if (userToken != null) query.SetUserToken(userToken); string queryStr = query.GetQueryString(); byte[] content = System.Text.Encoding.UTF8.GetBytes(string.Format("{0}{1}", Hmac(privateApiKey, queryStr), queryStr)); return System.Convert.ToBase64String(content); }
/// <summary> /// Browse all index contents. /// </summary> /// <param name="q">The query parameters for the browse.</param> /// <param name="cursor">The cursor to start the browse can be empty.</param> public Task <JObject> BrowseFromAsync(Query q, string cursor) { string cursorParam = ""; if (cursor != null && cursor.Length > 0) { cursorParam = string.Format("&cursor={0}", cursor); } return(_client.ExecuteRequest(AlgoliaClient.callType.Read, "GET", string.Format("/1/indexes/{0}/browse?{1}{2}", _urlIndexName, q.GetQueryString(), cursorParam))); }