public void WhenInvalidApKey_ThenThrowExceptionForbidden() { var request = new StickerRandomRequest(ApiKeys.Invalid); var ex = Assert.ThrowsAsync <GiphyApiClientException>(() => _sut.GetRandomStickerAsync(request)); Assert.That(ex.HttpStatusCode, Is.EqualTo(ApiStatusCodes.Forbidden)); }
public async Task WhenQueryIsSuccessful_WithNoTag_ThenReturnResults() { var request = new StickerRandomRequest(ApiKeys.Valid); var response = await _sut.GetRandomStickerAsync(request); Assert.That(response.Gif, Is.Not.Null); }
public Uri Create(StickerRandomRequest request) { return(request.AddUriParams(new Uri(_settings.BaseUrl).SetPath(@"v1/stickers/random"))); }
/// <summary> /// Returns a random sticker, limited by tag. /// Excluding the tag parameter will return a random Sticker from the GIPHY catalog. /// </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 <StickerRandomResponse> GetRandomStickerAsync(StickerRandomRequest request, CancellationToken cancellationToken = default) { var uri = _uriFactory.Create(request); return(await GetAsync <StickerRandomResponse>(uri, cancellationToken)); }