public async Task WhenQueryIsSuccessful_ThenReturnResults()
            {
                var request = new StickerTranslateRequest(ApiKeys.Valid)
                {
                    SearchTerm = "burger"
                };

                var response = await _sut.TranslateStickersAsync(request);

                Assert.That(response.Gif, Is.Not.Null);
            }
            public void WhenInvalidApKey_ThenThrowExceptionForbidden()
            {
                var request = new StickerTranslateRequest(ApiKeys.Invalid)
                {
                    SearchTerm = "burger"
                };

                var ex = Assert.ThrowsAsync <GiphyApiClientException>(() => _sut.TranslateStickersAsync(request));

                Assert.That(ex.HttpStatusCode, Is.EqualTo(ApiStatusCodes.Forbidden));
            }
 public Uri Create(StickerTranslateRequest request)
 {
     return(request.AddUriParams(new Uri(_settings.BaseUrl).SetPath(@"v1/stickers/translate")));
 }
Example #4
0
        /// <summary>
        /// The translate API draws on search, but uses the GIPHY special sauce to handle translating
        /// from one vocabulary to another. In this case, words and phrases to GIFs.
        /// </summary>
        /// <param name="request">Request object.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public async Task <StickerTranslateResponse> TranslateStickersAsync(StickerTranslateRequest request, CancellationToken cancellationToken = default)
        {
            var uri = _uriFactory.Create(request);

            return(await GetAsync <StickerTranslateResponse>(uri, cancellationToken));
        }