├── .idea └── .idea.GettyImages.Api │ └── .idea │ ├── .name │ ├── encodings.xml │ ├── vcs.xml │ ├── indexLayout.xml │ └── .gitignore ├── package-icon.jpg ├── nuget-add-ref.png ├── UnitTests ├── test-image.jpg ├── TestUtil.cs ├── Products │ └── ProductsTests.cs ├── Orders │ └── OrdersTests.cs ├── Countries │ └── CountriesTests.cs ├── Boards │ ├── GetBoardsByIdTests.cs │ ├── PutBoardsByIdTests.cs │ ├── GetCommentsTests.cs │ ├── DeleteBoardByIdTests.cs │ ├── PostBoardsTests.cs │ ├── PutAssetsByIdTests.cs │ ├── DeleteAssetsByIdTests.cs │ ├── DeleteCommentsByIdTests.cs │ ├── PostCommentsTests.cs │ ├── PutAssetsTests.cs │ └── DeleteAssetsTests.cs ├── Collections │ └── CollectionsTests.cs ├── AssetChanges │ ├── DeleteAssetChangesTests.cs │ ├── ChangeSetsTests.cs │ └── ChannelsTests.cs ├── Customers │ └── CustomersTests.cs ├── HeaderAndBody │ ├── TestHeadersHandler.cs │ ├── BodyTests.cs │ └── HeadersTests.cs ├── Credentials │ └── CredentialsTests.cs ├── WebHelper │ └── WebHelperTests.cs ├── UnitTests.csproj ├── AiGenerator │ ├── GetGeneratedImagesTests.cs │ ├── GetDownloadSizesTests.cs │ ├── GetGeneratedImageDownloadTests.cs │ └── GetVariationsTests.cs ├── Images │ ├── ImagesTests.cs │ ├── ImagesDownloadHistoryTests.cs │ ├── ImagesSimilarTests.cs │ └── ImagesSameSeriesTests.cs ├── Videos │ ├── VideosTests.cs │ ├── VideosDownloadHistoryTests.cs │ ├── VideosSimilarTests.cs │ └── VideosSameSeriesTests.cs ├── Events │ └── EventsTests.cs ├── AssetLicensing │ └── AcquireExtendedLicenseTests.cs ├── Usage │ └── UsageBatchesTests.cs ├── TestHandler.cs ├── Search │ ├── SearchImagesCreativeByImageTests.cs │ └── SearchVideosCreativeByImageTests.cs └── Artists │ ├── ArtistsImagesTests.cs │ └── ArtistsVideosTests.cs ├── Makefile ├── GettyImages.Api ├── Models │ ├── BoardAsset.cs │ ├── CommentRequest.cs │ ├── ReportUsageBatchRequest.cs │ ├── BoardInfo.cs │ ├── ExtendedLicense.cs │ ├── ImageGenerationsPendingResponse.cs │ ├── BoardRelationship.cs │ ├── CreativeSearchFacets.cs │ ├── LicenseModel.cs │ ├── CollectionFilter.cs │ ├── OrientationVideos.cs │ ├── GraphicalStyleFilter.cs │ ├── Artist.cs │ ├── FileType.cs │ ├── DownloadGeneratedImageReadyResponse.cs │ ├── AcquireAssetLicensesRequest.cs │ ├── EditorialSource.cs │ ├── ImageGenerationsSize.cs │ ├── ReleaseStatus.cs │ ├── AssetIdFromOrder.cs │ ├── AutoCorrections.cs │ ├── EditorialVideo.cs │ ├── SortOrderEvent.cs │ ├── CreateBoardResponse.cs │ ├── AssetUsage.cs │ ├── CreateCommentResponse.cs │ ├── DownloadAssetResponse.cs │ ├── GenerationVariationsRequest.cs │ ├── CommentPermissions.cs │ ├── GetCountriesResponse.cs │ ├── GetProductsResponse.cs │ ├── BoardCommentPermissions.cs │ ├── MinimumQuality.cs │ ├── CreativeKeyword.cs │ ├── GetCollectionsResponse.cs │ ├── GeneratedImageDownloadRequest.cs │ ├── Location.cs │ ├── Links.cs │ ├── DisplaySize.cs │ ├── Entertainment.cs │ ├── MaxDimensions.cs │ ├── RelatedSearch.cs │ ├── SpecificPeople.cs │ ├── ImageDetailLink.cs │ ├── Collaborator.cs │ ├── EditorialSegment.cs │ ├── GetAssetDownloadHistoryResponse.cs │ ├── IStockLicense.cs │ ├── NumberOfPeople.cs │ ├── OrientationImages.cs │ ├── HeroImage.cs │ ├── ReferralDestination.cs │ ├── SortOrderCreative.cs │ ├── DownloadDetails.cs │ ├── FacetFieldsCreative.cs │ ├── GetBoardsResponse.cs │ ├── GetEventsResponse.cs │ ├── SearchEventsResponse.cs │ ├── FormatAvailable.cs │ ├── ImageGenerationsMediaType.cs │ ├── AssetChangesResponse.cs │ ├── Dimensions.cs │ ├── GetDownloadsResponse.cs │ ├── GetVideosDetailsResponse.cs │ ├── AddBoardAssetsResponse.cs │ ├── AssetLicensingResponse.cs │ ├── GetCommentsResponse.cs │ ├── GetImagesDetailsResponse.cs │ ├── GraphicalStylesEditorial.cs │ ├── ReportUsageBatchResponse.cs │ ├── SearchImagesByArtistResponse.cs │ ├── SearchVideosByArtistResponse.cs │ ├── AllowedUse.cs │ ├── FacetEvent.cs │ ├── OAuthResponse.cs │ ├── SortOrderEditorial.cs │ ├── ArtistAssetSearchKeyword.cs │ ├── HeroImageDisplaySize.cs │ ├── CustomerInfoResponse.cs │ ├── AssetSearchItemDisplaySize.cs │ ├── GetPreviouslyPurchasedAssetsResponse.cs │ ├── User.cs │ ├── DownloadRequirements.cs │ ├── GraphicalStylesCreative.cs │ ├── Download.cs │ ├── GeneratedImageRedownloadRequest.cs │ ├── OverageDetails.cs │ ├── GetSimilarImagesResponse.cs │ ├── ImageGenerationsReadyResponse.cs │ ├── LocationEvent.cs │ ├── GeneratedDownloadSizesResponse.cs │ ├── OrientationImagesResponse.cs │ ├── MinimumSize.cs │ ├── OrderNotes.cs │ ├── Asset.cs │ ├── SearchEditorialImagesResponse.cs │ ├── AssetDownloadHistoryUser.cs │ ├── VideoSearchItemDisplaySize.cs │ ├── SearchCreativeImagesByImageResponse.cs │ ├── FacetFieldsEditorial.cs │ ├── SortOrderBoards.cs │ ├── Country.cs │ ├── Channel.cs │ ├── Comment.cs │ ├── Keyword.cs │ ├── SearchCreativeImagesResponse.cs │ ├── SearchEditorialVideosResponse.cs │ ├── Collection.cs │ ├── ImageGenerationsMood.cs │ ├── ChangedAssetDetail.cs │ ├── ProductType.cs │ ├── SearchFacetsResponse.cs │ ├── DownloadSize.cs │ ├── BoardPermissions.cs │ ├── ImageGenerationsRequest.cs │ ├── FrameRate.cs │ ├── SearchCreativeVideosResponse.cs │ ├── GetOrderDetailsResponse.cs │ ├── Event.cs │ ├── ImageTechnique.cs │ ├── ArtistAssetSearchAllowedUse.cs │ ├── BoardBasic.cs │ ├── AspectRatio.cs │ ├── Viewpoint.cs │ ├── AssetDownloadHistoryItem.cs │ ├── GetBoardDetailsResponse.cs │ ├── PreviousAssetPurchase.cs │ ├── VideoDownloadSize.cs │ ├── HistoricalDownload.cs │ ├── Ethnicity.cs │ ├── Composition.cs │ ├── Product.cs │ ├── ImageSearchItemCreative.cs │ ├── ArtistAssetSearchItem.cs │ ├── CreativeVideoSearchItem.cs │ ├── EditorialVideoSearchItem.cs │ ├── ImageSearchItem.cs │ ├── ImageSearchItemEditorial.cs │ ├── GetSimilarVideosResponse.cs │ ├── Video.cs │ └── SearchCreativeVideosByImageResponse.cs ├── CredentialType.cs ├── UnauthorizedException.cs ├── Token.cs ├── DescriptionAttribute.cs ├── app.config ├── Handlers │ ├── ApiKeyHandler.cs │ ├── BearerTokenHandler.cs │ ├── HeadersHandler.cs │ └── UserAgentHandler.cs ├── AssetChanges │ ├── Channels.cs │ ├── DeleteAssetChanges.cs │ └── ChangeSets.cs ├── Countries │ └── Countries.cs ├── Customers │ └── Customers.cs ├── Collections │ └── Collections.cs ├── HttpResponseMessageExtensions.cs ├── Products │ └── Products.cs ├── AiGenerator │ ├── GetDownloadSizes.cs │ ├── GeneratedImageRedownload.cs │ ├── GenerateImages.cs │ ├── GetGeneratedImages.cs │ ├── GeneratedImageVariations.cs │ ├── GetGeneratedImageDownload.cs │ ├── ImageGenerationsApiRequest.cs │ └── DownloadGeneratedImage.cs ├── Usage │ └── UsageBatches.cs ├── Orders │ └── Orders.cs ├── Boards │ ├── PostBoards.cs │ ├── GetBoardsById.cs │ ├── GetComments.cs │ ├── PostComments.cs │ ├── DeleteBoardsById.cs │ ├── PutAssets.cs │ ├── PutBoardsById.cs │ ├── DeleteAssets.cs │ ├── PutAssetsById.cs │ ├── DeleteAssetsById.cs │ ├── DeleteCommentsById.cs │ └── GetBoards.cs ├── Serializer.cs ├── Images │ └── ImageDownloadHistory.cs ├── Videos │ └── VideoDownloadHistory.cs ├── SdkException.cs ├── AssetLicensing │ └── AcquireExtendedLicense.cs ├── Events │ └── Events.cs ├── GettyImages.Api.csproj ├── PolledPathApiRequest.cs ├── Download │ ├── DownloadsVideos.cs │ ├── Downloads.cs │ └── DownloadsImages.cs ├── Purchases │ └── PurchasedAssets.cs ├── PollyHttpClientExtensions.cs └── Artists │ ├── ArtistsImages.cs │ └── ArtistsVideos.cs ├── IntegrationTests ├── README.md ├── InternalExtensions.cs ├── BaseFixture.cs └── IntegrationTests.csproj ├── .gitignore ├── .github └── workflows │ ├── build.yml │ └── publish.yml └── LICENSE /.idea/.idea.GettyImages.Api/.idea/.name: -------------------------------------------------------------------------------- 1 | GettyImages.Api -------------------------------------------------------------------------------- /package-icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gettyimages/gettyimages-api_dotnet/HEAD/package-icon.jpg -------------------------------------------------------------------------------- /nuget-add-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gettyimages/gettyimages-api_dotnet/HEAD/nuget-add-ref.png -------------------------------------------------------------------------------- /UnitTests/test-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gettyimages/gettyimages-api_dotnet/HEAD/UnitTests/test-image.jpg -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | default: build 2 | 3 | build: 4 | dotnet restore --force 5 | dotnet build 6 | 7 | test: 8 | dotnet test UnitTests -------------------------------------------------------------------------------- /GettyImages.Api/Models/BoardAsset.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class BoardAsset 4 | { 5 | public string AssetId { get; set; } 6 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CommentRequest.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class CommentRequest 4 | { 5 | public string Text { get; set; } 6 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ReportUsageBatchRequest.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class ReportUsageBatchRequest 4 | { 5 | public AssetUsage[] AssetUsages { get; set; } 6 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/BoardInfo.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class BoardInfo 4 | { 5 | public string Name { get; set; } 6 | public string Description { get; set; } 7 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ExtendedLicense.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum ExtendedLicense 4 | { 5 | Multiseat, 6 | Unlimited, 7 | Resale, 8 | Indemnification 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageGenerationsPendingResponse.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class ImageGenerationsPendingResponse 4 | { 5 | public string GenerationRequestId { get; set; } 6 | } -------------------------------------------------------------------------------- /GettyImages.Api/CredentialType.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api; 2 | 3 | public enum CredentialType 4 | { 5 | None, 6 | ApiKey, 7 | ClientCredentials, 8 | ResourceOwner, 9 | RefreshToken 10 | } -------------------------------------------------------------------------------- /.idea/.idea.GettyImages.Api/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/BoardRelationship.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum BoardRelationship 4 | { 5 | None = 0, 6 | [Description("owned")] Owned = 1, 7 | [Description("invited")] Invited = 2 8 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CreativeSearchFacets.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class CreativeSearchFacets 4 | { 5 | public Location[] Locations { get; set; } 6 | public Artist[] Artists { get; set; } 7 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/LicenseModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum LicenseModel 7 | { 8 | None = 0, 9 | RoyaltyFree = 1, 10 | RightsReady = 2 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CollectionFilter.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum CollectionFilter 4 | { 5 | None = 0, 6 | [Description("include")] Include = 1, 7 | [Description("exclude")] Exclude = 2 8 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/OrientationVideos.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum OrientationVideos 7 | { 8 | None = 0, 9 | Horizontal = 1, 10 | Vertical = 16 11 | } -------------------------------------------------------------------------------- /.idea/.idea.GettyImages.Api/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/GraphicalStyleFilter.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum GraphicalStyleFilter 4 | { 5 | None = 0, 6 | [Description("include")] Include = 1, 7 | [Description("exclude")] Exclude = 2 8 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Artist.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | namespace GettyImages.Api.Models; 4 | 5 | public class Artist 6 | { 7 | public string Name { get; set; } 8 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/FileType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum FileType 7 | { 8 | None = 0, 9 | [Description("eps")] Eps = 1, 10 | [Description("jpg")] Jpg = 2 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/DownloadGeneratedImageReadyResponse.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class DownloadGeneratedImageReadyResponse 4 | { 5 | public string Url { get; set; } 6 | public string GeneratedAssetId { get; set; } 7 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AcquireAssetLicensesRequest.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class AcquireAssetLicensesRequest 4 | { 5 | public ExtendedLicense[] ExtendedLicenses { get; set; } 6 | public bool UseTeamCredits { get; set; } 7 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/EditorialSource.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class EditorialSource 7 | { 8 | public int Id { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageGenerationsSize.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | public enum ImageGenerationsSize 6 | { 7 | [EnumMember(Value = "1k")] OneK = 1, 8 | [EnumMember(Value = "4k")] FourK = 2 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ReleaseStatus.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum ReleaseStatus 4 | { 5 | None = 0, 6 | [Description("release_not_important")] ReleaseNotImportant = 1, 7 | [Description("fully_released")] FullyReleased = 2 8 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AssetIdFromOrder.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class AssetIdFromOrder 7 | { 8 | public string Id { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AutoCorrections.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class AutoCorrections 7 | { 8 | public string Phrase { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/EditorialVideo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum EditorialVideo 7 | { 8 | None = 0, 9 | [Description("raw")] Raw = 1, 10 | [Description("produced")] Produced = 2 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SortOrderEvent.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace GettyImages.Api.Models 3 | { 4 | public enum SortOrderEvent 5 | { 6 | None = 0, 7 | [Description("newest")] Newest, 8 | [Description("oldest")] Oldest 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.idea/.idea.GettyImages.Api/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/CreateBoardResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class CreateBoardResponse 7 | { 8 | public string Id { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AssetUsage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | public class AssetUsage 6 | { 7 | public string AssetId { get; set; } 8 | public int Quantity { get; set; } 9 | public DateTime UsageDate { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CreateCommentResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class CreateCommentResponse 7 | { 8 | public string Id { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/DownloadAssetResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class DownloadAssetResponse 7 | { 8 | public string Uri { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GenerationVariationsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class GenerationVariationsRequest 4 | { 5 | public int ProductId { get; set; } 6 | public string ProjectCode { get; set; } 7 | public string Notes { get; set; } 8 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CommentPermissions.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class CommentPermissions 7 | { 8 | public bool CanDeleteComment { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetCountriesResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetCountriesResponse 7 | { 8 | public Country[] Countries { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetProductsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetProductsResponse 7 | { 8 | public Product[] Products { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/BoardCommentPermissions.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class BoardCommentPermissions 7 | { 8 | public bool CanAddComment { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/MinimumQuality.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | namespace GettyImages.Api.Models; 3 | 4 | public enum MinimumQuality 5 | { 6 | None = 0, 7 | [Description("1")] One, 8 | [Description("2")] Two, 9 | [Description("3")] Three 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CreativeKeyword.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class CreativeKeyword 4 | { 5 | public string KeywordId { get; set; } 6 | public string Text { get; set; } 7 | public string Type { get; set; } 8 | public int? Relevance { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetCollectionsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetCollectionsResponse 7 | { 8 | public Collection[] Collections { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/UnauthorizedException.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | 3 | namespace GettyImages.Api; 4 | 5 | public class UnauthorizedException : SdkException 6 | { 7 | internal UnauthorizedException(string message) : base(message, HttpStatusCode.Unauthorized) 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GeneratedImageDownloadRequest.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class GeneratedImageDownloadRequest 4 | { 5 | public ImageGenerationsSize SizeName { get; set; } 6 | public string Notes { get; set; } 7 | public string ProjectCode { get; set; } 8 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Location.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Location 7 | { 8 | public int Id { get; set; } 9 | public string Name { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Links.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Links 7 | { 8 | public string Invitation { get; set; } 9 | public string Share { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/DisplaySize.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class DisplaySize 7 | { 8 | public string Name { get; set; } 9 | public string Uri { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Entertainment.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Entertainment 7 | { 8 | public int Id { get; set; } 9 | public string Name { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/MaxDimensions.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class MaxDimensions 7 | { 8 | public int Height { get; set; } 9 | public int Width { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/RelatedSearch.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class RelatedSearch 7 | { 8 | public string Phrase { get; set; } 9 | public string Url { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SpecificPeople.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SpecificPeople 7 | { 8 | public int Id { get; set; } 9 | public string Name { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageDetailLink.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class ImageDetailLink 7 | { 8 | public string Rel { get; set; } 9 | public string Uri { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Token.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api; 4 | 5 | public class Token 6 | { 7 | internal Token() 8 | { 9 | } 10 | 11 | public DateTime Expiration { get; set; } 12 | public string AccessToken { get; set; } 13 | public string RefreshToken { get; set; } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Collaborator.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Collaborator 7 | { 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/EditorialSegment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum EditorialSegment 7 | { 8 | None = 0, 9 | Archival = 1, 10 | Entertainment = 2, 11 | News = 4, 12 | Publicity = 8, 13 | Royalty = 16, 14 | Sport = 32 15 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetAssetDownloadHistoryResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetAssetDownloadHistoryResponse 7 | { 8 | public AssetDownloadHistoryItem[] Downloads { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/IStockLicense.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class IStockLicense 7 | { 8 | public string LicenseType { get; set; } 9 | public int Credits { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/NumberOfPeople.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum NumberOfPeople 7 | { 8 | [Description("none")] None = 0, 9 | [Description("one")] One = 2, 10 | [Description("two")] Two = 4, 11 | [Description("group")] Group = 8 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/OrientationImages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum OrientationImages 7 | { 8 | None = 0, 9 | Horizontal = 1, 10 | Panoramic_Horizontal = 2, 11 | Panoramic_Vertical = 4, 12 | Square = 8, 13 | Vertical = 16 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/HeroImage.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class HeroImage 7 | { 8 | public string Id { get; set; } 9 | public HeroImageDisplaySize[] DisplaySizes { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ReferralDestination.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class ReferralDestination 7 | { 8 | public string SiteName { get; set; } 9 | public string Uri { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SortOrderCreative.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum SortOrderCreative 4 | { 5 | None = 0, 6 | [Description("best_match")] BestMatch, 7 | [Description("most_popular")] MostPopular, 8 | [Description("newest")] Newest, 9 | [Description("random")] Random 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/DownloadDetails.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class DownloadDetails 7 | { 8 | public string DownloadNotes { get; set; } 9 | public string ProjectCode { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/FacetFieldsCreative.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | 4 | namespace GettyImages.Api.Models 5 | { 6 | [Flags] 7 | public enum FacetFieldsCreative 8 | { 9 | None = 0, 10 | [Description("artists")] Artists = 1, 11 | [Description("locations")] Locations = 2 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetBoardsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetBoardsResponse 7 | { 8 | public BoardBasic[] Boards { get; set; } 9 | public int BoardCount { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetEventsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetEventsResponse 7 | { 8 | public Event[] Events { get; set; } 9 | public int[] EventsNotFound { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchEventsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchEventsResponse 7 | { 8 | public Event[] Events { get; set; } 9 | public int ResultCount { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/FormatAvailable.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace GettyImages.Api.Models 3 | { 4 | public enum FormatAvailable 5 | { 6 | None = 0, 7 | [Description("sd")] SD, 8 | [Description("hd")] HD, 9 | [Description("4k")] FourK, 10 | [Description("hd_web")] HDWeb 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageGenerationsMediaType.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | public enum ImageGenerationsMediaType 6 | { 7 | None = 0, 8 | [EnumMember(Value = "photography")] Photography = 1, 9 | [EnumMember(Value = "illustration")] Illustration = 2 10 | } -------------------------------------------------------------------------------- /UnitTests/TestUtil.cs: -------------------------------------------------------------------------------- 1 | namespace UnitTests; 2 | 3 | internal class TestUtil 4 | { 5 | public static TestHandler CreateTestHandler() 6 | { 7 | return new TestHandler(new 8 | { 9 | images = new[] 10 | { 11 | new { } 12 | } 13 | }); 14 | } 15 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AssetChangesResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | namespace GettyImages.Api.Models; 4 | 5 | public class AssetChangesResponse 6 | { 7 | public string ChangeSetId { get; set; } 8 | public ChangedAssetDetail[] ChangedAssets { get; set; } 9 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Dimensions.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Dimensions 7 | { 8 | public int Width { get; set; } 9 | public int Height { get; set; } 10 | public int Dpi { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetDownloadsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetDownloadsResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public HistoricalDownload[] Downloads { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetVideosDetailsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetVideosDetailsResponse 7 | { 8 | public Video[] Videos { get; set; } 9 | public string[] VideosNotFound { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AddBoardAssetsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | namespace GettyImages.Api.Models; 4 | 5 | 6 | public class AddBoardAssetsResponse 7 | { 8 | public BoardAsset[] AssetsAdded { get; set; } 9 | public string[] AssetsNotAdded { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AssetLicensingResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class AssetLicensingResponse 7 | { 8 | public int CreditsUsed { get; set; } 9 | public ExtendedLicense[] AcquiredLicenses { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetCommentsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetCommentsResponse 7 | { 8 | public Comment[] Comments { get; set; } 9 | public BoardCommentPermissions Permissions { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetImagesDetailsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetImagesDetailsResponse 7 | { 8 | public ImageDetail[] Images { get; set; } 9 | public string[] ImagesNotFound { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GraphicalStylesEditorial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum GraphicalStylesEditorial 7 | { 8 | None = 0, 9 | [Description("photography")] Photography = 1, 10 | [Description("illustration")] Illustration = 2, 11 | [Description("vector")] Vector = 4 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ReportUsageBatchResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class ReportUsageBatchResponse 7 | { 8 | public string[] InvalidAssets { get; set; } 9 | public int TotalAssetUsagesProcessed { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchImagesByArtistResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchImagesByArtistResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public ArtistAssetSearchItem[] Images { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchVideosByArtistResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchVideosByArtistResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public ArtistAssetSearchItem[] Videos { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/DescriptionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api; 4 | 5 | [AttributeUsage(AttributeTargets.Field)] 6 | public class DescriptionAttribute : Attribute 7 | { 8 | public DescriptionAttribute(string description) 9 | { 10 | Description = description; 11 | } 12 | 13 | public string Description { get; } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AllowedUse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | namespace GettyImages.Api.Models; 4 | 5 | public class AllowedUse 6 | { 7 | public string HowCanIUseIt { get; set; } 8 | public string ReleaseInfo { get; set; } 9 | public string[] UsageRestrictions { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/FacetEvent.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class FacetEvent 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | public DateTime Date { get; set; } 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/OAuthResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class OAuthResponse 7 | { 8 | public string AccessToken { get; set; } 9 | public string RefreshToken { get; set; } 10 | public int ExpiresIn { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SortOrderEditorial.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum SortOrderEditorial 4 | { 5 | None = 0, 6 | [Description("best_match")] BestMatch, 7 | [Description("most_popular")] MostPopular, 8 | [Description("newest")] Newest, 9 | [Description("oldest")] Oldest, 10 | [Description("random")] Random 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ArtistAssetSearchKeyword.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | namespace GettyImages.Api.Models; 4 | 5 | public class ArtistAssetSearchKeyword 6 | { 7 | public string KeywordId { get; set; } 8 | public string Text { get; set; } 9 | public string Type { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/HeroImageDisplaySize.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class HeroImageDisplaySize 7 | { 8 | public string Name { get; set; } 9 | public bool IsWatermarked { get; set; } 10 | public string Uri { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CustomerInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class CustomerInfoResponse 7 | { 8 | public string FirstName { get; set; } 9 | public string MiddleName { get; set; } 10 | public string LastName { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AssetSearchItemDisplaySize.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class AssetSearchItemDisplaySize 7 | { 8 | public bool IsWatermarked { get; set; } 9 | public string Name { get; set; } 10 | public string Uri { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetPreviouslyPurchasedAssetsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetPreviouslyPurchasedAssetsResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public PreviousAssetPurchase[] PreviousPurchases { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/User.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class User 7 | { 8 | public string Username { get; set; } 9 | public string FirstName { get; set; } 10 | public string MiddleName { get; set; } 11 | public string LastName { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/DownloadRequirements.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class DownloadRequirements 7 | { 8 | public bool IsNoteRequired { get; set; } 9 | public bool IsProjectCodeRequired { get; set; } 10 | public string[] ProjectCodes { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GraphicalStylesCreative.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum GraphicalStylesCreative 7 | { 8 | None = 0, 9 | [Description("fine_art")] FineArt = 1, 10 | [Description("photography")] Photography = 2, 11 | [Description("illustration")] Illustration = 4, 12 | [Description("vector")] Vector = 8 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Download.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Download 7 | { 8 | public string ProductId { get; set; } 9 | public string ProductType { get; set; } 10 | public string Uri { get; set; } 11 | public string AgreementName { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GeneratedImageRedownloadRequest.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class GeneratedImageRedownloadRequest 4 | { 5 | public string GeneratedAssetId { get; set; } 6 | public int ProductId { get; set; } 7 | public ImageGenerationsSize SizeName { get; set; } 8 | public string ProjectCode { get; set; } 9 | public string Notes { get; set; } 10 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/OverageDetails.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class OverageDetails 7 | { 8 | public int Limit { get; set; } 9 | public int Remaining { get; set; } 10 | public int Count { get; set; } 11 | public bool OveragesReached { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetSimilarImagesResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class GetSimilarImagesResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public ImageSearchItem[] Images { get; set; } 10 | public RelatedSearch[] RelatedSearches { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageGenerationsReadyResponse.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class ImageGenerationsReadyResponse 4 | { 5 | public string GenerationRequestId { get; set; } 6 | 7 | public Result[] Results { get; set; } 8 | 9 | public class Result 10 | { 11 | public int Index { get; set; } 12 | public string Url { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/LocationEvent.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class LocationEvent 7 | { 8 | public string City { get; set; } 9 | public string Country { get; set; } 10 | public string StateProvince { get; set; } 11 | public string Venue { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GeneratedDownloadSizesResponse.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class GeneratedDownloadSizesResponse 4 | { 5 | public DownloadSize[] DownloadSizes { get; set; } 6 | 7 | public class DownloadSize 8 | { 9 | public string SizeName { get; set; } 10 | public int Height { get; set; } 11 | public int Width { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/OrientationImagesResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models 4 | { 5 | [Flags] 6 | public enum OrientationImagesResponse 7 | { 8 | None = 0, 9 | Horizontal = 1, 10 | PanoramicHorizontal = 2, 11 | PanoramicVertical = 4, 12 | Square = 8, 13 | Vertical = 16, 14 | Unknown = 32 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/MinimumSize.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public enum MinimumSize 4 | { 5 | None = 0, 6 | [Description("x_small")] Xsmall, 7 | [Description("small")] Small, 8 | [Description("medium")] Medium, 9 | [Description("large")] Large, 10 | [Description("x_large")] Xlarge, 11 | [Description("xx_large")] Xxlarge, 12 | [Description("vector")] Vector 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/OrderNotes.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class OrderNotes 7 | { 8 | public string LicenseeName { get; set; } 9 | public string PurchaseOrderNumber { get; set; } 10 | public string ProjectTitle { get; set; } 11 | public string OrderedBy { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Asset.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class Asset 9 | { 10 | public string Id { get; set; } 11 | public string AssetType { get; set; } 12 | public DateTime DateAdded { get; set; } 13 | public DisplaySize[] DisplaySizes { get; set; } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchEditorialImagesResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchEditorialImagesResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public ImageSearchItemEditorial[] Images { get; set; } 10 | public RelatedSearch[] RelatedSearches { get; set; } 11 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AssetDownloadHistoryUser.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class AssetDownloadHistoryUser 7 | { 8 | public string Username { get; set; } 9 | public string FirstName { get; set; } 10 | public string MiddleName { get; set; } 11 | public string LastName { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/VideoSearchItemDisplaySize.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class VideoSearchItemDisplaySize 7 | { 8 | public bool IsWatermarked { get; set; } 9 | public string Name { get; set; } 10 | public string Uri { get; set; } 11 | public string AspectRatio { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchCreativeImagesByImageResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchCreativeImagesByImageResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public CreativeSearchFacets Facets { get; set; } 10 | public ImageSearchItemCreative[] Images { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/FacetFieldsEditorial.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | 4 | namespace GettyImages.Api.Models 5 | { 6 | [Flags] 7 | public enum FacetFieldsEditorial 8 | { 9 | None = 0, 10 | [Description("artists")] Artists = 1, 11 | [Description("events")] Events = 2, 12 | [Description("locations")] Locations = 4, 13 | [Description("specific_people")] SpecificPeople = 8 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.idea/.idea.GettyImages.Api/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /contentModel.xml 6 | /modules.xml 7 | /projectSettingsUpdater.xml 8 | /.idea.GettyImages.Api.iml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | # GitHub Copilot persisted chat sessions 15 | /copilot/chatSessions 16 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/SortOrderBoards.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models 2 | { 3 | public enum SortOrderBoards 4 | { 5 | None = 0, 6 | [Description("date_last_updated_descending")] DateLastUpdatedDescending, 7 | [Description("date_last_updated_ascending")] DateLastUpdatedAscending, 8 | [Description("name_ascending")] NameAscending, 9 | [Description("name_decending")] NameDescending 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/Country.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System.Text.Json.Serialization; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class Country 9 | { 10 | [JsonPropertyName("iso_alpha_2")] public string IsoAlpha2 { get; set; } 11 | [JsonPropertyName("iso_alpha_3")] public string IsoAlpha3 { get; set; } 12 | public string Name { get; set; } 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Channel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | public class Channel 6 | { 7 | public int ChannelId { get; set; } 8 | public string AssetFamily { get; set; } 9 | public string ChannelType { get; set; } 10 | public DateTime StartDate { get; set; } 11 | public int NotificationCount { get; set; } 12 | public string AssetType { get; set; } 13 | public DateTime OldestNotificationDateUtc { get; set; } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Comment.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class Comment 9 | { 10 | public Collaborator CreatedBy { get; set; } 11 | public DateTime DateCreated { get; set; } 12 | public string Id { get; set; } 13 | public CommentPermissions Permissions { get; set; } 14 | public string Text { get; set; } 15 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Keyword.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Keyword 7 | { 8 | public string KeywordId { get; set; } 9 | public string Text { get; set; } 10 | public string Type { get; set; } 11 | public int? Relevance { get; set; } 12 | public string[] EntityUris { get; set; } 13 | public string[] EntityTypes { get; set; } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchCreativeImagesResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchCreativeImagesResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public ImageSearchItemCreative[] Images { get; set; } 10 | public AutoCorrections AutoCorrections { get; set; } 11 | public RelatedSearch[] RelatedSearches { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchEditorialVideosResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchEditorialVideosResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public EditorialVideoSearchItem[] Videos { get; set; } 10 | public SearchFacetsResponse Facets { get; set; } 11 | public RelatedSearch[] RelatedSearches { get; set; } 12 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Collection.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class Collection 7 | { 8 | public string AssetFamily { get; set; } 9 | public string Code { get; set; } 10 | public int Id { get; set; } 11 | public string LicenseModel { get; set; } 12 | public string Name { get; set; } 13 | public string[] ProductTypes { get; set; } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageGenerationsMood.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | public enum ImageGenerationsMood 6 | { 7 | None = 0, 8 | [Description("black_and_white")] BlackAndWhite, 9 | [Description("warm")] Warm, 10 | [Description("cool")] Cool, 11 | [Description("natural")] Natural, 12 | [Description("vivid")] Vivid, 13 | [Description("dramatic")] Dramatic, 14 | [Description("bold")] Bold 15 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ChangedAssetDetail.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class ChangedAssetDetail 9 | { 10 | public DateTime AssetChangedUtcDatetime { get; set; } 11 | public string AssetLifecycle { get; set; } 12 | public string AssetType { get; set; } 13 | public string Id { get; set; } 14 | public string Uri { get; set; } 15 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ProductType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum ProductType 7 | { 8 | None = 0, 9 | [Description("editorialsubscription")] Editorialsubscription = 2, 10 | [Description("premiumaccess")] Premiumaccess = 4, 11 | [Description("easyaccess")] Easyaccess = 8, 12 | 13 | [Description("royaltyfreesubscription")] 14 | Royaltyfreesubscription = 16, 15 | [Description("imagepack")] Imagepack = 32 16 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchFacetsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchFacetsResponse 7 | { 8 | public SpecificPeople[] SpecificPeople { get; set; } 9 | public FacetEvent[] Events { get; set; } 10 | public Location[] Locations { get; set; } 11 | public Artist[] Artists { get; set; } 12 | public Entertainment[] Entertainment { get; set; } 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/DownloadSize.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class DownloadSize 7 | { 8 | public long Bytes { get; set; } 9 | public Download[] Downloads { get; set; } 10 | public double Height { get; set; } 11 | public string MediaType { get; set; } 12 | public string Name { get; set; } 13 | public int Width { get; set; } 14 | public int Dpi { get; set; } 15 | } -------------------------------------------------------------------------------- /GettyImages.Api/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/BoardPermissions.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class BoardPermissions 7 | { 8 | public bool CanDeleteBoard { get; set; } 9 | public bool CanInviteToBoard { get; set; } 10 | public bool CanUpdateName { get; set; } 11 | public bool CanUpdateDescription { get; set; } 12 | public bool CanAddAssets { get; set; } 13 | public bool CanRemoveAssets { get; set; } 14 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageGenerationsRequest.cs: -------------------------------------------------------------------------------- 1 | namespace GettyImages.Api.Models; 2 | 3 | public class ImageGenerationsRequest 4 | { 5 | public string Prompt { get; set; } 6 | public string NegativePrompt { get; set; } 7 | public string AspectRatio { get; set; } 8 | public ImageGenerationsMediaType? MediaType { get; set; } 9 | public ImageGenerationsMood? Mood { get; set; } 10 | public int ProductId { get; set; } 11 | public string ProjectCode { get; set; } 12 | public string Notes { get; set; } 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/FrameRate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum FrameRate 7 | { 8 | None = 0, 9 | [Description("23.98")] FrameRate23 = 1, 10 | [Description("24")] FrameRate24 = 2, 11 | [Description("25")] FrameRate25 = 4, 12 | [Description("29.97")] FrameRate29 = 8, 13 | [Description("30")] FrameRate30 = 16, 14 | [Description("50")] FrameRate50 = 32, 15 | [Description("59.94")] FrameRate59 = 64, 16 | [Description("60")] FrameRate60 = 128 17 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchCreativeVideosResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class SearchCreativeVideosResponse 7 | { 8 | public int ResultCount { get; set; } 9 | public CreativeVideoSearchItem[] Videos { get; set; } 10 | public SearchFacetsResponse Facets { get; set; } 11 | public AutoCorrections AutoCorrections { get; set; } 12 | public RelatedSearch[] RelatedSearches { get; set; } 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetOrderDetailsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class GetOrderDetailsResponse 9 | { 10 | public string Id { get; set; } 11 | public string InvoiceNumber { get; set; } 12 | public DateTime OrderDate { get; set; } 13 | public string EndClient { get; set; } 14 | public OrderNotes Notes { get; set; } 15 | public AssetIdFromOrder[] Assets { get; set; } 16 | } -------------------------------------------------------------------------------- /UnitTests/Products/ProductsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Products; 7 | 8 | public class CountriesTests 9 | { 10 | [Fact] 11 | public async Task ProductsBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).Products() 15 | .ExecuteAsync(); 16 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("products"); 17 | } 18 | } -------------------------------------------------------------------------------- /UnitTests/Orders/OrdersTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Orders; 7 | 8 | public class OrdersTests 9 | { 10 | [Fact] 11 | public async Task OrdersBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .Orders().WithId(1234).ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("orders/1234"); 19 | } 20 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Event.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class Event 9 | { 10 | public int ChildEventCount { get; set; } 11 | public string[] EditorialSegments { get; set; } 12 | public HeroImage HeroImage { get; set; } 13 | public int Id { get; set; } 14 | public int ImageCount { get; set; } 15 | public LocationEvent Location { get; set; } 16 | public string Name { get; set; } 17 | public DateTime StartDate { get; set; } 18 | } -------------------------------------------------------------------------------- /IntegrationTests/README.md: -------------------------------------------------------------------------------- 1 | # Integration Tests 2 | 3 | Some API calls need more in-depth testing to assure correctness. For these we have integration tests which are to be executed locally with secrets provided in configuration, primarily through [`dotnet user-secrets`](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets). Specifically, you'll need: 4 | 5 | ``` bash 6 | dotnet user-secrets set ApiKey **** 7 | dotnet user-secrets set ApiSecret **** 8 | dotnet user-secrets set UserName **** 9 | dotnet user-secrets set UserPassword **** 10 | dotnet user-secrets set ProductId **** 11 | ``` 12 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageTechnique.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models 4 | { 5 | 6 | [Flags] 7 | public enum ImageTechnique : long 8 | { 9 | None = 0, 10 | [Description("realtime")] Realtime = 1, 11 | [Description("time_lapse")] TimeLapse = 2, 12 | [Description("slow_motion")] SlowMotion = 4, 13 | [Description("color")] Color = 8, 14 | [Description("black_and_white")] BlackAndWhite = 16, 15 | [Description("animation")] Animation = 32, 16 | [Description("selective_focus")] SelectiveFocus = 64 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/ArtistAssetSearchAllowedUse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | using System.Text.Json.Serialization; 4 | 5 | namespace GettyImages.Api.Models; 6 | 7 | public class ArtistAssetSearchAllowedUse 8 | { 9 | [JsonPropertyName("HowCanIUseIt")] public string HowCanIUseIt { get; set; } 10 | [JsonPropertyName("ReleaseInfo")] public string ReleaseInfo { get; set; } 11 | [JsonPropertyName("UsageRestrictions")] public string[] UsageRestrictions { get; set; } 12 | [JsonPropertyName("Code")] public string Code { get; set; } 13 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/BoardBasic.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class BoardBasic 9 | { 10 | public string Id { get; set; } 11 | public int AssetCount { get; set; } 12 | public DateTime DateCreated { get; set; } 13 | public DateTime DateLastUpdated { get; set; } 14 | public string Description { get; set; } 15 | public Asset HeroAsset { get; set; } 16 | public string Name { get; set; } 17 | public string BoardRelationship { get; set; } 18 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AspectRatio.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | using System; 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | [Flags] 7 | public enum AspectRatio : long 8 | { 9 | None = 0, 10 | [Description("16:9")] AspectRatio16_9 = 1, 11 | [Description("9:16")] AspectRatio9_16 = 2, 12 | [Description("3:4")] AspectRatio3_4 = 4, 13 | [Description("4:3")] AspectRatio4_3 = 8, 14 | [Description("4:5")] AspectRatio4_5 = 16, 15 | [Description("2:1")] AspectRatio2_1 = 32, 16 | [Description("17:9")] AspectRatio17_9 = 64, 17 | [Description("9:17")] AspectRatio9_17 = 128 18 | } -------------------------------------------------------------------------------- /UnitTests/Countries/CountriesTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Countries; 7 | 8 | public class CountriesTests 9 | { 10 | [Fact] 11 | public async Task CountriesBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .Countries() 17 | .ExecuteAsync(); 18 | 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("countries"); 20 | } 21 | } -------------------------------------------------------------------------------- /UnitTests/Boards/GetBoardsByIdTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class GetBoardsByIdTests 9 | { 10 | [Fact] 11 | public async Task GetBoardsByIdBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .GetBoardsById().WithBoardId("15345").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345"); 19 | } 20 | } -------------------------------------------------------------------------------- /UnitTests/Boards/PutBoardsByIdTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class PutBoardsByIdTests 9 | { 10 | [Fact] 11 | public async Task PutBoardsByIdBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .PutBoardsById().WithBoardId("15345").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345"); 19 | } 20 | } -------------------------------------------------------------------------------- /UnitTests/Collections/CollectionsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Collections; 7 | 8 | public class CollectionsTests 9 | { 10 | [Fact] 11 | public async Task CollectionsBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .Collections() 17 | .ExecuteAsync(); 18 | 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("collections"); 20 | } 21 | } -------------------------------------------------------------------------------- /UnitTests/Boards/GetCommentsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class GetCommentsTests 9 | { 10 | [Fact] 11 | public async Task GetCommentsBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .GetComments().WithBoardId("15345").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345/comments"); 19 | } 20 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #ignore thumbnails created by windows 2 | Thumbs.db 3 | #Ignore files build by Visual Studio 4 | *.obj 5 | *.exe 6 | *.pdb 7 | *.user 8 | *.aps 9 | *.pch 10 | *.vspscc 11 | *_i.c 12 | *_p.c 13 | *.ncb 14 | *.suo 15 | *.tlb 16 | *.tlh 17 | *.bak 18 | *.cache 19 | *.ilk 20 | *.log 21 | [Bb]in 22 | [Dd]ebug*/ 23 | *.lib 24 | *.sbr 25 | [Rr]elease*/ 26 | _ReSharper*/ 27 | [Tt]est[Rr]esult* 28 | *.dll 29 | *.nupkg 30 | [Oo]bj 31 | [Pp]ackages 32 | _ReSharper* 33 | *.suo 34 | *.nupkg 35 | *.bom 36 | *.dll 37 | *.pdb 38 | *.user 39 | *.orig 40 | .nuget/*/* 41 | !nuget.exe 42 | *.DotSettings 43 | *.feature.cs 44 | *~ 45 | .vs/ 46 | .vscode/ 47 | -------------------------------------------------------------------------------- /UnitTests/Boards/DeleteBoardByIdTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class DeleteBoardByIdTests 9 | { 10 | [Fact] 11 | public async Task DeleteBoardsByIdBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .DeleteBoardsById().WithBoardId("15345").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345"); 19 | } 20 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Viewpoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models 4 | { 5 | [Flags] 6 | public enum Viewpoint : long 7 | { 8 | None = 0, 9 | [Description("lockdown")] Lockdown = 1, 10 | [Description("panning")] Panning = 2, 11 | [Description("tracking_shot")] TrackingShot = 4, 12 | [Description("aerial_view")] AerialView = 8, 13 | [Description("high_angle_view")] HighAngleView = 16, 14 | [Description("low_angle_view")] LowAngleView = 32, 15 | [Description("tilt")] Tilt = 64, 16 | [Description("point_of_view")] PointOfView = 128 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /UnitTests/Boards/PostBoardsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using GettyImages.Api.Models; 5 | using Xunit; 6 | 7 | namespace UnitTests.Boards; 8 | 9 | public class PostBoardsTests 10 | { 11 | [Fact] 12 | public async Task PostBoardsBasic() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | 16 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 17 | .PostBoards().WithNewBoard(new BoardInfo()).ExecuteAsync(); 18 | 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards"); 20 | } 21 | } -------------------------------------------------------------------------------- /IntegrationTests/InternalExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.Configuration; 3 | 4 | namespace IntegrationTests; 5 | 6 | internal static class InternalExtensions 7 | { 8 | public static string AssertConfigurationValue(this IConfiguration configuration, string key) 9 | { 10 | var result = configuration[key]; 11 | if (string.IsNullOrWhiteSpace(result)) 12 | { 13 | throw new Exception( 14 | $"Expected configuration value (\"{key}\") not found. Use \"dotnet user-secrets set {key} \" to set before running tests."); 15 | } 16 | 17 | return result; 18 | } 19 | } -------------------------------------------------------------------------------- /UnitTests/Boards/PutAssetsByIdTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class PutAssetsByIdTests 9 | { 10 | [Fact] 11 | public async Task PutAssetsByIdBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .PutAssetsById().WithBoardId("15345").WithAssetId("1245").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345/assets/1245"); 19 | } 20 | } -------------------------------------------------------------------------------- /UnitTests/Boards/DeleteAssetsByIdTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class DeleteAssetsByIdTests 9 | { 10 | [Fact] 11 | public async Task DeleteAssetsByIdBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .DeleteAssetsById().WithBoardId("15345").WithAssetId("1245").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345/assets/1245"); 19 | } 20 | } -------------------------------------------------------------------------------- /GettyImages.Api/Handlers/ApiKeyHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace GettyImages.Api.Handlers; 6 | 7 | internal class ApiKeyHandler : DelegatingHandler 8 | { 9 | private readonly string _apiKey; 10 | 11 | public ApiKeyHandler(string apiKey) 12 | { 13 | _apiKey = apiKey; 14 | } 15 | 16 | protected override async Task SendAsync( 17 | HttpRequestMessage request, 18 | CancellationToken cancellationToken) 19 | { 20 | request.Headers.Add("Api-Key", _apiKey); 21 | return await base.SendAsync(request, cancellationToken); 22 | } 23 | } -------------------------------------------------------------------------------- /UnitTests/AssetChanges/DeleteAssetChangesTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.AssetChanges; 7 | 8 | public class DeleteAssetChangesTests 9 | { 10 | [Fact] 11 | public async Task DeleteAssetChangesBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .DeleteAssetChanges().WithChangeSetId(155432).ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("asset-changes/change-sets/155432"); 19 | } 20 | } -------------------------------------------------------------------------------- /UnitTests/Customers/CustomersTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Customers; 7 | 8 | public class CustomersTests 9 | { 10 | [Fact] 11 | public async Task GetCustomerInfoBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient 16 | .GetApiClientWithResourceOwnerCredentials("apiKey", "apiSecret", "userName", "userPassword", testHandler) 17 | .Customers() 18 | .ExecuteAsync(); 19 | 20 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("/customers/current"); 21 | } 22 | } -------------------------------------------------------------------------------- /UnitTests/HeaderAndBody/TestHeadersHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Net.Http; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using GettyImages.Api.Handlers; 6 | 7 | namespace UnitTests.HeaderAndBody; 8 | 9 | internal class TestHeadersHandler : HeadersHandler 10 | { 11 | public TestHeadersHandler(IEnumerable> headerParameters) : base(headerParameters) 12 | { 13 | } 14 | 15 | public new async Task SendAsync(HttpRequestMessage request, 16 | CancellationToken cancellationToken) 17 | { 18 | return await base.SendAsync(request, cancellationToken); 19 | } 20 | } -------------------------------------------------------------------------------- /UnitTests/Boards/DeleteCommentsByIdTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class DeleteCommentsByIdTests 9 | { 10 | [Fact] 11 | public async Task DeleteCommentsByIdBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .DeleteCommentsById().WithBoardId("15345").WithCommentId("1245").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345/comments/1245"); 19 | } 20 | } -------------------------------------------------------------------------------- /GettyImages.Api/AssetChanges/Channels.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.AssetChanges; 5 | 6 | public class Channels : ApiRequest 7 | { 8 | private Channels(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | Path = "/asset-changes/channels"; 14 | } 15 | 16 | internal static Channels GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 17 | { 18 | return new Channels(credentials, baseUrl, customHandler); 19 | } 20 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/AssetDownloadHistoryItem.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class AssetDownloadHistoryItem 9 | { 10 | public DateTime DateDownloaded { get; set; } 11 | public string AssetType { get; set; } 12 | public AssetDownloadHistoryUser User { get; set; } 13 | public string ProductType { get; set; } 14 | public string AgreementName { get; set; } 15 | public int ProductId { get; set; } 16 | public string DownloadNotes { get; set; } 17 | public string ProjectCode { get; set; } 18 | public string DownloadSource { get; set; } 19 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetBoardDetailsResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class GetBoardDetailsResponse 9 | { 10 | public string Id { get; set; } 11 | public int AssetCount { get; set; } 12 | public Asset[] Assets { get; set; } 13 | public DateTime DateCreated { get; set; } 14 | public DateTime DateLastUpdated { get; set; } 15 | public string Description { get; set; } 16 | public string Name { get; set; } 17 | public int CommentCount { get; set; } 18 | public BoardPermissions Permissions { get; set; } 19 | public Links Links { get; set; } 20 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/PreviousAssetPurchase.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class PreviousAssetPurchase 9 | { 10 | public DateTime DatePurchased { get; set; } 11 | public string PurchasedBy { get; set; } 12 | public string AssetId { get; set; } 13 | public string AssetType { get; set; } 14 | public string LicenseModel { get; set; } 15 | public string OrderId { get; set; } 16 | public string ThumbUri { get; set; } 17 | public string SizeName { get; set; } 18 | public string FileSizeInBytes { get; set; } 19 | public string DownloadUri { get; set; } 20 | } -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Setup .NET 12 | uses: actions/setup-dotnet@v4 13 | with: 14 | dotnet-version: 8.0.x 15 | - name: Restore dependencies 16 | run: dotnet restore 17 | - name: Build 18 | run: dotnet build --configuration Release --no-restore 19 | - name: Test 20 | run: dotnet test --configuration Release --no-build --no-restore --verbosity normal -f net6 ./UnitTests/UnitTests.csproj 21 | - uses: actions/upload-artifact@v4 22 | with: 23 | name: artifacts 24 | path: ./GettyImages.Api/bin/Release 25 | -------------------------------------------------------------------------------- /UnitTests/Boards/PostCommentsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class PostCommentsTests 9 | { 10 | [Fact] 11 | public async Task PostCommentsBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | var comment = @"{ 16 | 'text': 'string' 17 | }"; 18 | 19 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 20 | .PostComments().WithBoardId("15345").WithComment(comment).ExecuteAsync(); 21 | 22 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345/comments"); 23 | } 24 | } -------------------------------------------------------------------------------- /UnitTests/Boards/PutAssetsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Boards; 7 | 8 | public class PutAssetsTests 9 | { 10 | [Fact] 11 | public async Task PutAssetsBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | var assets = @"[ 16 | { 17 | 'asset_id': 'string' 18 | } 19 | ]"; 20 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 21 | .PutAssets().WithBoardId("15345").WithBoardAssets(assets).ExecuteAsync(); 22 | 23 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345/assets"); 24 | } 25 | } -------------------------------------------------------------------------------- /UnitTests/Credentials/CredentialsTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using GettyImages.Api; 3 | using System.Threading.Tasks; 4 | using Xunit; 5 | 6 | namespace UnitTests.Credentials 7 | { 8 | public class CredentialsTests 9 | { 10 | [Fact] 11 | public async Task GetApiClientWithOnlyApiKey() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithApiKey("apiKey", testHandler).SearchImagesCreative() 16 | .WithPhrase("cat").ExecuteAsync(); 17 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/images/creative"); 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("phrase=cat"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/VideoDownloadSize.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | namespace GettyImages.Api.Models; 5 | 6 | public class VideoDownloadSize 7 | { 8 | public string BitDepth { get; set; } 9 | public string Compression { get; set; } 10 | public string ContentType { get; set; } 11 | public string Description { get; set; } 12 | public Download[] Downloads { get; set; } 13 | public string Format { get; set; } 14 | public double FrameRate { get; set; } 15 | public string FrameSize { get; set; } 16 | public decimal Height { get; set; } 17 | public bool Interlaced { get; set; } 18 | public long Bytes { get; set; } 19 | public string Name { get; set; } 20 | public int Width { get; set; } 21 | } -------------------------------------------------------------------------------- /GettyImages.Api/Handlers/BearerTokenHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace GettyImages.Api.Handlers; 6 | 7 | internal class BearerTokenHandler : DelegatingHandler 8 | { 9 | private readonly Token _accessToken; 10 | 11 | public BearerTokenHandler(Token accessToken) 12 | { 13 | _accessToken = accessToken; 14 | } 15 | 16 | protected override async Task SendAsync( 17 | HttpRequestMessage request, 18 | CancellationToken cancellationToken) 19 | { 20 | if (_accessToken != null) 21 | { 22 | request.Headers.Add("Authorization", "Bearer " + _accessToken.AccessToken); 23 | } 24 | 25 | return await base.SendAsync(request, cancellationToken); 26 | } 27 | } -------------------------------------------------------------------------------- /UnitTests/WebHelper/WebHelperTests.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using GettyImages.Api; 5 | using Xunit; 6 | 7 | namespace UnitTests.WebHelper; 8 | 9 | public class WebHelperTests 10 | { 11 | [Fact] 12 | public async Task Check500CodeTest() 13 | { 14 | var httpResponse = new HttpResponseMessage(); 15 | httpResponse.StatusCode = (HttpStatusCode)500; 16 | var testHandler = new TestHandler(httpResponse); 17 | var response = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 18 | .SearchImagesCreative().WithPhrase("cat"); 19 | await Assert.ThrowsAsync(async () => await response.ExecuteAsync()); 20 | Assert.True(testHandler.NumberOfCallsSendAsync >= 2); 21 | } 22 | } -------------------------------------------------------------------------------- /UnitTests/Boards/DeleteAssetsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using GettyImages.Api; 5 | using Xunit; 6 | 7 | namespace UnitTests.Boards; 8 | 9 | public class DeleteAssetsTests 10 | { 11 | [Fact] 12 | public async Task DeleteAssetsBasic() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | 16 | var ids = new List { "1234", "12553" }; 17 | 18 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 19 | .DeleteAssets().WithBoardId("15345").WithAssetIds(ids).ExecuteAsync(); 20 | 21 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("boards/15345/assets"); 22 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("asset_ids=1234%2C12553"); 23 | } 24 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/HistoricalDownload.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class HistoricalDownload 9 | { 10 | public DateTime DateDownloaded { get; set; } 11 | public string Id { get; set; } 12 | public string AssetType { get; set; } 13 | public string ProductType { get; set; } 14 | public string ThumbUri { get; set; } 15 | public string AgreementName { get; set; } 16 | public int ProductId { get; set; } 17 | public DownloadDetails DownloadDetails { get; set; } 18 | public string DownloadSource { get; set; } 19 | public User User { get; set; } 20 | public string SizeName { get; set; } 21 | public Dimensions Dimensions { get; set; } 22 | public string LicenseModel { get; set; } 23 | } -------------------------------------------------------------------------------- /GettyImages.Api/AssetChanges/DeleteAssetChanges.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | namespace GettyImages.Api.AssetChanges; 4 | 5 | public class DeleteAssetChanges : ApiRequest 6 | { 7 | private DeleteAssetChanges(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 8 | customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "DELETE"; 13 | 14 | } 15 | 16 | internal static DeleteAssetChanges GetInstance(Credentials credentials, string baseUrl, 17 | DelegatingHandler customHandler) 18 | { 19 | return new DeleteAssetChanges(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public DeleteAssetChanges WithChangeSetId(long value) 23 | { 24 | Path = $"/asset-changes/change-sets/{value}"; 25 | return this; 26 | } 27 | } -------------------------------------------------------------------------------- /GettyImages.Api/Countries/Countries.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Countries; 5 | 6 | public class Countries : ApiRequest 7 | { 8 | private Countries(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | Path = "/countries"; 14 | } 15 | 16 | internal static Countries GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 17 | { 18 | return new Countries(credentials, baseUrl, customHandler); 19 | } 20 | 21 | public Countries WithAcceptLanguage(string value) 22 | { 23 | AddHeaderParameter(Constants.AcceptLanguage, value); 24 | return this; 25 | } 26 | } -------------------------------------------------------------------------------- /GettyImages.Api/Customers/Customers.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Customers; 5 | 6 | public class Customers : ApiRequest 7 | { 8 | private Customers(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | Path = "/customers/current"; 14 | } 15 | 16 | internal static Customers GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 17 | { 18 | return new Customers(credentials, baseUrl, customHandler); 19 | } 20 | 21 | public Customers WithAcceptLanguage(string value) 22 | { 23 | AddHeaderParameter(Constants.AcceptLanguage, value); 24 | return this; 25 | } 26 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Ethnicity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum Ethnicity 7 | { 8 | None = 0, 9 | [Description("black")] Black = 1, 10 | [Description("caucasian")] Caucasian = 2, 11 | [Description("east_asian")] EastAsian = 4, 12 | [Description("hispanic_latino")] HispanicLatino = 8, 13 | [Description("japanese")] Japanese = 16, 14 | [Description("middle_eastern")] MiddleEastern = 32, 15 | [Description("mixed_race_person")] MixedRacePerson = 64, 16 | [Description("multiethnic_group")] MultiethnicGroup = 128, 17 | 18 | [Description("native_american_first_nations")] 19 | NativeAmericanFirstNations = 256, 20 | [Description("pacific_islander")] PacificIslander = 512, 21 | [Description("south_asian")] SouthAsian = 1024, 22 | [Description("southeast_asian")] SoutheastAsian = 2048 23 | } -------------------------------------------------------------------------------- /GettyImages.Api/Collections/Collections.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Collections; 5 | 6 | public class Collections : ApiRequest 7 | { 8 | private Collections(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | Path = "/collections"; 14 | } 15 | 16 | internal static Collections GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 17 | { 18 | return new Collections(credentials, baseUrl, customHandler); 19 | } 20 | 21 | public Collections WithAcceptLanguage(string value) 22 | { 23 | AddHeaderParameter(Constants.AcceptLanguage, value); 24 | return this; 25 | } 26 | } -------------------------------------------------------------------------------- /GettyImages.Api/HttpResponseMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | 4 | namespace GettyImages.Api; 5 | 6 | internal static class HttpResponseMessageExtensions 7 | { 8 | internal static async Task HandleResponseAsync(this HttpResponseMessage httpResponse) 9 | { 10 | if (!httpResponse.IsSuccessStatusCode) 11 | { 12 | await SdkException.GenerateSdkExceptionAsync(httpResponse); 13 | } 14 | } 15 | 16 | internal static async Task HandleGetContentResponseAsync(this HttpResponseMessage httpResponse) 17 | { 18 | if (!httpResponse.IsSuccessStatusCode) 19 | { 20 | await SdkException.GenerateSdkExceptionAsync(httpResponse); 21 | } 22 | 23 | var stream = await httpResponse.Content.ReadAsStreamAsync(); 24 | return await Serializer.DeserializeAsync(stream); 25 | } 26 | } -------------------------------------------------------------------------------- /GettyImages.Api/Products/Products.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Products; 5 | 6 | public class Products : ApiRequest 7 | { 8 | private Products(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | Path = "/products"; 14 | AddResponseFields(new []{ "download_requirements"}); 15 | } 16 | 17 | internal static Products GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 18 | { 19 | return new Products(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public Products WithAcceptLanguage(string value) 23 | { 24 | AddHeaderParameter(Constants.AcceptLanguage, value); 25 | return this; 26 | } 27 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Composition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | [Flags] 6 | public enum Composition 7 | { 8 | None = 0, 9 | [Description("abstract")] Abstract = 1, 10 | [Description("candid")] Candid = 2, 11 | [Description("close_up")] CloseUp = 4, 12 | [Description("copy_space")] CopySpace = 8, 13 | [Description("cut_out")] CutOut = 16, 14 | [Description("full_frame")] FullFrame = 32, 15 | [Description("full_length")] FullLength = 64, 16 | [Description("headshot")] Headshot = 128, 17 | [Description("looking_at_camera")] LookingAtCamera = 256, 18 | [Description("macro")] Macro = 512, 19 | [Description("portrait")] Portrait = 1024, 20 | [Description("sparse")] Sparse = 2048, 21 | [Description("still_life")] StillLife = 4096, 22 | [Description("three_quarter_length")] ThreeQuarterLength = 8128, 23 | [Description("waist_up")] WaistUp = 16384 24 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/GetDownloadSizes.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.AiGenerator; 5 | 6 | public class GetDownloadSizes : ApiRequest 7 | { 8 | private GetDownloadSizes(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 9 | customHandler) 10 | { 11 | Credentials = credentials; 12 | Method = "GET"; 13 | BaseUrl = baseUrl; 14 | } 15 | 16 | internal static GetDownloadSizes GetInstance(Credentials credentials, string baseUrl, 17 | DelegatingHandler customHandler) 18 | { 19 | return new GetDownloadSizes(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public GetDownloadSizes With(string generationRequestId, int index) 23 | { 24 | Path = $"/ai/image-generations/{generationRequestId}/images/{index}/download-sizes"; 25 | return this; 26 | } 27 | } -------------------------------------------------------------------------------- /GettyImages.Api/Usage/UsageBatches.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Usage; 5 | 6 | public class UsageBatches : ApiRequest 7 | { 8 | private UsageBatches(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "PUT"; 13 | } 14 | 15 | internal static UsageBatches GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 16 | { 17 | return new UsageBatches(credentials, baseUrl, customHandler); 18 | } 19 | 20 | public UsageBatches WithId(string value) 21 | { 22 | Path = $"/usage-batches/{value}"; 23 | return this; 24 | } 25 | 26 | public UsageBatches WithRequest(ReportUsageBatchRequest value) 27 | { 28 | BodyParameter = value; 29 | return this; 30 | } 31 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/GeneratedImageRedownload.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.AiGenerator; 5 | 6 | public class GeneratedImageRedownload : ApiRequest 7 | { 8 | private GeneratedImageRedownload(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 9 | customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "POST"; 14 | Path = "/ai/redownloads"; 15 | } 16 | 17 | internal static GeneratedImageRedownload GetInstance(Credentials credentials, string baseUrl, 18 | DelegatingHandler customHandler) 19 | { 20 | return new GeneratedImageRedownload(credentials, baseUrl, customHandler); 21 | } 22 | 23 | public GeneratedImageRedownload With(GeneratedImageRedownloadRequest value) 24 | { 25 | BodyParameter = value; 26 | return this; 27 | } 28 | } -------------------------------------------------------------------------------- /GettyImages.Api/Orders/Orders.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Orders; 5 | 6 | public class Orders : ApiRequest 7 | { 8 | private Orders(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | } 14 | 15 | protected int id { get; set; } 16 | 17 | internal static Orders GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 18 | { 19 | return new Orders(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public Orders WithId(int value) 23 | { 24 | Path = $"/orders/{value}"; 25 | return this; 26 | } 27 | 28 | public Orders WithAcceptLanguage(string value) 29 | { 30 | AddHeaderParameter(Constants.AcceptLanguage, value); 31 | return this; 32 | } 33 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/PostBoards.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class PostBoards : ApiRequest 7 | { 8 | private PostBoards(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "POST"; 13 | Path = "/boards"; 14 | } 15 | 16 | internal static PostBoards GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 17 | { 18 | return new PostBoards(credentials, baseUrl, customHandler); 19 | } 20 | 21 | public PostBoards WithNewBoard(BoardInfo value) 22 | { 23 | BodyParameter = value; 24 | return this; 25 | } 26 | 27 | public PostBoards WithAcceptLanguage(string value) 28 | { 29 | AddHeaderParameter(Constants.AcceptLanguage, value); 30 | return this; 31 | } 32 | } -------------------------------------------------------------------------------- /IntegrationTests/BaseFixture.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | 3 | namespace IntegrationTests; 4 | 5 | public abstract class BaseFixture 6 | { 7 | protected BaseFixture() 8 | { 9 | var configurationBuilder = new ConfigurationBuilder(); 10 | configurationBuilder.AddUserSecrets(); 11 | var configuration = configurationBuilder.Build(); 12 | ApiKey = configuration.AssertConfigurationValue("ApiKey"); 13 | ApiSecret = configuration.AssertConfigurationValue("ApiSecret"); 14 | UserName = configuration.AssertConfigurationValue("UserName"); 15 | UserPassword = configuration.AssertConfigurationValue("UserPassword"); 16 | ProductId = int.Parse(configuration.AssertConfigurationValue("ProductId")); 17 | } 18 | 19 | public int ProductId { get; } 20 | 21 | public string UserPassword { get; } 22 | 23 | public string UserName { get; } 24 | 25 | public string ApiSecret { get; } 26 | 27 | public string ApiKey { get; } 28 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/GetBoardsById.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class GetBoardsById : ApiRequest 7 | { 8 | private GetBoardsById(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 9 | customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "GET"; 14 | 15 | } 16 | 17 | internal static GetBoardsById GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 18 | { 19 | return new GetBoardsById(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public GetBoardsById WithBoardId(string value) 23 | { 24 | Path = $"/boards/{value}"; 25 | return this; 26 | } 27 | 28 | public GetBoardsById WithAcceptLanguage(string value) 29 | { 30 | AddHeaderParameter(Constants.AcceptLanguage, value); 31 | return this; 32 | } 33 | } -------------------------------------------------------------------------------- /UnitTests/UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | false 7 | 8 | 9 | 10 | Library 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | PreserveNewest 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /GettyImages.Api/AssetChanges/ChangeSets.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | namespace GettyImages.Api.AssetChanges; 4 | 5 | public class ChangeSets : ApiRequest 6 | { 7 | private ChangeSets(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 8 | { 9 | Credentials = credentials; 10 | BaseUrl = baseUrl; 11 | Method = "PUT"; 12 | Path = "/asset-changes/change-sets"; 13 | } 14 | 15 | internal static ChangeSets GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 16 | { 17 | return new ChangeSets(credentials, baseUrl, customHandler); 18 | } 19 | 20 | public ChangeSets WithChannelId(int value) 21 | { 22 | AppendMultiValuedQueryParameter(Constants.ChannelIdKey, value); 23 | return this; 24 | } 25 | 26 | public ChangeSets WithBatchSize(int value) 27 | { 28 | AddQueryParameter(Constants.BatchSizeKey, value); 29 | return this; 30 | } 31 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Product.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class Product 9 | { 10 | public string ApplicationWebsite { get; set; } 11 | public int? CreditsRemaining { get; set; } 12 | public int? DownloadLimit { get; set; } 13 | public string DownloadLimitDuration { get; set; } 14 | public DateTime? DownloadLimitResetUtcDate { get; set; } 15 | public int? DownloadsRemaining { get; set; } 16 | public DateTime? ExpirationUtcDate { get; set; } 17 | public int Id { get; set; } 18 | public string Name { get; set; } 19 | public string Status { get; set; } 20 | public string Type { get; set; } 21 | public DownloadRequirements DownloadRequirements { get; set; } 22 | public OverageDetails Overage { get; set; } 23 | public string AgreementName { get; set; } 24 | public string ImagepackResolution { get; set; } 25 | public int? TeamCredits { get; set; } 26 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/GetComments.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class GetComments : ApiRequest 7 | { 8 | private GetComments(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | } 14 | 15 | protected string BoardId { get; set; } 16 | 17 | internal static GetComments GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 18 | { 19 | return new GetComments(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public GetComments WithBoardId(string value) 23 | { 24 | Path = $"/boards/{value}/comments"; 25 | return this; 26 | } 27 | 28 | public GetComments WithAcceptLanguage(string value) 29 | { 30 | AddHeaderParameter(Constants.AcceptLanguage, value); 31 | return this; 32 | } 33 | } -------------------------------------------------------------------------------- /UnitTests/AiGenerator/GetGeneratedImagesTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.AiGenerator; 7 | 8 | public class GetGeneratedImagesTests : IAsyncLifetime 9 | { 10 | private string _absoluteUri; 11 | 12 | public async Task InitializeAsync() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .GetGeneratedImages() 17 | .WithGenerationRequestId("5D4F2A7A-95DA-44AC-800B-AF57B5E9E3C4") 18 | .ExecuteAsync(); 19 | 20 | _absoluteUri = testHandler.Request.RequestUri!.AbsoluteUri; 21 | 22 | } 23 | 24 | [Fact] 25 | public void UriIsExpected() 26 | { 27 | _absoluteUri.Should().Be("https://api.gettyimages.com/v3/ai/image-generations/5D4F2A7A-95DA-44AC-800B-AF57B5E9E3C4"); 28 | } 29 | 30 | public Task DisposeAsync() 31 | { 32 | return Task.CompletedTask; 33 | } 34 | } -------------------------------------------------------------------------------- /GettyImages.Api/Handlers/HeadersHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Net.Http; 3 | using System.Runtime.CompilerServices; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | [assembly: InternalsVisibleTo("UnitTests")] 8 | 9 | namespace GettyImages.Api.Handlers; 10 | 11 | internal class HeadersHandler : DelegatingHandler 12 | { 13 | private readonly IEnumerable> _headerParameters; 14 | 15 | public HeadersHandler(IEnumerable> headerParameters) 16 | { 17 | _headerParameters = headerParameters; 18 | } 19 | 20 | protected override async Task SendAsync( 21 | HttpRequestMessage request, 22 | CancellationToken cancellationToken) 23 | { 24 | if (_headerParameters != null) 25 | { 26 | foreach (var header in _headerParameters) 27 | { 28 | request.Headers.Add(header.Key, header.Value); 29 | } 30 | } 31 | 32 | return await base.SendAsync(request, cancellationToken); 33 | } 34 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 - 2022 Getty Images, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /UnitTests/AiGenerator/GetDownloadSizesTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.AiGenerator; 7 | 8 | public class GetDownloadSizesTests : IAsyncLifetime 9 | { 10 | private string _absoluteUri; 11 | 12 | public async Task InitializeAsync() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .GetDownloadSizes() 17 | .With(generationRequestId: "9BDF6A13-4C06-41C4-BF59-14D761C7233E", index: 3) 18 | .ExecuteAsync(); 19 | 20 | _absoluteUri = testHandler.Request.RequestUri!.AbsoluteUri; 21 | } 22 | 23 | [Fact] 24 | public void UriIsExpected() 25 | { 26 | _absoluteUri.Should() 27 | .Be( 28 | "https://api.gettyimages.com/v3/ai/image-generations/9BDF6A13-4C06-41C4-BF59-14D761C7233E/images/3/download-sizes"); 29 | } 30 | 31 | public Task DisposeAsync() 32 | { 33 | return Task.CompletedTask; 34 | } 35 | } -------------------------------------------------------------------------------- /UnitTests/AiGenerator/GetGeneratedImageDownloadTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.AiGenerator; 7 | 8 | public class GetGeneratedImageDownloadTests : IAsyncLifetime 9 | { 10 | private string _absoluteUri; 11 | 12 | public async Task InitializeAsync() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .GetGeneratedImageDownload() 17 | .With(generationRequestId: "CD9C0632-732C-4F8D-9F96-420B07985B50" , index: 2) 18 | .ExecuteAsync(); 19 | 20 | _absoluteUri = testHandler.Request.RequestUri!.AbsoluteUri; 21 | } 22 | 23 | [Fact] 24 | public void UriIsExpected() 25 | { 26 | _absoluteUri.Should() 27 | .Be("https://api.gettyimages.com/v3/ai/image-generations/CD9C0632-732C-4F8D-9F96-420B07985B50/images/2/download"); 28 | } 29 | 30 | public Task DisposeAsync() 31 | { 32 | return Task.CompletedTask; 33 | } 34 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/GenerateImages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using GettyImages.Api.Models; 5 | 6 | namespace GettyImages.Api.AiGenerator; 7 | 8 | public class GenerateImages : ImageGenerationsApiRequest 9 | { 10 | private GenerateImages(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | Path = "/ai/image-generations"; 16 | } 17 | 18 | internal static GenerateImages GetInstance(Credentials credentials, string baseUrl, 19 | DelegatingHandler customHandler) 20 | { 21 | return new GenerateImages(credentials, baseUrl, customHandler); 22 | } 23 | 24 | public GenerateImages WithImageGenerationsRequest(ImageGenerationsRequest value) 25 | { 26 | BodyParameter = value; 27 | return this; 28 | } 29 | 30 | public new Task ExecuteAsync() 31 | { 32 | return ExecuteAsync(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(45)); 33 | } 34 | } -------------------------------------------------------------------------------- /GettyImages.Api/Serializer.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text.Json; 3 | using System.Threading.Tasks; 4 | 5 | namespace GettyImages.Api; 6 | 7 | public static class Serializer 8 | { 9 | private static readonly JsonSerializerOptions JsonSerializerOptions = new() 10 | { 11 | PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy(), 12 | Converters = { new JsonEnumMemberStringEnumConverter() } 13 | }; 14 | 15 | public static T Deserialize(string requestString) 16 | { 17 | return JsonSerializer.Deserialize(requestString, JsonSerializerOptions); 18 | } 19 | 20 | public static async Task DeserializeAsync(Stream stream) 21 | { 22 | return await JsonSerializer.DeserializeAsync(stream, JsonSerializerOptions); 23 | } 24 | 25 | public static string Serialize(object value) 26 | { 27 | return JsonSerializer.Serialize(value, JsonSerializerOptions); 28 | } 29 | 30 | public static async Task SerializeAsync(Stream stream, object value) 31 | { 32 | await JsonSerializer.SerializeAsync(stream, value, JsonSerializerOptions); 33 | } 34 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/GetGeneratedImages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using GettyImages.Api.Models; 5 | 6 | namespace GettyImages.Api.AiGenerator; 7 | 8 | public class GetGeneratedImages : PolledPathApiRequest 9 | { 10 | private GetGeneratedImages(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | public new Task ExecuteAsync() 18 | { 19 | return ExecuteAsync(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(45)); 20 | } 21 | 22 | internal static GetGeneratedImages GetInstance(Credentials credentials, string baseUrl, 23 | DelegatingHandler customHandler) 24 | { 25 | return new GetGeneratedImages(credentials, baseUrl, customHandler); 26 | } 27 | 28 | public GetGeneratedImages WithGenerationRequestId(string generationRequestId) 29 | { 30 | Path = $"/ai/image-generations/{generationRequestId}"; 31 | return this; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /GettyImages.Api/Boards/PostComments.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class PostComments : ApiRequest 7 | { 8 | private PostComments(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "POST"; 13 | } 14 | 15 | 16 | 17 | internal static PostComments GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 18 | { 19 | return new PostComments(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public PostComments WithBoardId(string value) 23 | { 24 | Path = $"/boards/{value}/comments"; 25 | return this; 26 | } 27 | 28 | public PostComments WithComment(string value) 29 | { 30 | BodyParameter = new CommentRequest { Text = value }; 31 | return this; 32 | } 33 | 34 | public PostComments WithAcceptLanguage(string value) 35 | { 36 | AddHeaderParameter(Constants.AcceptLanguage, value); 37 | return this; 38 | } 39 | } -------------------------------------------------------------------------------- /UnitTests/Images/ImagesTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using GettyImages.Api; 5 | using Xunit; 6 | 7 | namespace UnitTests.Images; 8 | 9 | public class ImagesTests 10 | { 11 | [Fact] 12 | public async Task MultipleImagesBasic() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | 16 | var ids = new List { "882449540", "629219532" }; 17 | 18 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 19 | .Images().WithIds(ids).ExecuteAsync(); 20 | 21 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images"); 22 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("ids=882449540%2C629219532"); 23 | } 24 | 25 | [Fact] 26 | public async Task SingleImageBasic() 27 | { 28 | var testHandler = TestUtil.CreateTestHandler(); 29 | 30 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 31 | .Images().WithIds(new[] { "882449540" }).ExecuteAsync(); 32 | 33 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("ids=882449540"); 34 | } 35 | } -------------------------------------------------------------------------------- /UnitTests/Images/ImagesDownloadHistoryTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Images; 7 | 8 | public class ImagesDownloadHistoryTests 9 | { 10 | [Fact] 11 | public async Task ImageDownloadHistoryWithCompanyDownloads() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .ImageDownloadHistory().WithId("882449540").WithCompanyDownloads().ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/downloadhistory"); 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("company_downloads=True"); 20 | } 21 | 22 | [Fact] 23 | public async Task DownloadHistoryForImage() 24 | { 25 | var testHandler = TestUtil.CreateTestHandler(); 26 | 27 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 28 | .ImageDownloadHistory().WithId("882449540").ExecuteAsync(); 29 | 30 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/downloadhistory"); 31 | } 32 | } -------------------------------------------------------------------------------- /UnitTests/AssetChanges/ChangeSetsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.AssetChanges; 7 | 8 | public class ChangeSetsTests 9 | { 10 | [Fact] 11 | public async Task ChangeSetsBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .ChangeSets().WithChannelId(155432).ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("asset-changes/change-sets"); 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("channel_id=155432"); 20 | } 21 | 22 | [Fact] 23 | public async Task ChangeSetsWithBatchSize() 24 | { 25 | var testHandler = TestUtil.CreateTestHandler(); 26 | 27 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).ChangeSets() 28 | .WithChannelId(155432).WithBatchSize(200).ExecuteAsync(); 29 | 30 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("asset-changes/change-sets"); 31 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("batch_size=200"); 32 | } 33 | } -------------------------------------------------------------------------------- /UnitTests/AssetChanges/ChannelsTests.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Net.Http.Headers; 5 | using System.Threading.Tasks; 6 | using FluentAssertions; 7 | using GettyImages.Api; 8 | using GettyImages.Api.Models; 9 | using Xunit; 10 | 11 | namespace UnitTests.AssetChanges; 12 | 13 | public class ChannelsTests 14 | { 15 | [Fact] 16 | public async Task ChannelsBasic() 17 | { 18 | var channels = new[] 19 | { 20 | new Channel() 21 | }; 22 | 23 | var stream = new MemoryStream(); 24 | await Serializer.SerializeAsync(stream, channels); 25 | stream.Seek(0, SeekOrigin.Begin); 26 | var content = new StreamContent(stream); 27 | var responseMessage = new HttpResponseMessage(HttpStatusCode.OK); 28 | responseMessage.Content = content; 29 | responseMessage.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); 30 | var testHandler = new TestHandler(responseMessage); 31 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 32 | .Channels().ExecuteAsync(); 33 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("asset-changes/channels"); 34 | } 35 | } -------------------------------------------------------------------------------- /GettyImages.Api/Images/ImageDownloadHistory.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Images; 5 | 6 | public class ImageDownloadHistory : ApiRequest 7 | { 8 | private ImageDownloadHistory(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : 9 | base(customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "GET"; 14 | } 15 | 16 | internal static ImageDownloadHistory GetInstance(Credentials credentials, string baseUrl, 17 | DelegatingHandler customHandler) 18 | { 19 | return new ImageDownloadHistory(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public ImageDownloadHistory WithAcceptLanguage(string value) 23 | { 24 | AddHeaderParameter(Constants.AcceptLanguage, value); 25 | return this; 26 | } 27 | 28 | public ImageDownloadHistory WithId(string value) 29 | { 30 | Path = $"/images/{value}/downloadhistory"; 31 | return this; 32 | } 33 | 34 | public ImageDownloadHistory WithCompanyDownloads(bool value = true) 35 | { 36 | AddQueryParameter(Constants.CompanyDownloadsKey, value); 37 | return this; 38 | } 39 | } -------------------------------------------------------------------------------- /GettyImages.Api/Videos/VideoDownloadHistory.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Videos; 5 | 6 | public class VideoDownloadHistory : ApiRequest 7 | { 8 | private VideoDownloadHistory(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : 9 | base(customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "GET"; 14 | } 15 | 16 | internal static VideoDownloadHistory GetInstance(Credentials credentials, string baseUrl, 17 | DelegatingHandler customHandler) 18 | { 19 | return new VideoDownloadHistory(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public VideoDownloadHistory WithAcceptLanguage(string value) 23 | { 24 | AddHeaderParameter(Constants.AcceptLanguage, value); 25 | return this; 26 | } 27 | 28 | public VideoDownloadHistory WithId(string value) 29 | { 30 | Path = $"/videos/{value}/downloadhistory"; 31 | return this; 32 | } 33 | 34 | public VideoDownloadHistory IncludeCompanyDownloads() 35 | { 36 | AddQueryParameter(Constants.CompanyDownloadsKey, true); 37 | return this; 38 | } 39 | } -------------------------------------------------------------------------------- /UnitTests/Videos/VideosTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using GettyImages.Api; 5 | using Xunit; 6 | 7 | namespace UnitTests.Videos; 8 | 9 | public class VideosTests 10 | { 11 | [Fact] 12 | public async Task MultipleVideosBasic() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | var ids = new List { "882449540", "629219532" }; 16 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 17 | .Videos().WithIds(ids).ExecuteAsync(); 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos"); 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("ids=882449540%2C629219532"); 20 | } 21 | 22 | [Fact] 23 | public async Task SingleVideoBasic() 24 | { 25 | var testHandler = TestUtil.CreateTestHandler(); 26 | 27 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 28 | .Videos().WithId("882449540").ExecuteAsync(); 29 | 30 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos"); 31 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("ids=882449540"); 32 | } 33 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/GeneratedImageVariations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using GettyImages.Api.Models; 5 | 6 | namespace GettyImages.Api.AiGenerator; 7 | 8 | public class GeneratedImageVariations : ImageGenerationsApiRequest 9 | { 10 | private GeneratedImageVariations(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | public new Task ExecuteAsync() 18 | { 19 | return ExecuteAsync(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(45)); 20 | } 21 | 22 | internal static GeneratedImageVariations GetInstance(Credentials credentials, string baseUrl, 23 | DelegatingHandler customHandler) 24 | { 25 | return new GeneratedImageVariations(credentials, baseUrl, customHandler); 26 | } 27 | 28 | public GeneratedImageVariations With(string generationRequestId, int index, GenerationVariationsRequest generationVariationsRequest) 29 | { 30 | Path = $"/ai/image-generations/{generationRequestId}/images/{index}/variations"; 31 | BodyParameter = generationVariationsRequest; 32 | return this; 33 | } 34 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/DeleteBoardsById.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class DeleteBoardsById : ApiRequest 7 | { 8 | protected const string V3PostBoardsPath = "/boards"; 9 | 10 | private DeleteBoardsById(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | protected string BoardId { get; set; } 18 | 19 | internal static DeleteBoardsById GetInstance(Credentials credentials, string baseUrl, 20 | DelegatingHandler customHandler) 21 | { 22 | return new DeleteBoardsById(credentials, baseUrl, customHandler); 23 | } 24 | 25 | public override async Task ExecuteAsync() 26 | { 27 | Method = "DELETE"; 28 | Path = V3PostBoardsPath + "/" + BoardId; 29 | 30 | await base.ExecuteAsync(); 31 | } 32 | 33 | public DeleteBoardsById WithBoardId(string value) 34 | { 35 | BoardId = value; 36 | return this; 37 | } 38 | 39 | public DeleteBoardsById WithAcceptLanguage(string value) 40 | { 41 | AddHeaderParameter(Constants.AcceptLanguage, value); 42 | return this; 43 | } 44 | } -------------------------------------------------------------------------------- /UnitTests/Events/EventsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using GettyImages.Api; 5 | using Xunit; 6 | 7 | namespace UnitTests.Events; 8 | 9 | public class EventsTests 10 | { 11 | [Fact] 12 | public async Task MultipleEventsBasic() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | 16 | var ids = new List { 518451, 518452 }; 17 | 18 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 19 | .Events() 20 | .WithIds(ids) 21 | .ExecuteAsync(); 22 | 23 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("events"); 24 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("ids=518451%2C518452"); 25 | } 26 | 27 | [Fact] 28 | public async Task SingleEventBasic() 29 | { 30 | var testHandler = TestUtil.CreateTestHandler(); 31 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 32 | .Events() 33 | .WithId(518451) 34 | .ExecuteAsync(); 35 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("events"); 36 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("ids=518451"); 37 | } 38 | } -------------------------------------------------------------------------------- /GettyImages.Api/SdkException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Threading.Tasks; 5 | 6 | namespace GettyImages.Api; 7 | 8 | public class SdkException : Exception 9 | { 10 | internal SdkException(string message, HttpStatusCode? statusCode = null) : base(message) 11 | { 12 | StatusCode = statusCode; 13 | } 14 | 15 | // ReSharper disable once MemberCanBePrivate.Global 16 | // ReSharper disable once UnusedAutoPropertyAccessor.Global 17 | public HttpStatusCode? StatusCode { get; } 18 | 19 | internal static async Task GenerateSdkExceptionAsync(HttpResponseMessage httpResponse, string message = null) 20 | { 21 | if (httpResponse.Content != null && string.IsNullOrEmpty(message)) 22 | { 23 | message = await httpResponse.Content.ReadAsStringAsync(); 24 | } 25 | 26 | if (string.IsNullOrEmpty(message)) 27 | { 28 | message = $"{(int)httpResponse.StatusCode} - {httpResponse.ReasonPhrase}"; 29 | } 30 | 31 | switch (httpResponse.StatusCode) 32 | { 33 | case HttpStatusCode.Unauthorized: 34 | throw new UnauthorizedException(message); 35 | default: 36 | throw new SdkException(message, httpResponse.StatusCode); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /GettyImages.Api/AssetLicensing/AcquireExtendedLicense.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.AssetLicensing; 5 | 6 | public class AcquireExtendedLicense : ApiRequest 7 | { 8 | private AcquireExtendedLicense(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : 9 | base(customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "POST"; 14 | } 15 | 16 | protected string AssetId { get; set; } 17 | 18 | internal static AcquireExtendedLicense GetInstance(Credentials credentials, string baseUrl, 19 | DelegatingHandler customHandler) 20 | { 21 | return new AcquireExtendedLicense(credentials, baseUrl, customHandler); 22 | } 23 | 24 | public AcquireExtendedLicense WithAssetId(string value) 25 | { 26 | Path = $"/asset-licensing/{value}"; 27 | return this; 28 | } 29 | 30 | public AcquireExtendedLicense WithExtendedLicenses(AcquireAssetLicensesRequest value) 31 | { 32 | BodyParameter = value; 33 | return this; 34 | } 35 | 36 | public AcquireExtendedLicense WithAcceptLanguage(string value) 37 | { 38 | AddHeaderParameter(Constants.AcceptLanguage, value); 39 | return this; 40 | } 41 | } -------------------------------------------------------------------------------- /UnitTests/Videos/VideosDownloadHistoryTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Videos; 7 | 8 | public class VideosDownloadHistoryTests 9 | { 10 | [Fact] 11 | public async Task ImageDownloadHistoryWithCompanyDownloads() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 16 | .VideoDownloadHistory() 17 | .WithId("882449540") 18 | .IncludeCompanyDownloads() 19 | .ExecuteAsync(); 20 | 21 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/downloadhistory"); 22 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("company_downloads=True"); 23 | } 24 | 25 | [Fact] 26 | public async Task DownloadHistoryForImage() 27 | { 28 | var testHandler = TestUtil.CreateTestHandler(); 29 | 30 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 31 | .VideoDownloadHistory() 32 | .WithId("882449540") 33 | .ExecuteAsync(); 34 | 35 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/downloadhistory"); 36 | } 37 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/GetGeneratedImageDownload.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using GettyImages.Api.Models; 5 | 6 | namespace GettyImages.Api.AiGenerator; 7 | 8 | public class GetGeneratedImageDownload : PolledPathApiRequest 9 | { 10 | private GetGeneratedImageDownload(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | internal static GetGeneratedImageDownload GetInstance(Credentials credentials, string baseUrl, 18 | DelegatingHandler customHandler) 19 | { 20 | return new GetGeneratedImageDownload(credentials, baseUrl, customHandler); 21 | } 22 | 23 | public GetGeneratedImageDownload With(string generationRequestId, int index) 24 | { 25 | Path = $"/ai/image-generations/{generationRequestId}/images/{index}/download"; 26 | return this; 27 | } 28 | 29 | internal GetGeneratedImageDownload WithPath(string path) 30 | { 31 | Path = path; 32 | return this; 33 | } 34 | 35 | public new Task ExecuteAsync() 36 | { 37 | return ExecuteAsync(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(45)); 38 | } 39 | } -------------------------------------------------------------------------------- /GettyImages.Api/Events/Events.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Net.Http; 3 | using GettyImages.Api.Models; 4 | 5 | namespace GettyImages.Api.Events; 6 | 7 | public class Events : ApiRequest 8 | { 9 | 10 | private Events(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 11 | { 12 | Credentials = credentials; 13 | BaseUrl = baseUrl; 14 | Method = "GET"; 15 | Path = "/events"; 16 | 17 | AddResponseFields(new[] 18 | { 19 | "id", "child_event_count", "editorial_segments", "hero_image", "image_count", "location", "name", "start_date", 20 | "type" 21 | }); 22 | } 23 | 24 | internal static Events GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 25 | { 26 | return new Events(credentials, baseUrl, customHandler); 27 | } 28 | 29 | public Events WithId(int value) 30 | { 31 | AddIds(new []{ value }); 32 | return this; 33 | } 34 | 35 | public Events WithIds(IEnumerable value) 36 | { 37 | AddIds(value); 38 | return this; 39 | } 40 | 41 | public Events WithAcceptLanguage(string value) 42 | { 43 | AddHeaderParameter(Constants.AcceptLanguage, value); 44 | return this; 45 | } 46 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/PutAssets.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Net.Http; 4 | using GettyImages.Api.Models; 5 | 6 | namespace GettyImages.Api.Boards; 7 | 8 | public class PutAssets : ApiRequest 9 | { 10 | private PutAssets(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 11 | { 12 | Credentials = credentials; 13 | BaseUrl = baseUrl; 14 | Method = "PUT"; 15 | } 16 | 17 | internal static PutAssets GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 18 | { 19 | return new PutAssets(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public PutAssets WithBoardId(string value) 23 | { 24 | Path = $"/boards/{value}/assets"; 25 | return this; 26 | } 27 | 28 | public PutAssets WithBoardAssets(string value) 29 | { 30 | StringBodyParameter = value; 31 | return this; 32 | } 33 | 34 | public PutAssets WithAssetIds(IEnumerable value) 35 | { 36 | BodyParameter = value.Select(id => new BoardAsset { AssetId = id }); 37 | return this; 38 | } 39 | 40 | public PutAssets WithAcceptLanguage(string value) 41 | { 42 | AddHeaderParameter(Constants.AcceptLanguage, value); 43 | return this; 44 | } 45 | } -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | false 6 | true 7 | d1cf09c6-abcf-4f7b-afa2-4c863511c6d8 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | all 18 | 19 | 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | all 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /UnitTests/AssetLicensing/AcquireExtendedLicenseTests.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using GettyImages.Api; 5 | using GettyImages.Api.Models; 6 | using Xunit; 7 | 8 | namespace UnitTests.AssetLicensing; 9 | 10 | public class AcquireExtendedLicenseTests 11 | { 12 | [Fact] 13 | public async Task AcquireExtendedLicenseBasic() 14 | { 15 | var testHandler = TestUtil.CreateTestHandler(); 16 | var requestBody = new AcquireAssetLicensesRequest 17 | { 18 | ExtendedLicenses = new[] { ExtendedLicense.Multiseat }, 19 | UseTeamCredits = true 20 | }; 21 | 22 | var assetId = "123"; 23 | await ApiClient 24 | .GetApiClientWithResourceOwnerCredentials("apiKey", "apiSecret", "userName", "userPassword", testHandler) 25 | .AcquireExtendedLicense() 26 | .WithAssetId(assetId) 27 | .WithExtendedLicenses(requestBody) 28 | .ExecuteAsync(); 29 | 30 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain($"/asset-licensing/{assetId}"); 31 | var requestString = await testHandler.Request.Content.ReadAsStringAsync(); 32 | var content = Serializer.Deserialize(requestString); 33 | content.ExtendedLicenses.First().Should().Be(ExtendedLicense.Multiseat); 34 | content.UseTeamCredits.Should().BeTrue(); 35 | } 36 | } -------------------------------------------------------------------------------- /UnitTests/HeaderAndBody/BodyTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using GettyImages.Api.Boards; 5 | using GettyImages.Api.Models; 6 | using Xunit; 7 | 8 | namespace UnitTests.HeaderAndBody; 9 | 10 | public class BodyTests 11 | { 12 | [Fact] 13 | public void BodyParameterTest() 14 | { 15 | var postBoards = PostBoards.GetInstance(null, null, null); 16 | 17 | var description = "This board is for integration tests"; 18 | var name = "Test Board"; 19 | postBoards.WithNewBoard(new BoardInfo 20 | { 21 | Name = name, 22 | Description = description 23 | }); 24 | 25 | ((BoardInfo)postBoards.BodyParameter).Description.Should().Be(description); 26 | ((BoardInfo)postBoards.BodyParameter).Name.Should().Be(name); 27 | } 28 | 29 | [Fact] 30 | public async Task BodyBuilderTest() 31 | { 32 | var testHandler = TestUtil.CreateTestHandler(); 33 | 34 | var assets = @"[ 35 | { 36 | 'asset_id': 'string' 37 | } 38 | ]"; 39 | 40 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 41 | .PutAssets().WithBoardId("15345").WithBoardAssets(assets).ExecuteAsync(); 42 | 43 | Assert.Equal("application/json", testHandler.Request.Content.Headers.ContentType.ToString()); 44 | } 45 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/PutBoardsById.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | using GettyImages.Api.Models; 4 | 5 | namespace GettyImages.Api.Boards; 6 | 7 | public class PutBoardsById : ApiRequest 8 | { 9 | protected const string V3PostBoardsPath = "/boards"; 10 | 11 | private PutBoardsById(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 12 | customHandler) 13 | { 14 | Credentials = credentials; 15 | BaseUrl = baseUrl; 16 | } 17 | 18 | protected string BoardId { get; set; } 19 | 20 | internal static PutBoardsById GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 21 | { 22 | return new PutBoardsById(credentials, baseUrl, customHandler); 23 | } 24 | 25 | public override async Task ExecuteAsync() 26 | { 27 | Method = "PUT"; 28 | Path = V3PostBoardsPath + "/" + BoardId; 29 | 30 | await base.ExecuteAsync(); 31 | } 32 | 33 | public PutBoardsById WithBoardId(string value) 34 | { 35 | BoardId = value; 36 | return this; 37 | } 38 | 39 | public PutBoardsById WithBoardInfo(BoardInfo value) 40 | { 41 | BodyParameter = value; 42 | return this; 43 | } 44 | 45 | public PutBoardsById WithAcceptLanguage(string value) 46 | { 47 | AddHeaderParameter(Constants.AcceptLanguage, value); 48 | return this; 49 | } 50 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/DeleteAssets.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | 5 | namespace GettyImages.Api.Boards; 6 | 7 | public class DeleteAssets : ApiRequest 8 | { 9 | protected const string V3DeleteAssetsPath = "/boards/{0}/assets"; 10 | 11 | private DeleteAssets(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | protected string BoardId { get; set; } 18 | 19 | internal static DeleteAssets GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 20 | { 21 | return new DeleteAssets(credentials, baseUrl, customHandler); 22 | } 23 | 24 | public override async Task ExecuteAsync() 25 | { 26 | Method = "DELETE"; 27 | Path = string.Format(V3DeleteAssetsPath, BoardId); 28 | 29 | await base.ExecuteAsync(); 30 | } 31 | 32 | public DeleteAssets WithBoardId(string value) 33 | { 34 | BoardId = value; 35 | return this; 36 | } 37 | 38 | public DeleteAssets WithAssetIds(IEnumerable value) 39 | { 40 | AddAssetIds(value); 41 | return this; 42 | } 43 | 44 | public DeleteAssets WithAcceptLanguage(string value) 45 | { 46 | AddHeaderParameter(Constants.AcceptLanguage, value); 47 | return this; 48 | } 49 | } -------------------------------------------------------------------------------- /UnitTests/Usage/UsageBatchesTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using FluentAssertions; 5 | using GettyImages.Api; 6 | using GettyImages.Api.Models; 7 | using Xunit; 8 | 9 | namespace UnitTests.Usage; 10 | 11 | public class UsageBatchesTests 12 | { 13 | [Fact] 14 | public async Task UsageBatchesBasic() 15 | { 16 | var testHandler = TestUtil.CreateTestHandler(); 17 | 18 | // var request = @"{ 19 | // 'asset_usages': [ 20 | // { 21 | // 'asset_id': 'string', 22 | // 'quantity': 0, 23 | // 'usage_date': '2018-02-12T15:52:59.833Z' 24 | // } 25 | // ] 26 | // }"; 27 | var request = new ReportUsageBatchRequest 28 | { 29 | AssetUsages = new[] 30 | { 31 | new AssetUsage 32 | { 33 | Quantity = 10, 34 | AssetId = "test-asset", 35 | UsageDate = DateTime.UtcNow 36 | } 37 | } 38 | }; 39 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).UsageBatches() 40 | .WithId("464423888").WithRequest(request).ExecuteAsync(); 41 | 42 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("usage-batches/464423888"); 43 | testHandler.Request.Method.Should().Be(HttpMethod.Put); 44 | } 45 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/PutAssetsById.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class PutAssetsById : ApiRequest 7 | { 8 | protected const string V3PutAssetByIdPath = "/boards/{0}/assets/{1}"; 9 | 10 | private PutAssetsById(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | protected string BoardId { get; set; } 18 | protected string AssetId { get; set; } 19 | 20 | internal static PutAssetsById GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 21 | { 22 | return new PutAssetsById(credentials, baseUrl, customHandler); 23 | } 24 | 25 | public override async Task ExecuteAsync() 26 | { 27 | Method = "PUT"; 28 | Path = string.Format(V3PutAssetByIdPath, BoardId, AssetId); 29 | await base.ExecuteAsync(); 30 | } 31 | 32 | public PutAssetsById WithBoardId(string value) 33 | { 34 | BoardId = value; 35 | return this; 36 | } 37 | 38 | public PutAssetsById WithAssetId(string value) 39 | { 40 | AssetId = value; 41 | return this; 42 | } 43 | 44 | public PutAssetsById WithAcceptLanguage(string value) 45 | { 46 | AddHeaderParameter(Constants.AcceptLanguage, value); 47 | return this; 48 | } 49 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/DeleteAssetsById.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class DeleteAssetsById : ApiRequest 7 | { 8 | protected const string V3DeleteAssetByIdPath = "/boards/{0}/assets/{1}"; 9 | 10 | private DeleteAssetsById(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | protected string BoardId { get; set; } 18 | protected string AssetId { get; set; } 19 | 20 | internal static DeleteAssetsById GetInstance(Credentials credentials, string baseUrl, 21 | DelegatingHandler customHandler) 22 | { 23 | return new DeleteAssetsById(credentials, baseUrl, customHandler); 24 | } 25 | 26 | public override async Task ExecuteAsync() 27 | { 28 | Method = "DELETE"; 29 | Path = string.Format(V3DeleteAssetByIdPath, BoardId, AssetId); 30 | 31 | await base.ExecuteAsync(); 32 | } 33 | 34 | public DeleteAssetsById WithBoardId(string value) 35 | { 36 | BoardId = value; 37 | return this; 38 | } 39 | 40 | public DeleteAssetsById WithAssetId(string value) 41 | { 42 | AssetId = value; 43 | return this; 44 | } 45 | 46 | public DeleteAssetsById WithAcceptLanguage(string value) 47 | { 48 | AddHeaderParameter(Constants.AcceptLanguage, value); 49 | return this; 50 | } 51 | } -------------------------------------------------------------------------------- /UnitTests/HeaderAndBody/HeadersTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net.Http; 4 | using System.Threading; 5 | using GettyImages.Api; 6 | using GettyImages.Api.Search; 7 | using Xunit; 8 | 9 | namespace UnitTests.HeaderAndBody; 10 | 11 | public class HeadersTests 12 | { 13 | [Fact] 14 | public void HeadersParameterTest() 15 | { 16 | var searchImages = SearchImagesCreative.GetInstance(null, null, null); 17 | 18 | searchImages.WithAcceptLanguage("fr"); 19 | 20 | searchImages.WithGICountryCode("FRA"); 21 | 22 | Assert.Equal("fr", searchImages.HeaderParameters[Constants.AcceptLanguage]); 23 | 24 | Assert.Equal("FRA", searchImages.HeaderParameters[Constants.GICountryCode]); 25 | } 26 | 27 | [Fact] 28 | public async void HeadersHandlerTest() 29 | { 30 | var h = new KeyValuePair("Accept-Language", "fr"); 31 | IEnumerable> header = new List> { h }; 32 | var request = new HttpRequestMessage(); 33 | var headerHandler = new TestHeadersHandler(header); 34 | 35 | try 36 | { 37 | await headerHandler.SendAsync(request, new CancellationToken()); 38 | } 39 | catch (InvalidOperationException) 40 | { 41 | //No inner handler being assigned to HeadersHandler for test so catch needed for expected exception. 42 | } 43 | 44 | Assert.Equal("fr", request.Headers.AcceptLanguage.ToString()); 45 | } 46 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/ImageGenerationsApiRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Threading.Tasks; 5 | using GettyImages.Api.Models; 6 | 7 | namespace GettyImages.Api.AiGenerator; 8 | 9 | public abstract class ImageGenerationsApiRequest : ApiRequest 10 | { 11 | protected ImageGenerationsApiRequest(DelegatingHandler customHandler) : base(customHandler) 12 | { 13 | } 14 | 15 | public async Task ExecuteAsync(TimeSpan pollDelay, TimeSpan timeout) 16 | { 17 | var helper = new WebHelper(Credentials, BaseUrl, _customHandler); 18 | 19 | var httpResponseMessage = await helper.PostQueryRawHttpResponseMessageAsync(BuildQuery(QueryParameters), 20 | path: Path, BuildHeaders(HeaderParameters), BuildBody()); 21 | 22 | await httpResponseMessage.HandleResponseAsync(); 23 | 24 | if (httpResponseMessage.StatusCode == HttpStatusCode.Accepted) 25 | { 26 | var generationRequestId = httpResponseMessage.HandleGetContentResponseAsync().Result.GenerationRequestId; 27 | var generatedImages = GetGeneratedImages.GetInstance(Credentials, BaseUrl, _customHandler).WithGenerationRequestId(generationRequestId); 28 | return await generatedImages.ExecuteAsync(pollDelay, timeout); 29 | } 30 | 31 | await httpResponseMessage.HandleResponseAsync(); 32 | return await httpResponseMessage.HandleGetContentResponseAsync(); 33 | } 34 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/DeleteCommentsById.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading.Tasks; 3 | 4 | namespace GettyImages.Api.Boards; 5 | 6 | public class DeleteCommentsById : ApiRequest 7 | { 8 | protected const string V3DeleteCommentByIdPath = "/boards/{0}/comments/{1}"; 9 | 10 | private DeleteCommentsById(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 11 | customHandler) 12 | { 13 | Credentials = credentials; 14 | BaseUrl = baseUrl; 15 | } 16 | 17 | protected string BoardId { get; set; } 18 | protected string CommentId { get; set; } 19 | 20 | internal static DeleteCommentsById GetInstance(Credentials credentials, string baseUrl, 21 | DelegatingHandler customHandler) 22 | { 23 | return new DeleteCommentsById(credentials, baseUrl, customHandler); 24 | } 25 | 26 | public override async Task ExecuteAsync() 27 | { 28 | Method = "DELETE"; 29 | Path = string.Format(V3DeleteCommentByIdPath, BoardId, CommentId); 30 | 31 | await base.ExecuteAsync(); 32 | } 33 | 34 | public DeleteCommentsById WithBoardId(string value) 35 | { 36 | BoardId = value; 37 | return this; 38 | } 39 | 40 | public DeleteCommentsById WithCommentId(string value) 41 | { 42 | CommentId = value; 43 | return this; 44 | } 45 | 46 | public DeleteCommentsById WithAcceptLanguage(string value) 47 | { 48 | AddHeaderParameter(Constants.AcceptLanguage, value); 49 | return this; 50 | } 51 | } -------------------------------------------------------------------------------- /UnitTests/TestHandler.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using GettyImages.Api; 7 | 8 | namespace UnitTests; 9 | 10 | public class TestHandler : DelegatingHandler 11 | { 12 | private readonly HttpResponseMessage _httpResponseMessage; 13 | public int NumberOfCallsSendAsync; 14 | 15 | public TestHandler(object testResponse) 16 | { 17 | var stream = new MemoryStream(); 18 | Serializer.SerializeAsync(stream, testResponse).Wait(); 19 | _httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) 20 | { 21 | Content = new StreamContent(stream) 22 | }; 23 | stream.Seek(0, SeekOrigin.Begin); 24 | } 25 | 26 | public TestHandler(HttpResponseMessage httpResponseMessage) 27 | { 28 | _httpResponseMessage = httpResponseMessage; 29 | } 30 | 31 | public HttpRequestMessage Request { get; private set; } 32 | public Stream RequestStream { get; set; } 33 | 34 | protected override async Task SendAsync(HttpRequestMessage request, 35 | CancellationToken cancellationToken) 36 | { 37 | if (request.Content != null) 38 | { 39 | await request.Content.LoadIntoBufferAsync(); 40 | RequestStream = await request.Content.ReadAsStreamAsync(cancellationToken); 41 | RequestStream.Seek(0, SeekOrigin.Begin); 42 | } 43 | 44 | NumberOfCallsSendAsync += 1; 45 | Request = request; 46 | return _httpResponseMessage; 47 | } 48 | } -------------------------------------------------------------------------------- /GettyImages.Api/Boards/GetBoards.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | using BoardRelationship = GettyImages.Api.Models.BoardRelationship; 4 | 5 | namespace GettyImages.Api.Boards; 6 | 7 | public class GetBoards : ApiRequest 8 | { 9 | private GetBoards(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "GET"; 14 | Path = "/boards"; 15 | } 16 | 17 | internal static GetBoards GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 18 | { 19 | return new GetBoards(credentials, baseUrl, customHandler); 20 | } 21 | 22 | public GetBoards WithAcceptLanguage(string value) 23 | { 24 | AddHeaderParameter(Constants.AcceptLanguage, value); 25 | return this; 26 | } 27 | 28 | public GetBoards WithBoardRelationship(BoardRelationship value) 29 | { 30 | AddQueryParameter(Constants.BoardRelationshipKey, value); 31 | return this; 32 | } 33 | 34 | public GetBoards WithPage(int value) 35 | { 36 | AddQueryParameter(Constants.PageKey, value); 37 | return this; 38 | } 39 | 40 | public GetBoards WithPageSize(int value) 41 | { 42 | AddQueryParameter(Constants.PageSizeKey, value); 43 | return this; 44 | } 45 | 46 | public GetBoards WithSortOrder(SortOrderBoards value) 47 | { 48 | AddQueryParameter(Constants.SortOrderKey, value); 49 | return this; 50 | } 51 | } -------------------------------------------------------------------------------- /GettyImages.Api/GettyImages.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 0.0.0 7 | Getty Images 8 | Getty Images 9 | Getty Images API SDK 10 | Getty Images API SDK 11 | Allows easy integration with the Getty Images API. 12 | Copyright © 2014 - 2018 Getty Images 13 | Getty Images Videos API SDK GettyImages Photo Photos Search Creative Editorial Artist Embed 14 | LICENSE 15 | https://github.com/gettyimages/gettyimages-api_dotnet 16 | package-icon.jpg 17 | https://github.com/gettyimages/gettyimages-api_dotnet 18 | GitHub 19 | 10 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /UnitTests/Images/ImagesSimilarTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Images; 7 | 8 | public class ImagesSimilarTests 9 | { 10 | [Fact] 11 | public async Task ImagesSimilarBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 15 | .ImagesSimilar().WithId("882449540").ExecuteAsync(); 16 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/similar"); 17 | } 18 | 19 | 20 | [Fact] 21 | public async Task ImagesSimilarWithPage() 22 | { 23 | var testHandler = TestUtil.CreateTestHandler(); 24 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 25 | .ImagesSimilar().WithId("882449540").WithPage(3).ExecuteAsync(); 26 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/similar"); 27 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page=3"); 28 | } 29 | 30 | [Fact] 31 | public async Task ImagesSimilarWithPageSize() 32 | { 33 | var testHandler = TestUtil.CreateTestHandler(); 34 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 35 | .ImagesSimilar().WithId("882449540").WithPageSize(50).ExecuteAsync(); 36 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/similar"); 37 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page_size=50"); 38 | } 39 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageSearchItemCreative.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace GettyImages.Api.Models; 8 | 9 | public class ImageSearchItemCreative 10 | { 11 | public AllowedUse AllowedUse { get; set; } 12 | public Dictionary AlternativeIds { get; set; } 13 | public string Artist { get; set; } 14 | public string AssetFamily { get; set; } 15 | public bool CallForImage { get; set; } 16 | public string Caption { get; set; } 17 | public string CollectionCode { get; set; } 18 | public int CollectionId { get; set; } 19 | public string CollectionName { get; set; } 20 | public string ColorType { get; set; } 21 | public string Copyright { get; set; } 22 | public DateTime? DateCameraShot { get; set; } 23 | public DateTime? DateCreated { get; set; } 24 | public AssetSearchItemDisplaySize[] DisplaySizes { get; set; } 25 | public string DownloadProduct { get; set; } 26 | public DownloadSize[] DownloadSizes { get; set; } 27 | public string GraphicalStyle { get; set; } 28 | public string Id { get; set; } 29 | public CreativeKeyword[] Keywords { get; set; } 30 | public Download[] LargestDownloads { get; set; } 31 | public string LicenseModel { get; set; } 32 | public MaxDimensions MaxDimensions { get; set; } 33 | public string Orientation { get; set; } 34 | public int QualityRank { get; set; } 35 | public ReferralDestination[] ReferralDestinations { get; set; } 36 | public string Title { get; set; } 37 | public string UriOembed { get; set; } 38 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ArtistAssetSearchItem.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace GettyImages.Api.Models; 8 | 9 | public class ArtistAssetSearchItem 10 | { 11 | public ArtistAssetSearchAllowedUse AllowedUse { get; set; } 12 | public Dictionary AlternativeIds { get; set; } 13 | public string Artist { get; set; } 14 | public string AssetFamily { get; set; } 15 | public string AssetType { get; set; } 16 | public bool CallForImage { get; set; } 17 | public string Caption { get; set; } 18 | public string ClipLength { get; set; } 19 | public string CollectionCode { get; set; } 20 | public int? CollectionId { get; set; } 21 | public string CollectionName { get; set; } 22 | public string Copyright { get; set; } 23 | public DateTime DateSubmitted { get; set; } 24 | public DateTime DateCreated { get; set; } 25 | public AssetSearchItemDisplaySize[] DisplaySizes { get; set; } 26 | public string[] EditorialSegments { get; set; } 27 | public int[] EventIds { get; set; } 28 | public string GraphicalStyle { get; set; } 29 | public string Id { get; set; } 30 | public ArtistAssetSearchKeyword[] Keywords { get; set; } 31 | public string LicenseModel { get; set; } 32 | public MaxDimensions MaxDimensions { get; set; } 33 | public string Orientation { get; set; } 34 | public string[] ProductTypes { get; set; } 35 | public int QualityRank { get; set; } 36 | public ReferralDestination[] ReferralDestinations { get; set; } 37 | public string Title { get; set; } 38 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/CreativeVideoSearchItem.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class CreativeVideoSearchItem 9 | { 10 | public string Id { get; set; } 11 | public AllowedUse AllowedUse { get; set; } 12 | public string Artist { get; set; } 13 | public string AspectRatio { get; set; } 14 | public string AssetFamily { get; set; } 15 | public string Caption { get; set; } 16 | public string ClipLength { get; set; } 17 | public int CollectionId { get; set; } 18 | public string CollectionCode { get; set; } 19 | public string CollectionName { get; set; } 20 | public string ColorType { get; set; } 21 | public string Copyright { get; set; } 22 | public DateTime DateCreated { get; set; } 23 | public VideoSearchItemDisplaySize[] DisplaySizes { get; set; } 24 | public string DownloadProduct { get; set; } 25 | public VideoDownloadSize[] DownloadSizes { get; set; } 26 | public string Era { get; set; } 27 | public int[] EventIds { get; set; } 28 | public CreativeKeyword[] Keywords { get; set; } 29 | public Download[] LargestDownloads { get; set; } 30 | public string LicenseModel { get; set; } 31 | public string MasteredTo { get; set; } 32 | public string Orientation { get; set; } 33 | public string OriginallyShotOn { get; set; } 34 | public string[] ProductTypes { get; set; } 35 | public ReferralDestination[] ReferralDestinations { get; set; } 36 | public string ShotSpeed { get; set; } 37 | public string Title { get; set; } 38 | public IStockLicense[] IstockLicenses { get; set; } 39 | } -------------------------------------------------------------------------------- /UnitTests/Search/SearchImagesCreativeByImageTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Search; 7 | 8 | public class SearchImagesCreativeByImageTests 9 | { 10 | [Fact] 11 | public async Task SearchForCreativeImagesWithUrl() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | var unitUnderTest = ApiClient.GetApiClientWithClientCredentials("apiKey", 15 | "apiSecret", 16 | testHandler) 17 | .SearchImagesCreativeByImage(); 18 | await unitUnderTest 19 | .AddToBucketAndSearchAsync("test-image.jpg"); 20 | testHandler.Request.RequestUri.AbsoluteUri.Should() 21 | .StartWith("https://api.gettyimages.com/v3/search/by-image/uploads"); 22 | 23 | await unitUnderTest.ExecuteAsync(); 24 | testHandler.Request.RequestUri.AbsoluteUri.Should() 25 | .StartWith("https://api.gettyimages.com/v3/search/images/creative/by-image"); 26 | } 27 | 28 | [Fact] 29 | public async Task SearchForCreativeImagesWithAssetId() 30 | { 31 | var testHandler = TestUtil.CreateTestHandler(); 32 | var unitUnderTest = ApiClient.GetApiClientWithClientCredentials("apiKey", 33 | "apiSecret", 34 | testHandler) 35 | .SearchImagesCreativeByImage() 36 | .WithAssetId("464423888"); 37 | 38 | await unitUnderTest.ExecuteAsync(); 39 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/images/creative/by-image"); 40 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("asset_id=464423888"); 41 | } 42 | } -------------------------------------------------------------------------------- /UnitTests/Search/SearchVideosCreativeByImageTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Search; 7 | 8 | public class SearchVideosCreativeByImageTests 9 | { 10 | [Fact] 11 | public async Task SearchForCreativeVideosWithUrl() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | var unitUnderTest = ApiClient.GetApiClientWithClientCredentials("apiKey", 15 | "apiSecret", 16 | testHandler) 17 | .SearchVideosCreativeByImage(); 18 | await unitUnderTest 19 | .AddToBucketAndSearchAsync("test-image.jpg"); 20 | testHandler.Request.RequestUri.AbsoluteUri.Should() 21 | .StartWith("https://api.gettyimages.com/v3/search/by-image/uploads"); 22 | 23 | await unitUnderTest.ExecuteAsync(); 24 | testHandler.Request.RequestUri.AbsoluteUri.Should() 25 | .StartWith("https://api.gettyimages.com/v3/search/videos/creative/by-image"); 26 | } 27 | 28 | [Fact] 29 | public async Task SearchForCreativeVideosWithAssetId() 30 | { 31 | var testHandler = TestUtil.CreateTestHandler(); 32 | var unitUnderTest = ApiClient.GetApiClientWithClientCredentials("apiKey", 33 | "apiSecret", 34 | testHandler) 35 | .SearchVideosCreativeByImage() 36 | .WithAssetId("681332124"); 37 | 38 | await unitUnderTest.ExecuteAsync(); 39 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("search/videos/creative/by-image"); 40 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("asset_id=681332124"); 41 | } 42 | } -------------------------------------------------------------------------------- /GettyImages.Api/PolledPathApiRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace GettyImages.Api; 8 | 9 | public abstract class PolledPathApiRequest : ApiRequest 10 | { 11 | protected PolledPathApiRequest(DelegatingHandler customHandler) : base(customHandler) 12 | { 13 | } 14 | 15 | public async Task ExecuteAsync(TimeSpan pollDelay, TimeSpan timeout) 16 | { 17 | var helper = new WebHelper(Credentials, BaseUrl, _customHandler); 18 | 19 | HttpResponseMessage httpResponseMessage; 20 | 21 | try 22 | { 23 | var cancellationTokenWithTimeout = new CancellationTokenSource(timeout); 24 | 25 | var loopDelay = TimeSpan.Zero; 26 | 27 | do 28 | { 29 | await Task.Delay(loopDelay, cancellationTokenWithTimeout.Token); 30 | 31 | httpResponseMessage = await helper.GetRawHttpResponseMessageAsync(BuildQuery(QueryParameters), 32 | path: Path, BuildHeaders(HeaderParameters), cancellationTokenWithTimeout.Token); 33 | loopDelay = pollDelay; 34 | } while (httpResponseMessage.StatusCode == HttpStatusCode.Accepted); 35 | 36 | cancellationTokenWithTimeout.Token.ThrowIfCancellationRequested(); 37 | } 38 | catch (OperationCanceledException) 39 | { 40 | throw new SdkException("Call timed out", HttpStatusCode.GatewayTimeout); 41 | } 42 | 43 | await httpResponseMessage.HandleResponseAsync(); 44 | 45 | return await httpResponseMessage.HandleGetContentResponseAsync(); 46 | } 47 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/EditorialVideoSearchItem.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class EditorialVideoSearchItem 9 | { 10 | public string Source { get; set; } 11 | public string Id { get; set; } 12 | public AllowedUse AllowedUse { get; set; } 13 | public string Artist { get; set; } 14 | public string AspectRatio { get; set; } 15 | public string AssetFamily { get; set; } 16 | public string Caption { get; set; } 17 | public string ClipLength { get; set; } 18 | public int CollectionId { get; set; } 19 | public string CollectionCode { get; set; } 20 | public string CollectionName { get; set; } 21 | public string ColorType { get; set; } 22 | public string Copyright { get; set; } 23 | public DateTime DateCreated { get; set; } 24 | public VideoSearchItemDisplaySize[] DisplaySizes { get; set; } 25 | public string DownloadProduct { get; set; } 26 | public VideoDownloadSize[] DownloadSizes { get; set; } 27 | public string Era { get; set; } 28 | public int[] EventIds { get; set; } 29 | public Keyword[] Keywords { get; set; } 30 | public Download[] LargestDownloads { get; set; } 31 | public string LicenseModel { get; set; } 32 | public string MasteredTo { get; set; } 33 | public string Orientation { get; set; } 34 | public string OriginallyShotOn { get; set; } 35 | public string[] ProductTypes { get; set; } 36 | public ReferralDestination[] ReferralDestinations { get; set; } 37 | public string ShotSpeed { get; set; } 38 | public string Title { get; set; } 39 | public IStockLicense[] IstockLicenses { get; set; } 40 | } -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [released] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - name: Setup .NET 13 | uses: actions/setup-dotnet@v4 14 | with: 15 | dotnet-version: 8.0.x 16 | - name: Restore dependencies 17 | run: dotnet restore 18 | - name: 'Get Previous tag' 19 | id: previoustag 20 | uses: "WyriHaximus/github-action-get-previous-tag@v1" 21 | - name: Set version 22 | run: | 23 | sed -i -e "s/>0.0.0${{ steps.previoustag.outputs.tag }} 7 | { 8 | private DownloadsVideos(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 9 | customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "POST"; 14 | AddQueryParameter(Constants.AutoDownloadKey, false); 15 | } 16 | 17 | internal static DownloadsVideos GetInstance(Credentials credentials, string baseUrl, 18 | DelegatingHandler customHandler) 19 | { 20 | return new DownloadsVideos(credentials, baseUrl, customHandler); 21 | } 22 | 23 | public DownloadsVideos WithId(string value) 24 | { 25 | Path = $"/downloads/videos/{value}"; 26 | return this; 27 | } 28 | 29 | public DownloadsVideos WithAcceptLanguage(string value) 30 | { 31 | AddHeaderParameter(Constants.AcceptLanguage, value); 32 | return this; 33 | } 34 | 35 | public DownloadsVideos WithDownloadDetails(DownloadDetails value) 36 | { 37 | BodyParameter = value; 38 | return this; 39 | } 40 | 41 | public DownloadsVideos WithProductId(int value) 42 | { 43 | AddQueryParameter(Constants.ProductIdKey, value); 44 | return this; 45 | } 46 | 47 | public DownloadsVideos WithSize(string value) 48 | { 49 | AddQueryParameter(Constants.SizeKey, value); 50 | return this; 51 | } 52 | 53 | public DownloadsVideos WithUseTeamCredits(bool value = true) 54 | { 55 | AddQueryParameter(Constants.UseTeamCredits, value); 56 | return this; 57 | } 58 | } -------------------------------------------------------------------------------- /GettyImages.Api/Purchases/PurchasedAssets.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using GettyImages.Api.Models; 4 | 5 | namespace GettyImages.Api.Purchases; 6 | 7 | public class PurchasedAssets : ApiRequest 8 | { 9 | private PurchasedAssets(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 10 | customHandler) 11 | { 12 | Credentials = credentials; 13 | BaseUrl = baseUrl; 14 | Method = "GET"; 15 | Path = "/purchased-assets"; 16 | } 17 | 18 | internal static PurchasedAssets GetInstance(Credentials credentials, string baseUrl, 19 | DelegatingHandler customHandler) 20 | { 21 | return new PurchasedAssets(credentials, baseUrl, customHandler); 22 | } 23 | 24 | public PurchasedAssets WithAcceptLanguage(string value) 25 | { 26 | AddHeaderParameter(Constants.AcceptLanguage, value); 27 | return this; 28 | } 29 | 30 | public PurchasedAssets WithDateTo(DateTime value) 31 | { 32 | AddQueryParameter(Constants.DateToKey, value); 33 | return this; 34 | } 35 | 36 | public PurchasedAssets WithPage(int value) 37 | { 38 | AddQueryParameter(Constants.PageKey, value); 39 | return this; 40 | } 41 | 42 | public PurchasedAssets WithPageSize(int value) 43 | { 44 | AddQueryParameter(Constants.PageSizeKey, value); 45 | return this; 46 | } 47 | 48 | public PurchasedAssets WithDateFrom(DateTime value) 49 | { 50 | AddQueryParameter(Constants.DateFromKey, value); 51 | return this; 52 | } 53 | 54 | public PurchasedAssets IncludeCompanyPurchases() 55 | { 56 | AddQueryParameter(Constants.CompanyPurchasesKey, true); 57 | return this; 58 | } 59 | } -------------------------------------------------------------------------------- /UnitTests/Images/ImagesSameSeriesTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using GettyImages.Api; 3 | using System.Threading.Tasks; 4 | using Xunit; 5 | 6 | namespace UnitTests.Images 7 | { 8 | public class ImagesSameSeriesTests 9 | { 10 | [Fact] 11 | public async Task ImagesSameSeriesBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 15 | .ImagesSameSeries().WithId("882449540").ExecuteAsync(); 16 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/same-series"); 17 | } 18 | 19 | 20 | [Fact] 21 | public async Task ImagesSameSeriesWithPage() 22 | { 23 | var testHandler = TestUtil.CreateTestHandler(); 24 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 25 | .ImagesSameSeries().WithId("882449540").WithPage(3).ExecuteAsync(); 26 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/same-series"); 27 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page=3"); 28 | } 29 | 30 | [Fact] 31 | public async Task ImagesSameSeriesWithPageSize() 32 | { 33 | var testHandler = TestUtil.CreateTestHandler(); 34 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 35 | .ImagesSameSeries().WithId("882449540").WithPageSize(50).ExecuteAsync(); 36 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("images/882449540/same-series"); 37 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page_size=50"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageSearchItem.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace GettyImages.Api.Models; 8 | 9 | public class ImageSearchItem 10 | { 11 | public AllowedUse AllowedUse { get; set; } 12 | public Dictionary AlternativeIds { get; set; } 13 | public string Artist { get; set; } 14 | public string AssetFamily { get; set; } 15 | public bool CallForImage { get; set; } 16 | public string Caption { get; set; } 17 | public string CollectionCode { get; set; } 18 | public int? CollectionId { get; set; } 19 | public string CollectionName { get; set; } 20 | public string ColorType { get; set; } 21 | public string Copyright { get; set; } 22 | public DateTime? DateCameraShot { get; set; } 23 | public DateTime? DateCreated { get; set; } 24 | public AssetSearchItemDisplaySize[] DisplaySizes { get; set; } 25 | public string DownloadProduct { get; set; } 26 | public string[] EditorialSegments { get; set; } 27 | public int[] EventIds { get; set; } 28 | public string GraphicalStyle { get; set; } 29 | public string Id { get; set; } 30 | public Keyword[] Keywords { get; set; } 31 | public Download[] LargestDownloads { get; set; } 32 | public string LicenseModel { get; set; } 33 | public MaxDimensions MaxDimensions { get; set; } 34 | public string Orientation { get; set; } 35 | public string[] People { get; set; } 36 | public string[] ProductTypes { get; set; } 37 | public int QualityRank { get; set; } 38 | public ReferralDestination[] ReferralDestinations { get; set; } 39 | public string Title { get; set; } 40 | public string UriOembed { get; set; } 41 | public IStockLicense[] IstockLicenses { get; set; } 42 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/ImageSearchItemEditorial.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace GettyImages.Api.Models; 8 | 9 | public class ImageSearchItemEditorial 10 | { 11 | public AllowedUse AllowedUse { get; set; } 12 | public Dictionary AlternativeIds { get; set; } 13 | public string Artist { get; set; } 14 | public string AssetFamily { get; set; } 15 | public bool CallForImage { get; set; } 16 | public string Caption { get; set; } 17 | public string CollectionCode { get; set; } 18 | public int CollectionId { get; set; } 19 | public string CollectionName { get; set; } 20 | public string ColorType { get; set; } 21 | public string Copyright { get; set; } 22 | public DateTime? DateCameraShot { get; set; } 23 | public DateTime? DateCreated { get; set; } 24 | public AssetSearchItemDisplaySize[] DisplaySizes { get; set; } 25 | public string DownloadProduct { get; set; } 26 | public DownloadSize[] DownloadSizes { get; set; } 27 | public string[] EditorialSegments { get; set; } 28 | public EditorialSource EditorialSource { get; set; } 29 | public int[] EventIds { get; set; } 30 | public string GraphicalStyle { get; set; } 31 | public string Id { get; set; } 32 | public Keyword[] Keywords { get; set; } 33 | public Download[] LargestDownloads { get; set; } 34 | public string LicenseModel { get; set; } 35 | public MaxDimensions MaxDimensions { get; set; } 36 | public string Orientation { get; set; } 37 | public string[] People { get; set; } 38 | public string[] ProductTypes { get; set; } 39 | public int QualityRank { get; set; } 40 | public ReferralDestination[] ReferralDestinations { get; set; } 41 | public string Title { get; set; } 42 | public string UriOembed { get; set; } 43 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/GetSimilarVideosResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GettyImages.Api.Models; 4 | 5 | public class GetSimilarVideosResponse 6 | { 7 | public int ResultCount { get; set; } 8 | public SimilarVideo[] Videos { get; set; } 9 | 10 | } 11 | 12 | public class SimilarVideo 13 | { 14 | public string Id { get; set; } 15 | public AllowedUse AllowedUse { get; set; } 16 | public string Artist { get; set; } 17 | public string AspectRatio { get; set; } 18 | public string AssetFamily { get; set; } 19 | public bool CallForImage { get; set; } 20 | public string Caption { get; set; } 21 | public string ClipLength { get; set; } 22 | public int CollectionId { get; set; } 23 | public string CollectionCode { get; set; } 24 | public string CollectionName { get; set; } 25 | public string ColorType { get; set; } 26 | public string Copyright { get; set; } 27 | public DateTime? DateCreated { get; set; } 28 | public DateTime? DateSubmitted { get; set; } 29 | public VideoSearchItemDisplaySize[] DisplaySizes { get; set; } 30 | public string DownloadProduct { get; set; } 31 | public VideoDownloadSize[] DownloadSizes { get; set; } 32 | public string[] EditorialSegments { get; set; } 33 | public string Era { get; set; } 34 | public int[] EventIds { get; set; } 35 | public string IstockCollection { get; set; } 36 | public Keyword[] Keywords { get; set; } 37 | public Download[] LargestDownloads { get; set; } 38 | public string LicenseModel { get; set; } 39 | public string MasteredTo { get; set; } 40 | public string Orientation { get; set; } 41 | public string OriginallyShotOn { get; set; } 42 | public string[] ProductTypes { get; set; } 43 | public ReferralDestination[] ReferralDestinations { get; set; } 44 | public string ShotSpeed { get; set; } 45 | public string Source { get; set; } 46 | public string Title { get; set; } 47 | 48 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/Video.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | 4 | using System; 5 | 6 | namespace GettyImages.Api.Models; 7 | 8 | public class Video 9 | { 10 | public string Id { get; set; } 11 | public AllowedUse AllowedUse { get; set; } 12 | public string Artist { get; set; } 13 | public string AssetFamily { get; set; } 14 | public bool CallForImage { get; set; } 15 | public string Caption { get; set; } 16 | public string City { get; set; } 17 | public string ClipLength { get; set; } 18 | public string CollectionCode { get; set; } 19 | public int CollectionId { get; set; } 20 | public string CollectionName { get; set; } 21 | public string ColorType { get; set; } 22 | public string Copyright { get; set; } 23 | public string Country { get; set; } 24 | public DateTime? DateCreated { get; set; } 25 | public DateTime? DateSubmitted { get; set; } 26 | public DisplaySize[] DisplaySizes { get; set; } 27 | public string DownloadProduct { get; set; } 28 | public VideoDownloadSize[] DownloadSizes { get; set; } 29 | public string[] EditorialSegments { get; set; } 30 | public string Era { get; set; } 31 | public int[] EventIds { get; set; } 32 | public string IstockCollection { get; set; } 33 | public IStockLicense[] IstockLicenses { get; set; } 34 | public Keyword[] Keywords { get; set; } 35 | public string LicenseModel { get; set; } 36 | public string MasteredTo { get; set; } 37 | public string ObjectName { get; set; } 38 | public string OriginallyShotOn { get; set; } 39 | public string[] ProductTypes { get; set; } 40 | public int QualityRank { get; set; } 41 | public ReferralDestination[] ReferralDestinations { get; set; } 42 | public string ShotSpeed { get; set; } 43 | public string Source { get; set; } 44 | public string StateProvince { get; set; } 45 | public string Title { get; set; } 46 | } -------------------------------------------------------------------------------- /UnitTests/Artists/ArtistsImagesTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Artists; 7 | 8 | public class ArtistsImagesTests 9 | { 10 | [Fact] 11 | public async Task SearchForImagesByArtistBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).ArtistsImages() 16 | .WithArtist("roman makhmutov").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artists/images"); 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artist_name=roman+makhmutov"); 20 | } 21 | 22 | [Fact] 23 | public async Task SearchForImagesByArtistWithPage() 24 | { 25 | var testHandler = TestUtil.CreateTestHandler(); 26 | 27 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).ArtistsImages() 28 | .WithArtist("roman makhmutov").WithPage(3).ExecuteAsync(); 29 | 30 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artists/images"); 31 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artist_name=roman+makhmutov"); 32 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page=3"); 33 | } 34 | 35 | [Fact] 36 | public async Task SearchForImagesByArtistWithPageSize() 37 | { 38 | var testHandler = TestUtil.CreateTestHandler(); 39 | 40 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).ArtistsImages() 41 | .WithArtist("roman makhmutov").WithPageSize(50).ExecuteAsync(); 42 | 43 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artists/images"); 44 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artist_name=roman+makhmutov"); 45 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page_size=50"); 46 | } 47 | } -------------------------------------------------------------------------------- /GettyImages.Api/Download/Downloads.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Download; 5 | 6 | public class Downloads : ApiRequest 7 | { 8 | private Downloads(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) 9 | { 10 | Credentials = credentials; 11 | BaseUrl = baseUrl; 12 | Method = "GET"; 13 | Path = "/downloads"; 14 | } 15 | 16 | internal static Downloads GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 17 | { 18 | return new Downloads(credentials, baseUrl, customHandler); 19 | } 20 | 21 | public Downloads WithAcceptLanguage(string value) 22 | { 23 | AddHeaderParameter(Constants.AcceptLanguage, value); 24 | return this; 25 | } 26 | 27 | public Downloads WithCompanyDownloads(bool value = true) 28 | { 29 | AddQueryParameter(Constants.CompanyDownloadsKey, value); 30 | return this; 31 | } 32 | 33 | public Downloads WithEndDate(string value) 34 | { 35 | AddQueryParameter(Constants.DateToKey, value); 36 | return this; 37 | } 38 | 39 | public Downloads WithPage(int value) 40 | { 41 | AddQueryParameter(Constants.PageKey, value); 42 | return this; 43 | } 44 | 45 | public Downloads WithPageSize(int value) 46 | { 47 | AddQueryParameter(Constants.PageSizeKey, value); 48 | return this; 49 | } 50 | 51 | public Downloads WithProductType(ProductType value) 52 | { 53 | AddQueryParameter(Constants.ProductTypeKey, value); 54 | return this; 55 | } 56 | 57 | public Downloads WithStartDate(string value) 58 | { 59 | AddQueryParameter(Constants.DateFromKey, value); 60 | return this; 61 | } 62 | 63 | public Downloads WithUseTime(bool value = true) 64 | { 65 | AddQueryParameter(Constants.UseTimeKey, value); 66 | return this; 67 | } 68 | } -------------------------------------------------------------------------------- /UnitTests/Artists/ArtistsVideosTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using FluentAssertions; 3 | using GettyImages.Api; 4 | using Xunit; 5 | 6 | namespace UnitTests.Artists; 7 | 8 | public class ArtistsVideosTests 9 | { 10 | [Fact] 11 | public async Task SearchForVideosByArtistBasic() 12 | { 13 | var testHandler = TestUtil.CreateTestHandler(); 14 | 15 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).ArtistsVideos() 16 | .WithArtist("roman makhmutov").ExecuteAsync(); 17 | 18 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artists/videos"); 19 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artist_name=roman+makhmutov"); 20 | } 21 | 22 | [Fact] 23 | public async Task SearchForVideosByArtistWithPage() 24 | { 25 | var testHandler = TestUtil.CreateTestHandler(); 26 | 27 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).ArtistsVideos() 28 | .WithArtist("roman makhmutov").WithPage(3).ExecuteAsync(); 29 | 30 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artists/videos"); 31 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artist_name=roman+makhmutov"); 32 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page=3"); 33 | } 34 | 35 | [Fact] 36 | public async Task SearchForVideosByArtistWithPageSize() 37 | { 38 | var testHandler = TestUtil.CreateTestHandler(); 39 | 40 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler).ArtistsVideos() 41 | .WithArtist("roman makhmutov").WithPageSize(50).ExecuteAsync(); 42 | 43 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artists/videos"); 44 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("artist_name=roman+makhmutov"); 45 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page_size=50"); 46 | } 47 | } -------------------------------------------------------------------------------- /GettyImages.Api/PollyHttpClientExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using Polly; 5 | using Polly.Extensions.Http; 6 | using Polly.Retry; 7 | 8 | namespace GettyImages.Api; 9 | 10 | internal static class PollyHttpClientExtensions 11 | { 12 | private static readonly AsyncRetryPolicy RetryPolicy; 13 | 14 | static PollyHttpClientExtensions() 15 | { 16 | RetryPolicy = 17 | HttpPolicyExtensions 18 | .HandleTransientHttpError() 19 | .OrResult(responseMessage => (int)responseMessage.StatusCode == 429) 20 | .WaitAndRetryAsync(3, retryAttempt => 21 | TimeSpan.FromMilliseconds(retryAttempt * 100) 22 | ); 23 | } 24 | 25 | public static Task GetAsyncWithRetryPolicy(this HttpClient httpClient, Uri uri) 26 | { 27 | return RetryPolicy.ExecuteAsync(() => httpClient.GetAsync(uri)); 28 | } 29 | 30 | public static Task PostAsyncWithRetryPolicy(this HttpClient httpClient, 31 | string requestUri, HttpContent content) 32 | { 33 | return RetryPolicy.ExecuteAsync(() => httpClient.PostAsync(requestUri, content)); 34 | } 35 | 36 | public static Task PostAsyncWithRetryPolicy(this HttpClient httpClient, 37 | Uri requestUri, HttpContent content) 38 | { 39 | return RetryPolicy.ExecuteAsync(() => httpClient.PostAsync(requestUri, content)); 40 | } 41 | 42 | public static Task PutAsyncWithRetryPolicy(this HttpClient httpClient, 43 | Uri requestUri, HttpContent content) 44 | { 45 | return RetryPolicy.ExecuteAsync(() => httpClient.PutAsync(requestUri, content)); 46 | } 47 | 48 | public static Task DeleteAsyncWithRetryPolicy(this HttpClient httpClient, 49 | Uri requestUri) 50 | { 51 | return RetryPolicy.ExecuteAsync(() => httpClient.DeleteAsync(requestUri)); 52 | } 53 | } -------------------------------------------------------------------------------- /GettyImages.Api/Models/SearchCreativeVideosByImageResponse.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable UnusedMember.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | using System; 4 | 5 | namespace GettyImages.Api.Models; 6 | 7 | public class SearchCreativeVideosByImageResponse 8 | { 9 | public int ResultCount { get; set; } 10 | public CreativeSearchFacets Facets { get; set; } 11 | public CreativeVideoSearchByImageItem[] Videos { get; set; } 12 | } 13 | 14 | public class CreativeVideoSearchByImageItem 15 | { 16 | public string Id { get; set; } 17 | public AllowedUse AllowedUse { get; set; } 18 | public string Artist { get; set; } 19 | public string AspectRatio { get; set; } 20 | public string AssetFamily { get; set; } 21 | public bool CallForImage { get; set; } 22 | public string Caption { get; set; } 23 | public string ClipLength { get; set; } 24 | public int CollectionId { get; set; } 25 | public string CollectionCode { get; set; } 26 | public string CollectionName { get; set; } 27 | public string ColorType { get; set; } 28 | public string Copyright { get; set; } 29 | public DateTime DateCreated { get; set; } 30 | public DateTime DateSubmitted { get; set; } 31 | public VideoSearchItemDisplaySize[] DisplaySizes { get; set; } 32 | public string DownloadProduct { get; set; } 33 | public VideoDownloadSize[] DownloadSizes { get; set; } 34 | public string Era { get; set; } 35 | public string IstockCollection { get; set; } 36 | public CreativeKeyword[] Keywords { get; set; } 37 | public Download[] LargestDownloads { get; set; } 38 | public string LicenseModel { get; set; } 39 | public string MasteredTo { get; set; } 40 | public string Orientation { get; set; } 41 | public string OriginallyShotOn { get; set; } 42 | public string[] ProductTypes { get; set; } 43 | public int QualityRank { get; set; } 44 | public ReferralDestination[] ReferralDestinations { get; set; } 45 | public string ShotSpeed { get; set; } 46 | public string Title { get; set; } 47 | } -------------------------------------------------------------------------------- /UnitTests/Videos/VideosSimilarTests.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using GettyImages.Api; 5 | using Xunit; 6 | 7 | namespace UnitTests.Videos; 8 | 9 | public class VideosSimilarTests 10 | { 11 | [Fact] 12 | public async Task VideosSimilarBasic() 13 | { 14 | var testHandler = TestUtil.CreateTestHandler(); 15 | 16 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 17 | .VideosSimilar() 18 | .WithId("882449540") 19 | .ExecuteAsync(); 20 | 21 | Debug.Assert(testHandler.Request.RequestUri != null, "testHandler.Request.RequestUri != null"); 22 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/similar"); 23 | } 24 | 25 | 26 | [Fact] 27 | public async Task VideosSimilarWithPage() 28 | { 29 | var testHandler = TestUtil.CreateTestHandler(); 30 | 31 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 32 | .VideosSimilar().WithId("882449540").WithPage(3).ExecuteAsync(); 33 | 34 | Debug.Assert(testHandler.Request.RequestUri != null, "testHandler.Request.RequestUri != null"); 35 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/similar"); 36 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page=3"); 37 | } 38 | 39 | [Fact] 40 | public async Task VideosSimilarWithPageSize() 41 | { 42 | var testHandler = TestUtil.CreateTestHandler(); 43 | 44 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 45 | .VideosSimilar().WithId("882449540").WithPageSize(50).ExecuteAsync(); 46 | 47 | Debug.Assert(testHandler.Request.RequestUri != null, "testHandler.Request.RequestUri != null"); 48 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/similar"); 49 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page_size=50"); 50 | } 51 | } -------------------------------------------------------------------------------- /GettyImages.Api/Artists/ArtistsImages.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Artists; 5 | 6 | public class ArtistsImages : ApiRequest 7 | { 8 | private ArtistsImages(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 9 | customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "GET"; 14 | Path = "/artists/images"; 15 | 16 | AddResponseFields(new[] 17 | { 18 | "id", "allowed_use", "alternative_ids", "artist", "asset_family", "asset_type", "call_for_image", 19 | "caption", "collection_id", "collection_code", "collection_name", "comp", "copyright", "date_created", 20 | "date_submitted", "editorial_segments", "event_ids", "graphical_style", "license_model", "max_dimensions", 21 | "orientation", "preview", "product_types", "quality_rank", "referral_destinations", "thumb", "title" 22 | }); 23 | } 24 | 25 | internal static ArtistsImages GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 26 | { 27 | return new ArtistsImages(credentials, baseUrl, customHandler); 28 | } 29 | 30 | public ArtistsImages WithArtist(string value) 31 | { 32 | AddQueryParameter(Constants.ArtistNameKey, value); 33 | return this; 34 | } 35 | 36 | public ArtistsImages WithAcceptLanguage(string value) 37 | { 38 | AddHeaderParameter(Constants.AcceptLanguage, value); 39 | return this; 40 | } 41 | 42 | public ArtistsImages WithPage(int value) 43 | { 44 | AddQueryParameter(Constants.PageKey, value); 45 | return this; 46 | } 47 | 48 | public ArtistsImages WithPageSize(int value) 49 | { 50 | AddQueryParameter(Constants.PageSizeKey, value); 51 | return this; 52 | } 53 | 54 | public ArtistsImages IncludeKeywords() 55 | { 56 | AddResponseField("keywords"); 57 | return this; 58 | } 59 | } -------------------------------------------------------------------------------- /GettyImages.Api/Handlers/UserAgentHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Reflection; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace GettyImages.Api.Handlers; 8 | 9 | internal class UserAgentHandler : DelegatingHandler 10 | { 11 | private static readonly string UserAgentString; 12 | 13 | static UserAgentHandler() 14 | { 15 | UserAgentString = "GettyImagesApiSdk/" + 16 | Assembly.Load(new AssemblyName("GettyImages.Api")) 17 | .GetCustomAttribute() 18 | .InformationalVersion + 19 | " (" + OsVersion() + Framework() + ")"; 20 | } 21 | 22 | private static string OsVersion() 23 | { 24 | var os = string.Empty; 25 | 26 | try 27 | { 28 | os = typeof(Environment).GetTypeInfo().Assembly 29 | .GetType("System.Environment") 30 | .GetRuntimeProperty("OSVersion") 31 | .GetValue(null).ToString(); 32 | } 33 | catch 34 | { 35 | } 36 | 37 | return string.IsNullOrEmpty(os) ? os : os + "; "; 38 | } 39 | 40 | private static string Framework() 41 | { 42 | var frameworkVersion = ".NET"; 43 | 44 | try 45 | { 46 | frameworkVersion = " " + typeof(Environment).GetTypeInfo().Assembly 47 | .GetType("System.Environment").GetRuntimeProperty("Version").GetValue(null); 48 | } 49 | catch 50 | { 51 | } 52 | 53 | return (Type.GetType("Mono.Runtime") != null ? "Mono" : ".NET") + frameworkVersion; 54 | } 55 | 56 | protected override Task SendAsync(HttpRequestMessage request, 57 | CancellationToken cancellationToken) 58 | { 59 | request.Headers.Add("User-Agent", UserAgentString); 60 | if (InnerHandler == null) 61 | { 62 | InnerHandler = new HttpClientHandler(); 63 | } 64 | 65 | return base.SendAsync(request, cancellationToken); 66 | } 67 | } -------------------------------------------------------------------------------- /GettyImages.Api/Download/DownloadsImages.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Download; 5 | 6 | public class DownloadsImages : ApiRequest 7 | { 8 | private DownloadsImages(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 9 | customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "POST"; 14 | AddQueryParameter(Constants.AutoDownloadKey, false); 15 | } 16 | 17 | internal static DownloadsImages GetInstance(Credentials credentials, string baseUrl, 18 | DelegatingHandler customHandler) 19 | { 20 | return new DownloadsImages(credentials, baseUrl, customHandler); 21 | } 22 | 23 | public DownloadsImages WithId(string value) 24 | { 25 | Path = $"/downloads/images/{value}"; 26 | return this; 27 | } 28 | 29 | public DownloadsImages WithAcceptLanguage(string value) 30 | { 31 | AddHeaderParameter(Constants.AcceptLanguage, value); 32 | return this; 33 | } 34 | 35 | public DownloadsImages WithDownloadDetails(DownloadDetails value) 36 | { 37 | BodyParameter = value; 38 | return this; 39 | } 40 | 41 | public DownloadsImages WithFileType(FileType value) 42 | { 43 | AddQueryParameter(Constants.FileTypeKey, value); 44 | return this; 45 | } 46 | 47 | public DownloadsImages WithHeight(int height) 48 | { 49 | AddQueryParameter(Constants.HeightKey, height); 50 | return this; 51 | } 52 | 53 | public DownloadsImages WithProductId(int value) 54 | { 55 | AddQueryParameter(Constants.ProductIdKey, value); 56 | return this; 57 | } 58 | 59 | public DownloadsImages WithProductType(ProductType value) 60 | { 61 | AddQueryParameter(Constants.ProductTypeKey, value); 62 | return this; 63 | } 64 | 65 | public DownloadsImages WithUseTeamCredits(bool value = true) 66 | { 67 | AddQueryParameter(Constants.UseTeamCredits, value); 68 | return this; 69 | } 70 | } -------------------------------------------------------------------------------- /GettyImages.Api/Artists/ArtistsVideos.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using GettyImages.Api.Models; 3 | 4 | namespace GettyImages.Api.Artists; 5 | 6 | public class ArtistsVideos : ApiRequest 7 | { 8 | private ArtistsVideos(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 9 | customHandler) 10 | { 11 | Credentials = credentials; 12 | BaseUrl = baseUrl; 13 | Method = "GET"; 14 | Path = "/artists/videos"; 15 | 16 | AddResponseFields(new[] 17 | { 18 | "id", "allowed_use", "alternative_ids", "artist", "asset_family", "asset_type", "call_for_image", 19 | "caption", "clip_length", 20 | "collection_id", "collection_code", "collection_name", "comp", "copyright", "date_created", 21 | "date_submitted", 22 | "editorial_segments", "event_ids", "graphical_style", 23 | "license_model", "max_dimensions", "orientation", "preview", "product_types", 24 | "quality_rank", 25 | "referral_destinations", "thumb", "title" 26 | }); 27 | } 28 | 29 | internal static ArtistsVideos GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) 30 | { 31 | return new ArtistsVideos(credentials, baseUrl, customHandler); 32 | } 33 | 34 | public ArtistsVideos WithAcceptLanguage(string value) 35 | { 36 | AddHeaderParameter(Constants.AcceptLanguage, value); 37 | return this; 38 | } 39 | 40 | public ArtistsVideos WithArtist(string value) 41 | { 42 | AddQueryParameter(Constants.ArtistNameKey, value); 43 | return this; 44 | } 45 | 46 | public ArtistsVideos WithPage(int value) 47 | { 48 | AddQueryParameter(Constants.PageKey, value); 49 | return this; 50 | } 51 | 52 | public ArtistsVideos WithPageSize(int value) 53 | { 54 | AddQueryParameter(Constants.PageSizeKey, value); 55 | return this; 56 | } 57 | 58 | public ArtistsVideos IncludeKeywords() 59 | { 60 | AddResponseField("keywords"); 61 | return this; 62 | } 63 | } -------------------------------------------------------------------------------- /UnitTests/Videos/VideosSameSeriesTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using GettyImages.Api; 3 | using System.Diagnostics; 4 | using System.Threading.Tasks; 5 | using Xunit; 6 | 7 | namespace UnitTests.Videos 8 | { 9 | public class VideosSameSeriesTests 10 | { 11 | 12 | [Fact] 13 | public async Task VideosSameSeriesBasic() 14 | { 15 | var testHandler = TestUtil.CreateTestHandler(); 16 | 17 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 18 | .VideosSameSeries() 19 | .WithId("882449540") 20 | .ExecuteAsync(); 21 | 22 | Debug.Assert(testHandler.Request.RequestUri != null, "testHandler.Request.RequestUri != null"); 23 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/same-series"); 24 | } 25 | 26 | 27 | [Fact] 28 | public async Task VideosSameSeriesWithPage() 29 | { 30 | var testHandler = TestUtil.CreateTestHandler(); 31 | 32 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 33 | .VideosSameSeries().WithId("882449540").WithPage(3).ExecuteAsync(); 34 | 35 | Debug.Assert(testHandler.Request.RequestUri != null, "testHandler.Request.RequestUri != null"); 36 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/same-series"); 37 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page=3"); 38 | } 39 | 40 | [Fact] 41 | public async Task VideosSameSeriesWithPageSize() 42 | { 43 | var testHandler = TestUtil.CreateTestHandler(); 44 | 45 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 46 | .VideosSameSeries().WithId("882449540").WithPageSize(50).ExecuteAsync(); 47 | 48 | Debug.Assert(testHandler.Request.RequestUri != null, "testHandler.Request.RequestUri != null"); 49 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("videos/882449540/same-series"); 50 | testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("page_size=50"); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /UnitTests/AiGenerator/GetVariationsTests.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Json; 2 | using System.Threading.Tasks; 3 | using FluentAssertions; 4 | using GettyImages.Api; 5 | using GettyImages.Api.Models; 6 | using Xunit; 7 | 8 | namespace UnitTests.AiGenerator; 9 | 10 | public class GetVariationsTests : IAsyncLifetime 11 | { 12 | // Get variations on a generated image 13 | private image_variations_request _requestPayload; 14 | private string _absoluteUri; 15 | 16 | public async Task InitializeAsync() 17 | { 18 | var testHandler = TestUtil.CreateTestHandler(); 19 | await ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret", testHandler) 20 | .GeneratedImageVariations() 21 | .With(generationRequestId: "A6503762-4A4B-4434-8445-2C1335A95A78", index: 2, 22 | new GenerationVariationsRequest 23 | { 24 | Notes = "some notes", 25 | ProductId = 1234, 26 | ProjectCode = "some project code" 27 | }) 28 | .ExecuteAsync(); 29 | 30 | _requestPayload = await testHandler.Request.Content! 31 | .ReadFromJsonAsync(); 32 | _absoluteUri = testHandler.Request.RequestUri!.AbsoluteUri; 33 | } 34 | 35 | [Fact] 36 | public void NotesAreAttached() 37 | { 38 | _requestPayload.notes.Should().Be("some notes"); 39 | } 40 | 41 | [Fact] 42 | public void ProductIdIsAttached() 43 | { 44 | _requestPayload.product_id.Should().Be(1234); 45 | } 46 | 47 | [Fact] 48 | public void ProjectCodeIsAttached() 49 | { 50 | _requestPayload.project_code.Should().Be("some project code"); 51 | } 52 | 53 | [Fact] 54 | public void UriIsExpected() 55 | { 56 | _absoluteUri.Should().Be("https://api.gettyimages.com/v3/ai/image-generations/A6503762-4A4B-4434-8445-2C1335A95A78/images/2/variations"); 57 | } 58 | 59 | public class image_variations_request 60 | { 61 | public string notes { get; set; } 62 | public string project_code { get; set; } 63 | public int? product_id { get; set; } 64 | } 65 | 66 | public Task DisposeAsync() 67 | { 68 | return Task.CompletedTask; 69 | } 70 | } -------------------------------------------------------------------------------- /GettyImages.Api/AiGenerator/DownloadGeneratedImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Threading.Tasks; 5 | using GettyImages.Api.Models; 6 | 7 | namespace GettyImages.Api.AiGenerator; 8 | 9 | public class DownloadGeneratedImage : ApiRequest 10 | { 11 | private DownloadGeneratedImage(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base( 12 | customHandler) 13 | { 14 | Credentials = credentials; 15 | BaseUrl = baseUrl; 16 | } 17 | 18 | internal static DownloadGeneratedImage GetInstance(Credentials credentials, string baseUrl, 19 | DelegatingHandler customHandler) 20 | { 21 | return new DownloadGeneratedImage(credentials, baseUrl, customHandler); 22 | } 23 | 24 | public DownloadGeneratedImage With(string generationRequestId, int index, 25 | GeneratedImageDownloadRequest downloadRequest) 26 | { 27 | Path = $"/ai/image-generations/{generationRequestId}/images/{index}/download"; 28 | BodyParameter = downloadRequest; 29 | return this; 30 | } 31 | 32 | public new Task ExecuteAsync() 33 | { 34 | return ExecuteAsync(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(45)); 35 | } 36 | 37 | public async Task ExecuteAsync(TimeSpan pollDelay, TimeSpan timeout) 38 | { 39 | var helper = new WebHelper(Credentials, BaseUrl, _customHandler); 40 | 41 | var httpResponseMessage = await helper.PutQueryRawHttpResponseMessageAsync(BuildQuery(QueryParameters), 42 | Path, BuildHeaders(HeaderParameters), BuildBody()); 43 | 44 | await httpResponseMessage.HandleResponseAsync(); 45 | 46 | if (httpResponseMessage.StatusCode == HttpStatusCode.Accepted) 47 | { 48 | var getGeneratedImageDownload = GetGeneratedImageDownload.GetInstance(Credentials, BaseUrl, _customHandler) 49 | .WithPath(Path); 50 | return await getGeneratedImageDownload.ExecuteAsync(pollDelay, timeout); 51 | } 52 | 53 | await httpResponseMessage.HandleResponseAsync(); 54 | return await httpResponseMessage.HandleGetContentResponseAsync(); 55 | } 56 | } --------------------------------------------------------------------------------