diff --git a/GettyImages.Api/ApiClient.cs b/GettyImages.Api/ApiClient.cs index 6fe586d..fd372f7 100644 --- a/GettyImages.Api/ApiClient.cs +++ b/GettyImages.Api/ApiClient.cs @@ -2,7 +2,6 @@ using System.Net.Http; using System.Threading.Tasks; using GettyImages.Api.Download; -using GettyImages.Api.Orders; using GettyImages.Api.Search; namespace GettyImages.Api @@ -585,5 +584,16 @@ public AssetLicensing.AcquireExtendedLicense AcquireExtendedLicense() { return AssetLicensing.AcquireExtendedLicense.GetInstance(_credentials, _baseUrl, _customHandler); } + + /// + /// Returns information about the current user + /// + /// + /// The . + /// + public Customers.Customers Customers() + { + return Api.Customers.Customers.GetInstance(_credentials, _baseUrl, _customHandler); + } } } \ No newline at end of file diff --git a/GettyImages.Api/Customers/Customers.cs b/GettyImages.Api/Customers/Customers.cs new file mode 100644 index 0000000..2a2c2c9 --- /dev/null +++ b/GettyImages.Api/Customers/Customers.cs @@ -0,0 +1,36 @@ +using System.Net.Http; +using System.Threading.Tasks; + +namespace GettyImages.Api.Customers +{ + public class Customers : ApiRequest + { + protected const string V3CustomersPath = "/customers/current"; + + public Customers(Credentials credentials, string baseUrl, DelegatingHandler customHandler) : base(customHandler) + { + Credentials = credentials; + BaseUrl = baseUrl; + } + + internal static Customers GetInstance(Credentials credentials, string baseUrl, DelegatingHandler customHandler) + { + return new Customers(credentials, baseUrl, customHandler); + } + + public override async Task ExecuteAsync() + { + Method = "GET"; + Path = V3CustomersPath; + + return await base.ExecuteAsync(); + } + + public Customers WithAcceptLanguage(string value) + { + AddHeaderParameter(Constants.AcceptLanguage, value); + + return this; + } + } +} diff --git a/UnitTests/Customers/CustomersTests.cs b/UnitTests/Customers/CustomersTests.cs new file mode 100644 index 0000000..3610e4c --- /dev/null +++ b/UnitTests/Customers/CustomersTests.cs @@ -0,0 +1,22 @@ +using FluentAssertions; +using GettyImages.Api; +using Xunit; + +namespace UnitTests.Customers +{ + public class CustomersTests + { + [Fact] + public void GetCustomerInfoBasic() + { + var testHandler = TestUtil.CreateTestHandler(); + + var response = ApiClient.GetApiClientWithResourceOwnerCredentials("apiKey", "apiSecret", "userName", "userPassword", testHandler) + .Customers() + .ExecuteAsync() + .Result; + + testHandler.Request.RequestUri.AbsoluteUri.Should().Contain("/customers/current"); + } + } +}