Chilas.Algolia.Analytics/AnalyticsClient.cs
/// <summary>
/// Get Analytics features for Search
/// Consult Algolia Analytics documentation for supported options
/// </summary>
/// <param name="options"></param>
/// <param name="searchType"></param>
/// <returns></returns>
Get Analytics features for Search
Consult Algolia Analytics documentation for supported options
Get Analytics features for Search Consult Algolia Analytics documentation for supported options
public async Task<JObject> GetAnalyticsForSearch(AnalyticsOptions options, AnalyticSearchType searchType)
        {
            var requestUrl = $"{AnalyticsApiUrl}/searches/{Indices}/{GetSearchResource(searchType)}";
            if (!string.IsNullOrWhiteSpace(options.RequestString))
                requestUrl += options.RequestString;
            var httpRequest = await _httpClient.GetAsync(requestUrl);
            var httpResponse = string.Empty;
            if (httpRequest.IsSuccessStatusCode)
            {
                 httpResponse = await httpRequest.Content.ReadAsStringAsync();
            }
            else
            {
                switch (httpRequest.StatusCode)
                {
                    case HttpStatusCode.Forbidden:
                        throw new AlgoliaException("Invalid Incredentials.");
                    case HttpStatusCode.InternalServerError:
                        throw new AlgoliaException("An Internal server error occurred.");
                }
            }
            var result = JObject.Parse(httpResponse);
            return result;
        }
public async Task < JObject > GetAnalyticsForSearch ( AnalyticsOptions options , AnalyticSearchType searchType ) { var requestUrl = $" { AnalyticsApiUrl } /searches/ { Indices } / { GetSearchResource ( searchType ) } " ; if ( ! string . IsNullOrWhiteSpace ( options . RequestString ) ) requestUrl += options . RequestString ; var httpRequest = await _httpClient . GetAsync ( requestUrl ) ; var httpResponse = string . Empty ; if ( httpRequest . IsSuccessStatusCode ) { httpResponse = await httpRequest . Content . ReadAsStringAsync ( ) ; } else { switch ( httpRequest . StatusCode ) { case HttpStatusCode . Forbidden : throw new AlgoliaException ( " " ) ; case HttpStatusCode . InternalServerError : throw new AlgoliaException ( " " ) ; } } var result = JObject . Parse ( httpResponse ) ; return result ; }
Get Analytics features for Search
Consult Algolia Analytics documentation for supported options
Get Analytics features for Search Consult Algolia Analytics documentation for supported options
None
options
AnalyticsOptions
None
searchType
AnalyticSearchType
None