private SearchRequest CreateSearchRequest(HttpStatusCode httpStatusCode, GetStatusImageOptions options)
        {
            var request = new SearchRequest(_giphyApiKey)
            {
                Query  = httpStatusCode.Name,
                Limit  = 1,
                Rating = new Rating(RatingType.ParentalGuidance)
            };

            if (options?.UseCodeInQuery != null)
            {
                request.Query = httpStatusCode.Code + " " + request.Query;
            }

            if (options?.QueryPrefix != null)
            {
                request.Query = options.QueryPrefix + " " + request.Query;
            }

            if (options != null && options.UseRandomFromSet)
            {
                request.Limit = LimitForRandom;
            }

            return(request);
        }
        public async Task <GetStatusImageResponse> GetStatusImageAsync(int statusCode, GetStatusImageOptions options = null, CancellationToken cancellationToken = default)
        {
            var httpStatusCode = HttpStatusCode.CreateFromCode(statusCode);

            var giphyClient = new GiphyApiClient(_httpClient, new GiphyApiClientSettings());


            var response = await giphyClient.SearchAsync(CreateSearchRequest(httpStatusCode, options), cancellationToken);

            GifResponse gif;

            if (options != null && options.UseRandomFromSet)
            {
                var rnd    = new Random();
                int number = rnd.Next(0, LimitForRandom);

                gif = response.Gifs.Skip(number).Take(1).Single();
            }
            else
            {
                gif = response.Gifs.SingleOrDefault();
            }


            var imageUrl = GetSmallestImage(gif);

            return(new GetStatusImageResponse
            {
                Code = httpStatusCode.Code,
                Name = httpStatusCode.Name,
                ImageUrl = imageUrl
            });
        }