Skip to content

Commit

Permalink
Merge pull request #17 from jgreywolf/155-AddDownloadProductFilter
Browse files Browse the repository at this point in the history
155 add download product filter
  • Loading branch information
ssterli2 authored Sep 24, 2019
2 parents 849bedb + 87b2d0d commit 5e0b0fe
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 0 deletions.
8 changes: 8 additions & 0 deletions GettyImages.Api/ApiRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ protected void AddComposition(Composition value)
}
}

protected void AddDownloadProduct(ProductType value)
{
if (QueryParameters.ContainsKey(Constants.DownloadProductKey))
QueryParameters[Constants.DownloadProductKey] = value;
else
QueryParameters.Add(Constants.DownloadProductKey, value);
}

protected void AddEditorialSegment(EditorialSegment value)
{
if (QueryParameters.ContainsKey(Constants.EditorialSegmentKey))
Expand Down
1 change: 1 addition & 0 deletions GettyImages.Api/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal static class Constants
public const string CompositionKey = "compositions";
public const string DateToKey = "date_to";
public const string DateFromKey = "date_from";
public const string DownloadProductKey = "download_product";
public const string EditorialSegmentKey = "editorial_segments";
public const string EditorialVideoKey = "editorial_video_types";
public const string EmbedContentOnlyKey = "embed_content_only";
Expand Down
6 changes: 6 additions & 0 deletions GettyImages.Api/Search/SearchImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public SearchImages WithComposition(Composition value)
return this;
}

public SearchImages WithDownloadProduct(ProductType value)
{
AddDownloadProduct(value);
return this;
}

public SearchImages WithEmbedContentOnly(bool value = true)
{
AddQueryParameter(Constants.EmbedContentOnlyKey, value);
Expand Down
6 changes: 6 additions & 0 deletions GettyImages.Api/Search/SearchImagesCreative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public SearchImagesCreative WithComposition(Composition value)
return this;
}

public SearchImagesCreative WithDownloadProduct(ProductType value)
{
AddDownloadProduct(value);
return this;
}

public SearchImagesCreative WithEmbedContentOnly(bool value = true)
{
AddQueryParameter(Constants.EmbedContentOnlyKey, value);
Expand Down
6 changes: 6 additions & 0 deletions GettyImages.Api/Search/SearchImagesEditorial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public SearchImagesEditorial WithComposition(Composition value)
return this;
}

public SearchImagesEditorial WithDownloadProduct(ProductType value)
{
AddDownloadProduct(value);
return this;
}

public SearchImagesEditorial WithEditorialSegment(EditorialSegment value)
{
AddEditorialSegment(value);
Expand Down
6 changes: 6 additions & 0 deletions GettyImages.Api/Search/SearchVideos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public SearchVideos WithCollectionFilterType(CollectionFilter value)
return this;
}

public SearchVideos WithDownloadProduct(ProductType value)
{
AddDownloadProduct(value);
return this;
}

public SearchVideos WithEditorialVideoType(EditorialVideo value)
{
AddEditorialVideoType(value);
Expand Down
6 changes: 6 additions & 0 deletions GettyImages.Api/Search/SearchVideosCreative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public SearchVideosCreative WithCollectionFilterType(CollectionFilter value)
return this;
}

public SearchVideosCreative WithDownloadProduct(ProductType value)
{
AddDownloadProduct(value);
return this;
}

public SearchVideosCreative WithExcludeNudity(bool value = true)
{
AddQueryParameter(Constants.Excludenudity, value);
Expand Down
6 changes: 6 additions & 0 deletions GettyImages.Api/Search/SearchVideosEditorial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public SearchVideosEditorial WithCollectionFilterType(CollectionFilter value)
return this;
}

public SearchVideosEditorial WithDownloadProduct(ProductType value)
{
AddDownloadProduct(value);
return this;
}

public SearchVideosEditorial WithEditorialVideoType(EditorialVideo value)
{
AddEditorialVideoType(value);
Expand Down
13 changes: 13 additions & 0 deletions UnitTests/Search/SearchImagesCreativeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ public void SearchForCreativeImagesWithComposition()
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("compositions=abstract%2Cheadshot");
}

[Fact]
public void SearchForCreativeImagesWithDownloadProduct()
{
var testHandler = TestUtil.CreateTestHandler();

var response = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).SearchImagesCreative()
.WithPhrase("cat").WithDownloadProduct(ProductType.Easyaccess).ExecuteAsync().Result;

testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/images/creative");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("phrase=cat");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("download_product=easyaccess");
}

[Fact]
public void SearchForCreativeImagesWithEmbedContentOnly()
{
Expand Down
13 changes: 13 additions & 0 deletions UnitTests/Search/SearchImagesEditorialTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ public void SearchForEditorialImagesWithComposition()
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("compositions=abstract%2Cheadshot");
}

[Fact]
public void SearchForEditorialImagesWithDownloadProduct()
{
var testHandler = TestUtil.CreateTestHandler();

var response = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).SearchImagesEditorial()
.WithPhrase("cat").WithDownloadProduct(ProductType.Easyaccess).ExecuteAsync().Result;

testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/images/editorial");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("phrase=cat");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("download_product=easyaccess");
}

[Fact]
public void SearchForEditorialImagesWithEditorialSegment()
{
Expand Down
13 changes: 13 additions & 0 deletions UnitTests/Search/SearchImagesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ public void SearchForBlendedImagesWithComposition()
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("compositions=abstract%2Cheadshot");
}

[Fact]
public void SearchForBlendedImagesWithDownloadProduct()
{
var testHandler = TestUtil.CreateTestHandler();

var response = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).SearchImages()
.WithPhrase("cat").WithDownloadProduct(ProductType.Easyaccess).ExecuteAsync().Result;

testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/images");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("phrase=cat");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("download_product=easyaccess");
}

[Fact]
public void SearchForBlendedImagesWithEmbedContentOnly()
{
Expand Down
13 changes: 13 additions & 0 deletions UnitTests/Search/SearchVideosCreativeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ public void SearchForCreativeVideosWithCollectionFilterType()
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("collections_filter_type=exclude");
}

[Fact]
public void SearchForCreativeVideosWithDownloadProduct()
{
var testHandler = TestUtil.CreateTestHandler();

var response = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).SearchVideosCreative()
.WithPhrase("cat").WithDownloadProduct(ProductType.Easyaccess).ExecuteAsync().Result;

testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/videos/creative");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("phrase=cat");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("download_product=easyaccess");
}

[Fact]
public void SearchForCreativeVideosWithExcludeNudity()
{
Expand Down
13 changes: 13 additions & 0 deletions UnitTests/Search/SearchVideosEditorialTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ public void SearchForEditorialVideosWithCollectionFilterType()
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("collections_filter_type=exclude");
}

[Fact]
public void SearchForEditorialVideosWithDownloadProduct()
{
var testHandler = TestUtil.CreateTestHandler();

var response = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).SearchVideosEditorial()
.WithPhrase("cat").WithDownloadProduct(ProductType.Easyaccess).ExecuteAsync().Result;

testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/videos/editorial");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("phrase=cat");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("download_product=easyaccess");
}

[Fact]
public void SearchForEditorialVideosWithEditorialVideoType()
{
Expand Down
13 changes: 13 additions & 0 deletions UnitTests/Search/SearchVideosTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ public void SearchForBlendedVideosWithCollectionFilterType()
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("collections_filter_type=exclude");
}

[Fact]
public void SearchForBlendedVideosWithDownloadProduct()
{
var testHandler = TestUtil.CreateTestHandler();

var response = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).SearchVideos()
.WithPhrase("cat").WithDownloadProduct(ProductType.Easyaccess).ExecuteAsync().Result;

testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/videos");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("phrase=cat");
testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("download_product=easyaccess");
}

[Fact]
public void SearchForBlendedVideosWithEditorialVideoType()
{
Expand Down

0 comments on commit 5e0b0fe

Please sign in to comment.