public void WhenInvalidApKey_ThenThrowExceptionForbidden()
            {
                var request = new StickerPackByIdRequest(ApiKeys.Invalid);

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

                Assert.That(ex.HttpStatusCode, Is.EqualTo(ApiStatusCodes.Forbidden));
            }
            public async Task WhenStickerPackExists_ThenReturnStickerPack()
            {
                var request = new StickerPackByIdRequest(ApiKeys.Valid)
                {
                    PackId = ExistingStickerPackId
                };

                var response = await _sut.GetStickerPackByIdAsync(request);

                Assert.That(response.StickerPack.Id, Is.EqualTo(ExistingStickerPackId));
            }
 public Uri Create(StickerPackByIdRequest request)
 {
     return(request.AddUriParams(new Uri(_settings.BaseUrl).SetPath(@"v1/stickers/packs/" + request.PackId)));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns the metadata for an individual sticker pack.
        /// </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 <StickerPackByIdResponse> GetStickerPackByIdAsync(StickerPackByIdRequest request, CancellationToken cancellationToken = default)
        {
            var uri = _uriFactory.Create(request);

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