├── src
├── Amazon.SellingPartner.Auth.Core
│ ├── IDateHelper.cs
│ ├── EndpointConstants.cs
│ ├── IRateLimitConfiguration.cs
│ ├── ILwaClient.cs
│ ├── SigningDateHelper.cs
│ ├── ScopeConstants.cs
│ ├── IAmazonSecurityTokenCredentialResolver.cs
│ ├── AmazonSecurityTokenCredentials.cs
│ ├── Amazon.SellingPartner.Auth.Core.csproj
│ ├── AwsAuthenticationCredentials.cs
│ ├── LwaTokenResponse.cs
│ ├── SellingPartnerApiCredentials.cs
│ ├── RateLimitConfigurationOnRequests.cs
│ ├── LwaAuthorizationCredentials.cs
│ ├── LwaAccessTokenRequestMetaBuilder.cs
│ ├── LwaAccessTokenRequestMeta.cs
│ ├── AmazonSecurityTokenCredentialResolver.cs
│ └── Utils.cs
├── Amazon.SellingPartner.Core
│ ├── Amazon.SellingPartner.Core.csproj
│ ├── DateTimeExtensions.cs
│ ├── DateTimeOffsetExtensions.cs
│ ├── StringExtensions.cs
│ ├── AmazonDateUtil.cs
│ ├── AmazonSpApiEndpoint.cs
│ └── AmazonMarketplace.cs
├── Amazon.SellingPartner.Serialization.NewtonsoftJson
│ ├── Amazon.SellingPartner.Serialization.NewtonsoftJson.csproj
│ └── AmazonSellingPartnerSafeContractResolver.cs
├── Amazon.SellingPartner.Auth.RestSharp
│ ├── SafeRestSharpJsonNetSerializer.cs
│ ├── Amazon.SellingPartner.Auth.RestSharp.csproj
│ ├── AmazonSpRestRequestExtension.cs
│ ├── RestSharpLwaAuthorizationSigner.cs
│ ├── AmazonSpRestRequestUtil.cs
│ ├── resources
│ │ └── swagger-codegen
│ │ │ └── templates
│ │ │ ├── api_test.mustache
│ │ │ └── IReadableConfiguration.mustache
│ ├── RestSharpAwsSigV4Signer.cs
│ └── RestSharpLwaClient.cs
├── Amazon.SellingPartner.Auth.Caching
│ ├── Amazon.SellingPartner.Auth.Caching.csproj
│ └── MemoryCacheAmazonSecurityTokenCredentialResolver.cs
├── Amazon.SellingPartner.Auth.HttpClient
│ ├── Amazon.SellingPartner.Auth.HttpClient.csproj
│ ├── AmazonSpSecurityTokenHandler.cs
│ ├── AmazonSpAccessTokenHandler.cs
│ ├── HttpLwaClient.cs
│ └── HttpRequestMessageAWSSigV4Signer.cs
├── Amazon.SellingPartner.Auth.RestSharp.Caching
│ ├── MemoryCacheRestSharpLwaAuthorizationSigner.cs
│ ├── Amazon.SellingPartner.Auth.RestSharp.Caching.csproj
│ ├── MemoryCacheRestSharpLwaClient.cs
│ └── AmazonSpCacheRestRequestExtension.cs
├── Amazon.SellingPartner.Auth.HttpClient.Caching
│ ├── Amazon.SellingPartner.Auth.HttpClient.Caching.csproj
│ └── MemoryCacheHttpLwaClient.cs
└── Clients
│ ├── Amazon.SellingPartner.RestSharp.Orders
│ ├── Client
│ │ ├── ExceptionFactory.cs
│ │ ├── GlobalConfiguration.cs
│ │ ├── SwaggerDateConverter.cs
│ │ ├── IApiAccessor.cs
│ │ ├── ApiResponse.cs
│ │ ├── ApiException.cs
│ │ └── IReadableConfiguration.cs
│ ├── Amazon.SellingPartner.RestSharp.Orders.csproj
│ └── Model
│ │ ├── OrderList.cs
│ │ ├── ErrorList.cs
│ │ ├── OrderItemList.cs
│ │ ├── PromotionIdList.cs
│ │ ├── OrderItemBuyerInfoList.cs
│ │ ├── PaymentMethodDetailItemList.cs
│ │ └── PaymentExecutionDetailItemList.cs
│ ├── Amazon.SellingPartner.Sales.Client
│ ├── Amazon.SellingPartner.Sales.Client.csproj
│ └── nswag.json
│ ├── Amazon.SellingPartner.Orders.Client
│ ├── Amazon.SellingPartner.Orders.Client.csproj
│ └── nswag.json
│ ├── Amazon.SellingPartner.Sellers.Client
│ ├── Amazon.SellingPartner.Sellers.Client.csproj
│ └── nswag.json
│ ├── Amazon.SellingPartner.Finances.Client
│ └── Amazon.SellingPartner.Finances.Client.csproj
│ ├── Amazon.SellingPartner.Services.Client
│ └── Amazon.SellingPartner.Services.Client.csproj
│ ├── Amazon.SellingPartner.Shipping.Client
│ └── Amazon.SellingPartner.Shipping.Client.csproj
│ ├── Amazon.SellingPartner.Messaging.Client
│ └── Amazon.SellingPartner.Messaging.Client.csproj
│ ├── Amazon.SellingPartner.Tokens.Client
│ └── Amazon.SellingPartner.Tokens.Client.csproj
│ ├── Amazon.SellingPartner.Uploads.Client
│ └── Amazon.SellingPartner.Uploads.Client.csproj
│ ├── Amazon.SellingPartner.FbaInventory.Client
│ └── Amazon.SellingPartner.FbaInventory.Client.csproj
│ ├── Amazon.SellingPartner.ProductFees.Client
│ └── Amazon.SellingPartner.ProductFees.Client.csproj
│ ├── Amazon.SellingPartner.Authorization.Client
│ └── Amazon.SellingPartner.Authorization.Client.csproj
│ ├── Amazon.SellingPartner.Notifications.Client
│ └── Amazon.SellingPartner.Notifications.Client.csproj
│ ├── Amazon.SellingPartner.Solicitations.Client
│ └── Amazon.SellingPartner.Solicitations.Client.csproj
│ ├── Amazon.SellingPartner.ProductPricing.Client
│ └── Amazon.SellingPartner.ProductPricing.Client.csproj
│ ├── Amazon.SellingPartner.APlusContent.Client
│ └── Amazon.SellingPartner.APlusContent.Client.csproj
│ ├── Amazon.SellingPartner.FbaInboundEligility.Client
│ └── Amazon.SellingPartner.FbaInboundEligility.Client.csproj
│ ├── Amazon.SellingPartner.FbaSmallAndLight.Client
│ └── Amazon.SellingPartner.FbaSmallAndLight.Client.csproj
│ ├── Amazon.SellingPartner.ShipmentInvoicing.Client
│ └── Amazon.SellingPartner.ShipmentInvoicing.Client.csproj
│ ├── Amazon.SellingPartner.FulfillmentInbound.Client
│ └── Amazon.SellingPartner.FulfillmentInbound.Client.csproj
│ ├── Amazon.SellingPartner.MerchantFufillment.Client
│ └── Amazon.SellingPartner.MerchantFufillment.Client.csproj
│ ├── Amazon.SellingPartner.FulfillmentOutbound.Client
│ └── Amazon.SellingPartner.FulfillmentOutbound.Client.csproj
│ ├── Amazon.SellingPartner.ListingRestrictions.Client
│ └── Amazon.SellingPartner.ListingRestrictions.Client.csproj
│ ├── Amazon.SellingPartner.ProductTypeDefinitions.Client
│ └── Amazon.SellingPartner.ProductTypeDefinitions.Client.csproj
│ ├── Amazon.SellingPartner.Feed.Client
│ ├── Amazon.SellingPartner.Feed.Client.csproj
│ └── nswag.json
│ ├── Amazon.SellingPartner.Reports.Client
│ └── Amazon.SellingPartner.Reports.Client.csproj
│ ├── Amazon.SellingPartner.CatalogItems.Client
│ └── Amazon.SellingPartner.CatalogItems.Client.csproj
│ └── Amazon.SellingPartner.ListingItems.Client
│ └── Amazon.SellingPartner.ListingItems.Client.csproj
├── tests
├── Amazon.SellingPartner.IntegrationTests
│ ├── Helpers
│ │ ├── RunnableInDebugOnlyAttribute.cs
│ │ ├── HttpClient
│ │ │ ├── SafeAmazonSellingPartnerOrdersClient.cs
│ │ │ ├── AmazonSpHttpClientFactory.cs
│ │ │ ├── TestAmazonSpHttpClientFactory.cs
│ │ │ └── AmazonSpAccessTokenHandlerFactory.cs
│ │ ├── SellingPartnerClientFactory.cs
│ │ ├── SellingPartnerApiCredentialsFactory.cs
│ │ ├── RestSharp
│ │ │ ├── AmazonSpConfiguration.cs
│ │ │ └── AmazonSpApiClient.cs
│ │ ├── DefaultSellingPartnerClientFactory.cs
│ │ ├── GzipUtil.cs
│ │ └── SafeSellingPartnerClientFactory.cs
│ ├── README.md
│ ├── AmazonSpSalesTests.cs
│ ├── AmazonSpFulfillmentInboundTests.cs
│ ├── AmazonSpProductFeesTests.cs
│ ├── AmazonUtilTests.cs
│ ├── LwaClientIntegrationTests.cs
│ ├── AmazonSpOrdersTests.cs
│ ├── AmazonSpFinancesTests.cs
│ ├── AmazonSpReportTests.cs
│ └── AmazonSpFeedsTests.cs
└── Amazon.SellingPartner.Auth.Tests
│ ├── Amazon.SellingPartner.Auth.Tests.csproj
│ ├── UtilsTest.cs
│ ├── LwaAuthorizationSignerTest.cs
│ └── LwaAccessTokenRequestMetaBuilderTest.cs
└── LICENSE
/src/Amazon.SellingPartner.Auth.Core/IDateHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Amazon.SellingPartner.Auth.Core
4 | {
5 | public interface IDateHelper
6 | {
7 | DateTime GetUtcNow();
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/EndpointConstants.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Auth.Core
2 | {
3 | public class EndpointConstants
4 | {
5 | public const string LwaToken = "https://api.amazon.com/auth/o2/token";
6 | }
7 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/IRateLimitConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Auth.Core
2 | {
3 | public interface IRateLimitConfiguration
4 | {
5 | int GetRateLimitPermit();
6 | int GetTimeOut();
7 | }
8 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Core/Amazon.SellingPartner.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Core/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Amazon.SellingPartner.Core
4 | {
5 | public static class DateTimeExtensions
6 | {
7 | public static string ToAmazonDateTimeString(this DateTime value) => AmazonDateUtil.ConvertToString(value);
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/ILwaClient.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace Amazon.SellingPartner.Auth.Core
4 | {
5 | public interface ILwaClient
6 | {
7 | Task GetTokenResponseAsync();
8 | Task GetAccessTokenAsync();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/SigningDateHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Amazon.SellingPartner.Auth.Core
4 | {
5 | public class SigningDateHelper : IDateHelper
6 | {
7 | public DateTime GetUtcNow()
8 | {
9 | return DateTime.UtcNow;
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Core/DateTimeOffsetExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Amazon.SellingPartner.Core
4 | {
5 | public static class DateTimeOffsetExtensions
6 | {
7 | public static string ToAmazonDateTimeOffsetString(this DateTimeOffset value) => AmazonDateUtil.ConvertToString(value);
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/ScopeConstants.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Auth.Core
2 | {
3 | public class ScopeConstants
4 | {
5 | public const string ScopeNotificationsApi = "sellingpartnerapi::notifications";
6 | public const string ScopeMigrationApi = "sellingpartnerapi::migration";
7 | }
8 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/IAmazonSecurityTokenCredentialResolver.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace Amazon.SellingPartner.Auth.Core
5 | {
6 | public interface IAmazonSecurityTokenCredentialResolver
7 | {
8 | Task GetCredentialsAsync(CancellationToken cancellationToken);
9 | }
10 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Serialization.NewtonsoftJson/Amazon.SellingPartner.Serialization.NewtonsoftJson.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/RunnableInDebugOnlyAttribute.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using Xunit;
3 |
4 | namespace Amazon.SellingPartner.IntegrationTests.Helpers
5 | {
6 | public class RunnableInDebugOnlyAttribute : FactAttribute
7 | {
8 | public RunnableInDebugOnlyAttribute()
9 | {
10 | if (!Debugger.IsAttached)
11 | {
12 | Skip = "Only running in interactive mode.";
13 | }
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/SafeRestSharpJsonNetSerializer.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Serialization.NewtonsoftJson;
2 | using RestSharp.Serializers.NewtonsoftJson;
3 |
4 | namespace Amazon.SellingPartner.Auth.RestSharp
5 | {
6 | public class SafeRestSharpJsonNetSerializer : JsonNetSerializer
7 | {
8 | public SafeRestSharpJsonNetSerializer()
9 | {
10 | DefaultSettings.ContractResolver = new AmazonSellingPartnerSafeContractResolver();
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/README.md:
--------------------------------------------------------------------------------
1 |
2 | ```sh
3 | dotnet user-secrets init
4 | ```
5 |
6 | ```sh
7 | dotnet user-secrets set "Amzn:AWSKey" "AWS_KEY"
8 | dotnet user-secrets set "Amzn:AWSSecret" "AWS_SECRET"
9 | dotnet user-secrets set "Amzn:ClientId" "amzn1.application-oa2-client.xyz"
10 | dotnet user-secrets set "Amzn:ClientSecret" "CLIENT_SECRET"
11 | dotnet user-secrets set "Amzn:RefreshToken" "REFRESH_TOKEN"
12 | dotnet user-secrets set "Amzn:RoleARN" "arn:aws:iam::1234:role/ROLE_NAME"
13 | ```
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/AmazonSecurityTokenCredentials.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Amazon.SellingPartner.Auth.Core
4 | {
5 | public class AmazonSecurityTokenCredentials
6 | {
7 | public string SessionToken { get; set; }
8 | public string SecretAccessKey { get; set; }
9 | public string AccessKeyId { get; set; }
10 | public DateTime? Expiration { get; set; }
11 | public string Region { get; set; }
12 | public string Host { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/Amazon.SellingPartner.Auth.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Caching/Amazon.SellingPartner.Auth.Caching.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/AwsAuthenticationCredentials.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Auth.Core
2 | {
3 | public class AwsAuthenticationCredentials
4 | {
5 | ///
6 | /// AWS IAM User Access Key Id
7 | ///
8 | public string AccessKeyId { get; set; }
9 |
10 | ///
11 | /// AWS IAM User Secret Key
12 | ///
13 | public string SecretKey { get; set; }
14 |
15 | ///
16 | /// AWS Region
17 | ///
18 | public string Region { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Core/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Amazon.SellingPartner.Core
4 | {
5 | public static class StringExtensions
6 | {
7 | public static string EnsureTrailingSlash(this string url)
8 | {
9 | if (!url.EndsWith("/"))
10 | return url + "/";
11 |
12 | return url;
13 | }
14 |
15 | public static DateTimeOffset ToDateTimeOffset(this string value) => AmazonDateUtil.ConvertToDateTimeOffset(value);
16 |
17 | public static DateTime ToDateTime(this string value) => AmazonDateUtil.ConvertToDateTime(value);
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/LwaTokenResponse.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace Amazon.SellingPartner.Auth.Core
4 | {
5 | public class LwaTokenResponse
6 | {
7 | [JsonProperty(PropertyName = "access_token")]
8 | public string AccessToken { get; set; }
9 |
10 | [JsonProperty(PropertyName = "refresh_token")]
11 | public string RefreshToken { get; set; }
12 |
13 | [JsonProperty(PropertyName = "token_type")]
14 | public string TokenType { get; set; }
15 |
16 | [JsonProperty(PropertyName = "expires_in")]
17 | public int? ExpiresIn { get; set; }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.HttpClient/Amazon.SellingPartner.Auth.HttpClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp.Caching/MemoryCacheRestSharpLwaAuthorizationSigner.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Auth.Core;
2 | using Microsoft.Extensions.Caching.Memory;
3 |
4 | namespace Amazon.SellingPartner.Auth.RestSharp.Caching
5 | {
6 | public class MemoryCacheRestSharpLwaAuthorizationSigner : RestSharpLwaAuthorizationSigner
7 | {
8 | public MemoryCacheRestSharpLwaAuthorizationSigner(LwaAuthorizationCredentials lwaAuthorizationCredentials, IMemoryCache memoryCache) : base(lwaAuthorizationCredentials)
9 | {
10 | RestSharpLwaClient = new MemoryCacheRestSharpLwaClient(lwaAuthorizationCredentials, memoryCache);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.HttpClient.Caching/Amazon.SellingPartner.Auth.HttpClient.Caching.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp.Caching/Amazon.SellingPartner.Auth.RestSharp.Caching.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/HttpClient/SafeAmazonSellingPartnerOrdersClient.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Serialization.NewtonsoftJson;
2 | using Amazon.SellingPartner.Orders.Client;
3 |
4 | namespace Amazon.SellingPartner.IntegrationTests.Helpers.HttpClient
5 | {
6 | ///
7 | /// Derived class allowing us to override the json contract resolvers so it wont throw on missing required data
8 | ///
9 | public class SafeAmazonSellingPartnerOrdersClient : AmazonSellingPartnerOrdersClient
10 | {
11 | public SafeAmazonSellingPartnerOrdersClient(System.Net.Http.HttpClient httpClient) : base(httpClient)
12 | {
13 | JsonSerializerSettings.ContractResolver = new AmazonSellingPartnerSafeContractResolver();
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Serialization.NewtonsoftJson/AmazonSellingPartnerSafeContractResolver.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using Newtonsoft.Json;
3 | using Newtonsoft.Json.Serialization;
4 |
5 | namespace Amazon.SellingPartner.Serialization.NewtonsoftJson
6 | {
7 | ///
8 | /// Some field are marked as required however may be not included in response due to GDPR
9 | ///
10 | public class AmazonSellingPartnerSafeContractResolver : DefaultContractResolver
11 | {
12 | protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
13 | {
14 | JsonProperty? jsonProp = base.CreateProperty(member, memberSerialization);
15 | jsonProp.Required = Required.Default;
16 | return jsonProp;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/HttpClient/AmazonSpHttpClientFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Amazon.SellingPartner.Auth.Core;
3 | using Amazon.SellingPartner.Auth.HttpClient;
4 |
5 | namespace Amazon.SellingPartner.IntegrationTests.Helpers.HttpClient
6 | {
7 | public class AmazonSpHttpClientFactory
8 | {
9 | public System.Net.Http.HttpClient Create(SellingPartnerApiCredentials credentials, string endpoint, RegionEndpoint region)
10 | {
11 | AmazonSpAccessTokenHandler pipeline = new AmazonSpAccessTokenHandlerFactory().Create(credentials, endpoint, region);
12 | var httpClient = new System.Net.Http.HttpClient(pipeline)
13 | {
14 | BaseAddress = new Uri(endpoint)
15 | };
16 | return httpClient;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/HttpClient/TestAmazonSpHttpClientFactory.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Auth.Core;
2 | using Amazon.SellingPartner.Core;
3 |
4 | namespace Amazon.SellingPartner.IntegrationTests.Helpers.HttpClient
5 | {
6 | public class TestAmazonSpHttpClientFactory
7 | {
8 | public System.Net.Http.HttpClient Create(SellingPartnerApiCredentials? credentials = null, string endpoint = null, RegionEndpoint region = null)
9 | {
10 | credentials ??= new SellingPartnerApiCredentialsFactory().CreateFromUserSecrets();
11 | endpoint ??= AmazonSpApiEndpoint.Europe.Endpoint.EnsureTrailingSlash();
12 | region ??= RegionEndpoint.EUWest1;
13 |
14 | return new AmazonSpHttpClientFactory().Create(credentials, endpoint, region);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/SellingPartnerApiCredentials.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Auth.Core
2 | {
3 | public class SellingPartnerApiCredentials
4 | {
5 | public SellingPartnerApiCredentials(string awsKey, string awsSecret, string clientId, string clientSecret, string refreshToken, string roleArn)
6 | {
7 | AWSKey = awsKey;
8 | AWSSecret = awsSecret;
9 | ClientId = clientId;
10 | ClientSecret = clientSecret;
11 | RefreshToken = refreshToken;
12 | RoleARN = roleArn;
13 | }
14 |
15 | public string AWSKey { get; }
16 | public string AWSSecret { get; }
17 | public string ClientId { get; }
18 | public string ClientSecret { get; }
19 | public string RefreshToken { get; }
20 | public string RoleARN { get; }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Client/ExceptionFactory.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using RestSharp;
13 |
14 | namespace Amazon.SellingPartner.RestSharp.Orders.Client
15 | {
16 | ///
17 | /// A delegate to ExceptionFactory method
18 | ///
19 | /// Method name
20 | /// Response
21 | /// Exceptions
22 | public delegate Exception ExceptionFactory(string methodName, IRestResponse response);
23 | }
24 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/RateLimitConfigurationOnRequests.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Auth.Core
2 | {
3 | public class RateLimitConfigurationOnRequests : IRateLimitConfiguration
4 | {
5 | ///
6 | /// RateLimiter Permit
7 | ///
8 | private readonly int _rateLimitPermit;
9 |
10 | ///
11 | /// Timeout for RateLimiter
12 | ///
13 | private readonly int _waitTimeOutInMilliSeconds;
14 |
15 | public RateLimitConfigurationOnRequests(int waitTimeOutInMilliSeconds, int rateLimitPermit)
16 | {
17 | _waitTimeOutInMilliSeconds = waitTimeOutInMilliSeconds;
18 | _rateLimitPermit = rateLimitPermit;
19 | }
20 |
21 | public int GetRateLimitPermit()
22 | {
23 | return _rateLimitPermit;
24 | }
25 |
26 | public int GetTimeOut()
27 | {
28 | return _waitTimeOutInMilliSeconds;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Client/GlobalConfiguration.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | namespace Amazon.SellingPartner.RestSharp.Orders.Client
12 | {
13 | ///
14 | /// provides a compile-time extension point for globally configuring
15 | /// API Clients.
16 | ///
17 | ///
18 | /// A customized implementation via partial class may reside in another file and may
19 | /// be excluded from automatic generation via a .swagger-codegen-ignore file.
20 | ///
21 | public partial class GlobalConfiguration : Configuration
22 | {
23 |
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/LwaAuthorizationCredentials.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Amazon.SellingPartner.Auth.Core
5 | {
6 | public class LwaAuthorizationCredentials
7 | {
8 | public LwaAuthorizationCredentials()
9 | {
10 | Scopes = new List();
11 | }
12 |
13 | ///
14 | /// LWA Client Id
15 | ///
16 | public string ClientId { get; set; }
17 |
18 | ///
19 | /// LWA Client Secret
20 | ///
21 | public string ClientSecret { get; set; }
22 |
23 | ///
24 | /// LWA Refresh Token
25 | ///
26 | public string RefreshToken { get; set; }
27 |
28 | ///
29 | /// LWA Authorization Server Endpoint
30 | ///
31 | public Uri Endpoint { get; set; }
32 |
33 | ///
34 | /// LWA Authorization Scopes
35 | ///
36 | public List Scopes { get; set; }
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/Amazon.SellingPartner.Auth.RestSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Joe Adanah
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Core/AmazonDateUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 |
4 | namespace Amazon.SellingPartner.Core
5 | {
6 | public static class AmazonDateUtil
7 | {
8 | public static DateTime ConvertToDateTime(string value) => DateTime.Parse(value, null, DateTimeStyles.RoundtripKind);
9 |
10 | public static DateTimeOffset ConvertToDateTimeOffset(string value) => DateTimeOffset.Parse(value, null, DateTimeStyles.RoundtripKind);
11 |
12 | public static string ConvertToString(DateTime value) => value.ToString("yyyy-MM-ddTHH:mm:ssZ");
13 |
14 | public static string ConvertToString() => ConvertToString(new DateTimeOffset());
15 |
16 | public static string ConvertToString(DateTimeOffset value) => value.ToString("yyyy-MM-ddTHH:mm:sszzz");
17 |
18 | public static string ConvertToString(DateTime start, DateTime end, string delimiter = "--") => ConvertToString(start) + delimiter + ConvertToString(end);
19 |
20 | public static string ConvertToString(DateTimeOffset start, DateTimeOffset end, string delimiter = "--") => ConvertToString(start) + delimiter + ConvertToString(end);
21 | }
22 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/SellingPartnerClientFactory.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Feed.Client;
2 | using Amazon.SellingPartner.Finances.Client;
3 | using Amazon.SellingPartner.FulfillmentInbound.Client;
4 | using Amazon.SellingPartner.Orders.Client;
5 | using Amazon.SellingPartner.ProductFees.Client;
6 | using Amazon.SellingPartner.Reports.Client;
7 | using Amazon.SellingPartner.Sales.Client;
8 |
9 | namespace Amazon.SellingPartner.IntegrationTests.Helpers
10 | {
11 | public abstract class SellingPartnerClientFactory
12 | {
13 | public abstract IAmazonSellingPartnerFinancesClient CreateFinancesClient();
14 | public abstract IAmazonSellingPartnerFulfillmentInboundClient CreateFulfillmentInboundClient();
15 | public abstract IAmazonSellingPartnerOrdersClient CreateOrdersClient();
16 | public abstract IAmazonSellingPartnerProductFeesClient CreateProductFeesClient();
17 | public abstract IAmazonSellingPartnerReportsClient CreateReportsClient();
18 | public abstract IAmazonSellingPartnerSalesClient CreateSalesClient();
19 | public abstract IAmazonSellingPartnerFeedClient CreateFeedClient();
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/SellingPartnerApiCredentialsFactory.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Auth.Core;
2 | using Microsoft.Extensions.Configuration;
3 |
4 | namespace Amazon.SellingPartner.IntegrationTests.Helpers
5 | {
6 | public class SellingPartnerApiCredentialsFactory
7 | {
8 | IConfiguration Configuration { get; set; }
9 |
10 | public SellingPartnerApiCredentialsFactory()
11 | {
12 | // the type specified here is just so the secrets library can
13 | // find the UserSecretId we added in the csproj file
14 | IConfigurationBuilder builder = new ConfigurationBuilder()
15 | .AddUserSecrets();
16 |
17 | Configuration = builder.Build();
18 | }
19 |
20 |
21 | public SellingPartnerApiCredentials CreateFromUserSecrets()
22 | {
23 | return new SellingPartnerApiCredentials(awsKey: Configuration["Amzn:AWSKey"], awsSecret: Configuration["Amzn:AWSSecret"], clientId: Configuration["Amzn:ClientId"],
24 | clientSecret: Configuration["Amzn:ClientSecret"], refreshToken: Configuration["Amzn:RefreshToken"], roleArn: Configuration["Amzn:RoleARN"]);
25 |
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Client/SwaggerDateConverter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using Newtonsoft.Json.Converters;
12 |
13 | namespace Amazon.SellingPartner.RestSharp.Orders.Client
14 | {
15 | ///
16 | /// Formatter for 'date' swagger formats ss defined by full-date - RFC3339
17 | /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
18 | ///
19 | public class SwaggerDateConverter : IsoDateTimeConverter
20 | {
21 | ///
22 | /// Initializes a new instance of the class.
23 | ///
24 | public SwaggerDateConverter()
25 | {
26 | // full-date = date-fullyear "-" date-month "-" date-mday
27 | DateTimeFormat = "yyyy-MM-dd";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/AmazonSpRestRequestExtension.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Amazon.SecurityToken.Model;
3 | using Amazon.SellingPartner.Auth.Core;
4 | using RestSharp;
5 |
6 | namespace Amazon.SellingPartner.Auth.RestSharp
7 | {
8 | public static class AmazonSpRestRequestExtension
9 | {
10 | public static IRestRequest SignWithAccessToken(this IRestRequest restRequest, string clientId, string clientSecret, string refreshToken)
11 | {
12 | LwaAuthorizationCredentials lwaAuthorizationCredentials = AmazonSpRestRequestUtil.GetLwaAuthorizationCredentials(clientId, clientSecret, refreshToken);
13 | return new RestSharpLwaAuthorizationSigner(lwaAuthorizationCredentials).Sign(restRequest);
14 | }
15 |
16 |
17 | public static async Task SignWithStsKeysAndSecurityTokenAsync(this IRestRequest restRequest, string host, string roleArn, string accessKey, string secretKey,
18 | RegionEndpoint region)
19 | {
20 | AssumeRoleResponse response = await AmazonSpRestRequestUtil.AssumeRoleAsync(roleArn, accessKey, secretKey, region);
21 | return AmazonSpRestRequestUtil.AddSecurityTokenAndV4Sign(restRequest, host, region, response);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonSpSalesTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Amazon.SellingPartner.Core;
4 | using Amazon.SellingPartner.IntegrationTests.Helpers;
5 | using Amazon.SellingPartner.Sales.Client;
6 | using FluentAssertions;
7 | using Xunit;
8 |
9 | namespace Amazon.SellingPartner.IntegrationTests
10 | {
11 | public class AmazonSpSalesTests
12 | {
13 | private readonly IAmazonSellingPartnerSalesClient _client;
14 |
15 | public AmazonSpSalesTests()
16 | {
17 | _client = new DefaultSellingPartnerClientFactory().CreateSalesClient();
18 | }
19 |
20 | [Fact]
21 | public async Task Should_get_sales_order_metrics()
22 | {
23 | // "2022-03-01T00:00:00-07:00--2022-03-04700:00:00-07:00"
24 | // "2022-03-01T00:00:00Z--2022-03-04T00:00:00Z"
25 | var startDate = new DateTime(2022, 03, 01, 00, 00, 00, DateTimeKind.Utc);
26 | var endDate = new DateTime(2022, 03, 07, 00, 00, 00, DateTimeKind.Utc);
27 |
28 | var response = await _client.GetOrderMetricsAsync(new[] { AmazonMarketplace.UK.MarketplaceId }, AmazonDateUtil.ConvertToString(startDate, endDate), Granularity.Total);
29 |
30 | response.Should().NotBeNull();
31 | response.Payload.Should().NotBeNull();
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp.Caching/MemoryCacheRestSharpLwaClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Amazon.SellingPartner.Auth.Core;
4 | using Microsoft.Extensions.Caching.Memory;
5 |
6 | namespace Amazon.SellingPartner.Auth.RestSharp.Caching
7 | {
8 | public class MemoryCacheRestSharpLwaClient : RestSharpLwaClient
9 | {
10 | private readonly IMemoryCache _memoryCache;
11 |
12 | public MemoryCacheRestSharpLwaClient(LwaAuthorizationCredentials lwaAuthorizationCredentials, IMemoryCache memoryCache) : base(lwaAuthorizationCredentials)
13 | {
14 | _memoryCache = memoryCache;
15 | }
16 |
17 | public override LwaTokenResponse GetTokenResponse()
18 | {
19 | var key = string.Format("amazon:lwa:{0}:{1}:{2}:token",
20 | LWAAuthorizationCredentials.ClientId,
21 | LWAAuthorizationCredentials.Endpoint.Host,
22 | string.Join("-", LWAAuthorizationCredentials?.Scopes ?? new List()));
23 |
24 | return _memoryCache.GetOrCreate(key, entry =>
25 | {
26 | // cache for 60 mins - 5 mins safety margin
27 | entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(3600 - (60 * 5));
28 | return base.GetTokenResponse();
29 | });
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/RestSharpLwaAuthorizationSigner.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Auth.Core;
2 | using RestSharp;
3 |
4 | namespace Amazon.SellingPartner.Auth.RestSharp
5 | {
6 | public class RestSharpLwaAuthorizationSigner
7 | {
8 | public const string AccessTokenHeaderName = "x-amz-access-token";
9 |
10 | ///
11 | /// Constructor for RestSharpLwaAuthorizationSigner
12 | ///
13 | /// LWA Authorization Credentials for token exchange
14 | public RestSharpLwaAuthorizationSigner(LwaAuthorizationCredentials lwaAuthorizationCredentials)
15 | {
16 | RestSharpLwaClient = new RestSharpLwaClient(lwaAuthorizationCredentials);
17 | }
18 |
19 | public RestSharpLwaClient RestSharpLwaClient { get; set; }
20 |
21 | ///
22 | /// Signs a request with LWA Access Token
23 | ///
24 | /// Request to sign
25 | /// restRequest with LWA signature
26 | public IRestRequest Sign(IRestRequest restRequest)
27 | {
28 | string accessToken = RestSharpLwaClient.GetAccessToken();
29 |
30 | restRequest.AddHeader(AccessTokenHeaderName, accessToken);
31 |
32 | return restRequest;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Client/IApiAccessor.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 |
13 | namespace Amazon.SellingPartner.RestSharp.Orders.Client
14 | {
15 | ///
16 | /// Represents configuration aspects required to interact with the API endpoints.
17 | ///
18 | public interface IApiAccessor
19 | {
20 | ///
21 | /// Gets or sets the configuration object
22 | ///
23 | /// An instance of the Configuration
24 | Configuration Configuration {get; set;}
25 |
26 | ///
27 | /// Gets the base path of the API client.
28 | ///
29 | /// The base path
30 | String GetBasePath();
31 |
32 | ///
33 | /// Provides a factory method hook for the creation of exceptions.
34 | ///
35 | ExceptionFactory ExceptionFactory { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.Auth.Tests/Amazon.SellingPartner.Auth.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | latest
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers; buildtransitive
15 |
16 |
17 | all
18 | runtime; build; native; contentfiles; analyzers; buildtransitive
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Sales.Client/Amazon.SellingPartner.Sales.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Sales.Client
7 | Amazon.SellingPartner.Sales.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Orders.Client/Amazon.SellingPartner.Orders.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Orders.Client
7 | Amazon.SellingPartner.Orders.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Sellers.Client/Amazon.SellingPartner.Sellers.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Sellers.Client
7 | Amazon.SellingPartner.Sellers.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Finances.Client/Amazon.SellingPartner.Finances.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Finances.Client
7 | Amazon.SellingPartner.Finances.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Services.Client/Amazon.SellingPartner.Services.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Services.Client
7 | Amazon.SellingPartner.Services.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Shipping.Client/Amazon.SellingPartner.Shipping.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Shipping.Client
7 | Amazon.SellingPartner.Shipping.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Messaging.Client/Amazon.SellingPartner.Messaging.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Messaging.Client
7 | Amazon.SellingPartner.Messaging.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Tokens.Client/Amazon.SellingPartner.Tokens.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Tokens.Client
7 | Amazon.SellingPartner.Tokens.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Uploads.Client/Amazon.SellingPartner.Uploads.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Uploads.Client
7 | Amazon.SellingPartner.Uploads.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.FbaInventory.Client/Amazon.SellingPartner.FbaInventory.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.FbaInventory.Client
7 | Amazon.SellingPartner.FbaInventory.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.ProductFees.Client/Amazon.SellingPartner.ProductFees.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.ProductFees.Client
7 | Amazon.SellingPartner.ProductFees.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Authorization.Client/Amazon.SellingPartner.Authorization.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Authorization.Client
7 | Amazon.SellingPartner.Authorization.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Notifications.Client/Amazon.SellingPartner.Notifications.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Notifications.Client
7 | Amazon.SellingPartner.Notifications.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Solicitations.Client/Amazon.SellingPartner.Solicitations.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Solicitations.Client
7 | Amazon.SellingPartner.Solicitations.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.ProductPricing.Client/Amazon.SellingPartner.ProductPricing.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.ProductPricing.Client
7 | Amazon.SellingPartner.ProductPricing.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonSpFulfillmentInboundTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Amazon.SellingPartner.Core;
4 | using Amazon.SellingPartner.FulfillmentInbound.Client;
5 | using Amazon.SellingPartner.IntegrationTests.Helpers;
6 | using FluentAssertions;
7 | using Xunit;
8 |
9 | namespace Amazon.SellingPartner.IntegrationTests
10 | {
11 | public class AmazonSpFulfillmentInboundTests
12 | {
13 | private readonly IAmazonSellingPartnerFulfillmentInboundClient _client;
14 |
15 | public AmazonSpFulfillmentInboundTests()
16 | {
17 | _client = new DefaultSellingPartnerClientFactory().CreateFulfillmentInboundClient();
18 | }
19 |
20 | [Fact(Skip = "Model doesnt look right as v0")]
21 | public async Task Should_get_fba_inbound_shipments()
22 | {
23 | var response = await _client.GetShipmentsAsync(QueryType.DATE_RANGE, marketplaceId: AmazonMarketplace.UK.MarketplaceId, lastUpdatedAfter: new DateTime(2022, 03, 01),
24 | lastUpdatedBefore: new DateTime(2022, 03, 07));
25 |
26 | response.Should().NotBeNull();
27 | }
28 |
29 | [Fact]
30 | public async Task Should_get_fba_shipment_items_by_id()
31 | {
32 | var response = await _client.GetShipmentItemsByShipmentIdAsync("FBA15FQSDSV5", AmazonMarketplace.UK.MarketplaceId);
33 |
34 | response.Should().NotBeNull();
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.APlusContent.Client/Amazon.SellingPartner.APlusContent.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.APlusContent.Client
7 | Amazon.SellingPartner.APlusContent.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.FbaInboundEligility.Client/Amazon.SellingPartner.FbaInboundEligility.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.FbaInboundEligility.Client
7 | Amazon.SellingPartner.FbaInboundEligility.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.FbaSmallAndLight.Client/Amazon.SellingPartner.FbaSmallAndLight.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.FbaSmallAndLight.Client
7 | Amazon.SellingPartner.FbaSmallAndLight.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.ShipmentInvoicing.Client/Amazon.SellingPartner.ShipmentInvoicing.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.ShipmentInvoicing.Client
7 | Amazon.SellingPartner.ShipmentInvoicing.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.FulfillmentInbound.Client/Amazon.SellingPartner.FulfillmentInbound.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.FulfillmentInbound.Client
7 | Amazon.SellingPartner.FulfillmentInbound.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.MerchantFufillment.Client/Amazon.SellingPartner.MerchantFufillment.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.MerchantFufillment.Client
7 | Amazon.SellingPartner.MerchantFufillment.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.FulfillmentOutbound.Client/Amazon.SellingPartner.FulfillmentOutbound.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.FulfillmentOutbound.Client
7 | Amazon.SellingPartner.FulfillmentOutbound.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.ListingRestrictions.Client/Amazon.SellingPartner.ListingRestrictions.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.ListingRestrictions.Client
7 | Amazon.SellingPartner.ListingRestrictions.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.ProductTypeDefinitions.Client/Amazon.SellingPartner.ProductTypeDefinitions.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.ProductTypeDefinitions.Client
7 | Amazon.SellingPartner.ProductTypeDefinitions.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Feed.Client/Amazon.SellingPartner.Feed.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Feed.Client
7 | Amazon.SellingPartner.Feed.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Reports.Client/Amazon.SellingPartner.Reports.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.Reports.Client
7 | Amazon.SellingPartner.Reports.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.CatalogItems.Client/Amazon.SellingPartner.CatalogItems.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.CatalogItems.Client
7 | Amazon.SellingPartner.CatalogItems.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/RestSharp/AmazonSpConfiguration.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.RestSharp.Orders.Client;
2 |
3 | namespace Amazon.SellingPartner.IntegrationTests.Helpers.RestSharp
4 | {
5 | public partial class AmazonSpConfiguration : GlobalConfiguration
6 | {
7 | private static string _clientId;
8 | private static string _clientSecret;
9 | private static string _refreshToken;
10 | private static string _host;
11 | private static string _roleArn;
12 | private static string _awsKey;
13 | private static string _awsSecret;
14 | private static RegionEndpoint _region;
15 | public override string BasePath { get; set; } = "https://sellingpartnerapi-eu.amazon.com";
16 | public override AmazonSpApiClient ApiClient { get; } = GetClient();
17 |
18 | private static AmazonSpApiClient GetClient()
19 | {
20 | return new AmazonSpApiClient(_clientId, _clientSecret, _refreshToken, _host, _roleArn, _awsKey, _awsSecret, _region);
21 | }
22 |
23 | public static void SetClientParams(string clientId, string clientSecret, string refreshToken, string host, string roleArn, string awsKey, string awsSecret, RegionEndpoint region)
24 | {
25 | _clientId = clientId;
26 | _clientSecret = clientSecret;
27 | _refreshToken = refreshToken;
28 | _host = host;
29 | _roleArn = roleArn;
30 | _awsKey = awsKey;
31 | _awsSecret = awsSecret;
32 | _region = region;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.ListingItems.Client/Amazon.SellingPartner.ListingItems.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | latest
6 | Amazon.SellingPartner.ListingItems.Client
7 | Amazon.SellingPartner.ListingItems.Client
8 |
9 |
10 |
11 |
12 |
13 | all
14 | runtime; build; native; contentfiles; analyzers
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.HttpClient/AmazonSpSecurityTokenHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Http;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Amazon.SellingPartner.Auth.Core;
5 |
6 | namespace Amazon.SellingPartner.Auth.HttpClient
7 | {
8 | public class AmazonSpSecurityTokenHandler : DelegatingHandler
9 | {
10 | public const string SecurityTokenHeaderName = "x-amz-security-token";
11 |
12 | private readonly IAmazonSecurityTokenCredentialResolver _securityTokenCredentialResolver;
13 |
14 | public AmazonSpSecurityTokenHandler(IAmazonSecurityTokenCredentialResolver securityTokenCredentialResolver)
15 | {
16 | _securityTokenCredentialResolver = securityTokenCredentialResolver;
17 | }
18 |
19 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
20 | {
21 | AmazonSecurityTokenCredentials response = await _securityTokenCredentialResolver.GetCredentialsAsync(cancellationToken);
22 |
23 | request.Headers.Add(SecurityTokenHeaderName, response.SessionToken);
24 |
25 | var awsAuthenticationCredentials = new AwsAuthenticationCredentials
26 | {
27 | AccessKeyId = response.AccessKeyId,
28 | SecretKey = response.SecretAccessKey,
29 | Region = response.Region
30 | };
31 |
32 | var signer = new HttpRequestMessageAWSSigV4Signer(awsAuthenticationCredentials);
33 | request = signer.Sign(request, response.Host);
34 |
35 | return await base.SendAsync(request, cancellationToken);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonSpProductFeesTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Amazon.SellingPartner.Core;
4 | using Amazon.SellingPartner.IntegrationTests.Helpers;
5 | using Amazon.SellingPartner.ProductFees.Client;
6 | using FluentAssertions;
7 | using Xunit;
8 |
9 | namespace Amazon.SellingPartner.IntegrationTests
10 | {
11 | public class AmazonSpProductFeesTests
12 | {
13 | private readonly IAmazonSellingPartnerProductFeesClient _client;
14 |
15 | public AmazonSpProductFeesTests()
16 | {
17 | _client = new DefaultSellingPartnerClientFactory().CreateProductFeesClient();
18 | }
19 |
20 | [Fact]
21 | public async Task Should_get_fee_estimate_by_sku()
22 | {
23 | var response = await _client.GetMyFeesEstimateForSKUAsync(new GetMyFeesEstimateRequest()
24 | {
25 | FeesEstimateRequest = new FeesEstimateRequest()
26 | {
27 | Identifier = Guid.NewGuid().ToString(),
28 | IsAmazonFulfilled = false,
29 | MarketplaceId = AmazonMarketplace.UK.MarketplaceId,
30 | PriceToEstimateFees = new PriceToEstimateFees()
31 | {
32 | ListingPrice = new MoneyType()
33 | {
34 | Amount = 14.99,
35 | CurrencyCode = "GBP"
36 | }
37 | }
38 | }
39 | }, "5003");
40 |
41 | response.Should().NotBeNull();
42 | response.Payload.Should().NotBeNull();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/RestSharp/AmazonSpApiClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Amazon.SellingPartner.Auth.RestSharp;
3 | using Amazon.SellingPartner.RestSharp.Orders.Client;
4 | using RestSharp;
5 |
6 | namespace Amazon.SellingPartner.IntegrationTests.Helpers.RestSharp
7 | {
8 | public class AmazonSpApiClient : ApiClient
9 | {
10 | private readonly string _awsKey;
11 | private readonly string _awsSecret;
12 | private readonly string _clientId;
13 | private readonly string _clientSecret;
14 | private readonly string _host;
15 | private readonly string _refreshToken;
16 | private readonly RegionEndpoint _region;
17 | private readonly string _roleArn;
18 |
19 | public AmazonSpApiClient(string clientId, string clientSecret, string refreshToken, string host, string roleArn, string awsKey, string awsSecret, RegionEndpoint region) : base(
20 | "https://sellingpartnerapi-eu.amazon.com")
21 | {
22 | _clientId = clientId;
23 | _clientSecret = clientSecret;
24 | _refreshToken = refreshToken;
25 | _host = new Uri(host).Host;
26 | _roleArn = roleArn;
27 | _awsKey = awsKey;
28 | _awsSecret = awsSecret;
29 | _region = region;
30 | }
31 |
32 | protected override void InterceptRequest(IRestRequest request)
33 | {
34 | request.SignWithAccessToken(_clientId, _clientSecret, _refreshToken);
35 |
36 | request.SignWithStsKeysAndSecurityTokenAsync(_host, _roleArn, _awsKey, _awsSecret, _region)
37 | .GetAwaiter()
38 | .GetResult();
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.HttpClient.Caching/MemoryCacheHttpLwaClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 | using Amazon.SellingPartner.Auth.Core;
5 | using Microsoft.Extensions.Caching.Memory;
6 |
7 | namespace Amazon.SellingPartner.Auth.HttpClient.Caching
8 | {
9 | public class MemoryCacheHttpLwaClient : HttpLwaClient
10 | {
11 | private readonly IMemoryCache _memoryCache;
12 |
13 | public MemoryCacheHttpLwaClient(System.Net.Http.HttpClient httpClient, LwaAuthorizationCredentials lwaAuthorizationCredentials, IMemoryCache memoryCache) : base(httpClient,
14 | lwaAuthorizationCredentials)
15 | {
16 | _memoryCache = memoryCache;
17 | }
18 |
19 | public MemoryCacheHttpLwaClient(LwaAuthorizationCredentials lwaAuthorizationCredentials, IMemoryCache memoryCache) : base(lwaAuthorizationCredentials)
20 | {
21 | _memoryCache = memoryCache;
22 | }
23 |
24 | public override async Task GetTokenResponseAsync()
25 | {
26 | var key = string.Format("amzn:lwa:{0}:{1}:{2}:token",
27 | LWAAuthorizationCredentials.ClientId,
28 | LWAAuthorizationCredentials.Endpoint.Host,
29 | string.Join("-", LWAAuthorizationCredentials?.Scopes ?? new List()));
30 |
31 | return await _memoryCache.GetOrCreateAsync(key, async entry =>
32 | {
33 | // cache for 55 mins (token is valid for 60 mins)
34 | entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(3600 - (60 * 5));
35 | return await base.GetTokenResponseAsync();
36 | });
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/DefaultSellingPartnerClientFactory.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Feed.Client;
2 | using Amazon.SellingPartner.Finances.Client;
3 | using Amazon.SellingPartner.FulfillmentInbound.Client;
4 | using Amazon.SellingPartner.Orders.Client;
5 | using Amazon.SellingPartner.ProductFees.Client;
6 | using Amazon.SellingPartner.Reports.Client;
7 | using Amazon.SellingPartner.Sales.Client;
8 |
9 | namespace Amazon.SellingPartner.IntegrationTests.Helpers
10 | {
11 | public class DefaultSellingPartnerClientFactory : SellingPartnerClientFactory
12 | {
13 | private readonly SellingPartnerClientFactory _safeFactory;
14 |
15 | public DefaultSellingPartnerClientFactory()
16 | {
17 | _safeFactory = new SafeSellingPartnerClientFactory();
18 | }
19 |
20 | public override IAmazonSellingPartnerFinancesClient CreateFinancesClient() => _safeFactory.CreateFinancesClient();
21 |
22 | public override IAmazonSellingPartnerFulfillmentInboundClient CreateFulfillmentInboundClient() => _safeFactory.CreateFulfillmentInboundClient();
23 |
24 | public override IAmazonSellingPartnerOrdersClient CreateOrdersClient() => _safeFactory.CreateOrdersClient();
25 |
26 | public override IAmazonSellingPartnerProductFeesClient CreateProductFeesClient() => _safeFactory.CreateProductFeesClient();
27 |
28 | public override IAmazonSellingPartnerReportsClient CreateReportsClient() => _safeFactory.CreateReportsClient();
29 |
30 | public override IAmazonSellingPartnerSalesClient CreateSalesClient() => _safeFactory.CreateSalesClient();
31 |
32 | public override IAmazonSellingPartnerFeedClient CreateFeedClient() => _safeFactory.CreateFeedClient();
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp.Caching/AmazonSpCacheRestRequestExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Amazon.SecurityToken.Model;
4 | using Amazon.SellingPartner.Auth.Core;
5 | using Microsoft.Extensions.Caching.Memory;
6 | using RestSharp;
7 |
8 | namespace Amazon.SellingPartner.Auth.RestSharp.Caching
9 | {
10 | public static class AmazonSpCacheRestRequestExtension
11 | {
12 | public static IRestRequest SignWithCachedAccessToken(this IRestRequest restRequest, IMemoryCache memoryCache, string clientId, string clientSecret, string refreshToken)
13 | {
14 | LwaAuthorizationCredentials lwaAuthorizationCredentials = AmazonSpRestRequestUtil.GetLwaAuthorizationCredentials(clientId, clientSecret, refreshToken);
15 | return new MemoryCacheRestSharpLwaAuthorizationSigner(lwaAuthorizationCredentials, memoryCache).Sign(restRequest);
16 | }
17 |
18 |
19 | public static async Task SignWithCachedStsKeysAndSecurityTokenAsync(this IRestRequest restRequest, IMemoryCache memoryCache, string host, string roleArn, string accessKey,
20 | string secretKey, RegionEndpoint region)
21 | {
22 | var key = $"amazon:sts:{host}:{roleArn}:{accessKey}:{region.SystemName}:token";
23 |
24 | AssumeRoleResponse response = await memoryCache.GetOrCreateAsync(key, async entry =>
25 | {
26 | entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(3600 - (60 * 5));
27 | return await AmazonSpRestRequestUtil.AssumeRoleAsync(roleArn, accessKey, secretKey, region);
28 | });
29 |
30 | return AmazonSpRestRequestUtil.AddSecurityTokenAndV4Sign(restRequest, host, region, response);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Amazon.SellingPartner.RestSharp.Orders.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net48
5 | Amazon.SellingPartner.RestSharp.Orders
6 | Library
7 | Swagger
8 | Swagger
9 | Swagger Library
10 | A library generated from a Swagger doc
11 | No Copyright
12 | true
13 | true
14 | true
15 | Amazon.SellingPartner.RestSharp.Orders
16 | 1.0.0
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/LwaAccessTokenRequestMetaBuilder.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Auth.Core
2 | {
3 | public class LwaAccessTokenRequestMetaBuilder
4 | {
5 | public const string SellerApiGrantType = "refresh_token";
6 | public const string SellerlessApiGrantType = "client_credentials";
7 |
8 | private const string Delimiter = " ";
9 |
10 | ///
11 | /// Builds an instance of LwaAccessTokenRequestMeta modeling appropriate LWA token
12 | /// request params based on configured LwaAuthorizationCredentials
13 | ///
14 | /// LWA Authorization Credentials
15 | ///
16 | public virtual LwaAccessTokenRequestMeta Build(LwaAuthorizationCredentials lwaAuthorizationCredentials)
17 | {
18 | LwaAccessTokenRequestMeta lwaAccessTokenRequestMeta = new LwaAccessTokenRequestMeta()
19 | {
20 | ClientId = lwaAuthorizationCredentials.ClientId,
21 | ClientSecret = lwaAuthorizationCredentials.ClientSecret,
22 | RefreshToken = lwaAuthorizationCredentials.RefreshToken
23 | };
24 |
25 | if (lwaAuthorizationCredentials.Scopes == null || lwaAuthorizationCredentials.Scopes.Count == 0)
26 | {
27 | lwaAccessTokenRequestMeta.GrantType = SellerApiGrantType;
28 | }
29 | else
30 | {
31 | lwaAccessTokenRequestMeta.Scope = string.Join(Delimiter, lwaAuthorizationCredentials.Scopes);
32 | lwaAccessTokenRequestMeta.GrantType = SellerlessApiGrantType;
33 | }
34 |
35 | return lwaAccessTokenRequestMeta;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.Auth.Tests/UtilsTest.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Text;
3 | using Amazon.SellingPartner.Auth.Core;
4 | using Xunit;
5 |
6 | namespace Amazon.SellingPartner.Auth.Tests
7 | {
8 | public class UtilsTest
9 | {
10 | private const string TestString = "test";
11 |
12 | [Fact]
13 | public void TestUrlEncode_WithoutEncoding()
14 | {
15 | string result = Utils.UrlEncode("Test-_.~");
16 | Assert.Equal("Test-_.~", result);
17 | }
18 |
19 | [Fact]
20 | public void TestUrlEncode_WithEncoding()
21 | {
22 | string result = Utils.UrlEncode("Test$%*^");
23 | Assert.Equal("Test%24%25%2A%5E", result);
24 | }
25 |
26 | [Fact]
27 | public void TestUrlEncode_Empty()
28 | {
29 | Assert.Empty(Utils.UrlEncode(string.Empty));
30 | }
31 |
32 | [Fact]
33 | public void TestHash()
34 | {
35 | Assert.NotEmpty(Utils.Hash(TestString));
36 | }
37 |
38 | [Fact]
39 | public void TestToHex()
40 | {
41 | string result = Utils.ToHex(Encoding.UTF8.GetBytes(TestString));
42 | Assert.Equal("74657374", result);
43 | }
44 |
45 | [Fact]
46 | public void TestGetKeyedHash()
47 | {
48 | byte[] expectedHash = new byte[]
49 | {
50 | 106, 120, 238, 51, 86, 30, 87, 173, 232, 197, 95, 132, 155,
51 | 183, 80, 81, 25, 213, 212, 241, 218, 201, 168, 17, 253, 143, 54, 226, 42, 118, 61, 54
52 | };
53 | byte[] keyedHash = Utils.GetKeyedHash(Encoding.UTF8.GetBytes("testKey"), TestString);
54 | Assert.True(expectedHash.SequenceEqual(keyedHash));
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonUtilTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Amazon.SellingPartner.Core;
3 | using FluentAssertions;
4 | using Xunit;
5 |
6 | namespace Amazon.SellingPartner.IntegrationTests
7 | {
8 | public class AmazonUtilTests
9 | {
10 | [Fact]
11 | public void Should_parse_date_time_offset_string()
12 | {
13 | var value = "2022-03-01T00:00:00-07:00";
14 | var expected = new DateTimeOffset(2022, 03, 01, 00, 00, 00, TimeSpan.FromHours(-7));
15 |
16 | var actual = AmazonDateUtil.ConvertToDateTimeOffset(value);
17 |
18 | actual.Should().Be(expected);
19 | }
20 |
21 | [Fact]
22 | public void Should_parse_date_time_string()
23 | {
24 | var value = "2022-03-04T00:00:00Z";
25 | var expected = new DateTime(2022, 03, 04, 00, 00, 00, DateTimeKind.Utc);
26 |
27 | var actual = AmazonDateUtil.ConvertToDateTime(value);
28 |
29 | actual.Should().Be(expected);
30 | }
31 |
32 | [Fact]
33 | public void Should_convert_to_date_time_offset_string()
34 | {
35 | var value = new DateTimeOffset(2022, 03, 01, 00, 00, 00, TimeSpan.FromHours(-7));
36 | var expected = "2022-03-01T00:00:00-07:00";
37 |
38 | var actual = AmazonDateUtil.ConvertToString(value);
39 |
40 | actual.Should().Be(expected);
41 | }
42 |
43 | [Fact]
44 | public void Should_convert_to_date_time_string()
45 | {
46 | var value = new DateTime(2022, 03, 04, 00, 00, 00, DateTimeKind.Utc);
47 | var expected = "2022-03-04T00:00:00Z";
48 |
49 | var actual = AmazonDateUtil.ConvertToString(value);
50 |
51 | actual.Should().Be(expected);
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.HttpClient/AmazonSpAccessTokenHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 | using Amazon.SellingPartner.Auth.Core;
6 |
7 | namespace Amazon.SellingPartner.Auth.HttpClient
8 | {
9 | public class AmazonSpAccessTokenHandler : DelegatingHandler
10 | {
11 | public const string AccessTokenHeaderName = "x-amz-access-token";
12 |
13 | private readonly ILwaClient _lwaClient;
14 |
15 | public AmazonSpAccessTokenHandler(string clientId, string clientSecret, string refreshToken, string endpoint = "https://api.amazon.com/auth/o2/token") : this(clientId, clientSecret,
16 | refreshToken, new Uri(endpoint))
17 | {
18 | }
19 |
20 | public AmazonSpAccessTokenHandler(string clientId, string clientSecret, string refreshToken, Uri endpoint)
21 | {
22 | var lwaAuthorizationCredentials = new LwaAuthorizationCredentials
23 | {
24 | ClientId = clientId,
25 | ClientSecret = clientSecret,
26 | Endpoint = endpoint,
27 | RefreshToken = refreshToken,
28 | };
29 |
30 | _lwaClient = new HttpLwaClient(lwaAuthorizationCredentials);
31 | }
32 |
33 | public AmazonSpAccessTokenHandler(ILwaClient lwaClient)
34 | {
35 | _lwaClient = lwaClient;
36 | }
37 |
38 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
39 | {
40 | string accessToken = await _lwaClient.GetAccessTokenAsync();
41 |
42 | request.Headers.Add(AccessTokenHeaderName, accessToken);
43 |
44 | return await base.SendAsync(request, cancellationToken);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Caching/MemoryCacheAmazonSecurityTokenCredentialResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Amazon.SellingPartner.Auth.Core;
5 | using Microsoft.Extensions.Caching.Memory;
6 |
7 | namespace Amazon.SellingPartner.Auth.Caching
8 | {
9 | public class MemoryCacheAmazonSecurityTokenCredentialResolver : AmazonSecurityTokenCredentialResolver, IAmazonSecurityTokenCredentialResolver
10 | {
11 | private readonly string _accessKey;
12 | private readonly IMemoryCache _memoryCache;
13 | private readonly string _region;
14 |
15 | private readonly string _roleArn;
16 |
17 | public MemoryCacheAmazonSecurityTokenCredentialResolver(IMemoryCache memoryCache, string host, string roleArn, string accessKey, string secretKey, RegionEndpoint region,
18 | int roleDurationSeconds = 3600, Func? roleSessionNameGenerator = null) : base(host, roleArn, accessKey, secretKey, region, roleDurationSeconds, roleSessionNameGenerator)
19 | {
20 | _memoryCache = memoryCache;
21 | _roleArn = roleArn;
22 | _accessKey = accessKey;
23 | _region = region.SystemName;
24 | }
25 |
26 | public new async Task GetCredentialsAsync(CancellationToken cancellationToken = default)
27 | {
28 | var key = string.Format("amzn:security-session:{0}:{1}:{2}",
29 | _region,
30 | _roleArn,
31 | _accessKey);
32 |
33 | return await _memoryCache.GetOrCreateAsync(key, async entry =>
34 | {
35 | AmazonSecurityTokenCredentials response = await base.GetCredentialsAsync(cancellationToken);
36 | entry.AbsoluteExpiration = new DateTimeOffset(response.Expiration.GetValueOrDefault()) - TimeSpan.FromMinutes(5);
37 | return response;
38 | });
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Core/AmazonSpApiEndpoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Amazon.SellingPartner.Core
4 | {
5 | ///
6 | /// https://developer-docs.amazon.com/sp-api/docs/sp-api-endpoints
7 | ///
8 | public sealed class AmazonSpApiEndpoint
9 | {
10 | public static readonly AmazonSpApiEndpoint NorthAmerica = new AmazonSpApiEndpoint(region: "North America", regionDescription: "North America (Canada, US, Mexico, and Brazil marketplaces)",
11 | endpoint: "https://sellingpartnerapi-na.amazon.com", awsRegion: "us-east-1");
12 |
13 | public static readonly AmazonSpApiEndpoint Europe = new AmazonSpApiEndpoint(region: "Europe",
14 | regionDescription: "Europe (Spain, UK, France, Netherlands, Germany, Italy, Sweden, Poland, Saudi Arabia, Egypt, Turkey, United Arab Emirates, and India marketplaces)",
15 | endpoint: "https://sellingpartnerapi-eu.amazon.com", awsRegion: "eu-west-1");
16 |
17 | public static readonly AmazonSpApiEndpoint FarEast = new AmazonSpApiEndpoint(region: "Far East", regionDescription: "Far East (Singapore, Australia, and Japan marketplaces)",
18 | endpoint: "https://sellingpartnerapi-fe.amazon.com", awsRegion: "us-west-2");
19 |
20 |
21 | private AmazonSpApiEndpoint(string region, string regionDescription, string endpoint, string awsRegion)
22 | {
23 | Region = region ?? throw new ArgumentNullException(nameof(region));
24 | RegionDescription = regionDescription ?? throw new ArgumentNullException(nameof(regionDescription));
25 | Endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint));
26 | AwsRegion = awsRegion ?? throw new ArgumentNullException(nameof(awsRegion));
27 | }
28 |
29 | public string Region { get; }
30 | public string RegionDescription { get; }
31 | public string Endpoint { get; }
32 | public string AwsRegion { get; }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Client/ApiResponse.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System.Collections.Generic;
12 |
13 | namespace Amazon.SellingPartner.RestSharp.Orders.Client
14 | {
15 | ///
16 | /// API Response
17 | ///
18 | public class ApiResponse
19 | {
20 | ///
21 | /// Gets or sets the status code (HTTP status code)
22 | ///
23 | /// The status code.
24 | public int StatusCode { get; private set; }
25 |
26 | ///
27 | /// Gets or sets the HTTP headers
28 | ///
29 | /// HTTP headers
30 | public IDictionary Headers { get; private set; }
31 |
32 | ///
33 | /// Gets or sets the data (parsed HTTP body)
34 | ///
35 | /// The data.
36 | public T Data { get; private set; }
37 |
38 | ///
39 | /// Initializes a new instance of the class.
40 | ///
41 | /// HTTP status code.
42 | /// HTTP headers.
43 | /// Data (parsed HTTP body)
44 | public ApiResponse(int statusCode, IDictionary headers, T data)
45 | {
46 | this.StatusCode= statusCode;
47 | this.Headers = headers;
48 | this.Data = data;
49 | }
50 |
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/GzipUtil.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.IO.Compression;
3 | using System.Threading.Tasks;
4 |
5 | namespace Amazon.SellingPartner.IntegrationTests.Helpers
6 | {
7 | public static class GzipUtil
8 | {
9 | public static async Task CompressAsync(string fileToCompress)
10 | {
11 | await CompressAsync(new FileInfo(fileToCompress));
12 | }
13 |
14 | public static async Task CompressAsync(FileInfo fileToCompress)
15 | {
16 | await using FileStream originalFileStream = fileToCompress.OpenRead();
17 | if ((File.GetAttributes(fileToCompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fileToCompress.Extension != ".gz")
18 | {
19 | await using FileStream compressedFileStream = File.Create(fileToCompress.FullName + ".gz");
20 | await using GZipStream compressionStream = new GZipStream(compressedFileStream, CompressionMode.Compress);
21 | await originalFileStream.CopyToAsync(compressionStream);
22 | }
23 | }
24 |
25 | public static async Task DecompressAsync(string fileToDecompress)
26 | {
27 | await DecompressAsync(new FileInfo(fileToDecompress));
28 | }
29 |
30 | public static async Task DecompressAsync(FileInfo fileToDecompress)
31 | {
32 | await using FileStream originalFileStream = fileToDecompress.OpenRead();
33 | var currentFileName = fileToDecompress.FullName;
34 | var newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);
35 |
36 | await using FileStream decompressedFileStream = File.Create(newFileName);
37 | await using GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress);
38 | await decompressionStream.CopyToAsync(decompressedFileStream);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/LwaClientIntegrationTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Amazon.SellingPartner.Auth.Core;
4 | using Amazon.SellingPartner.Auth.HttpClient;
5 | using Amazon.SellingPartner.Auth.RestSharp;
6 | using Amazon.SellingPartner.IntegrationTests.Helpers;
7 | using FluentAssertions;
8 | using Xunit;
9 |
10 | namespace Amazon.SellingPartner.IntegrationTests
11 | {
12 | public class LwaClientIntegrationTests
13 | {
14 | [Fact]
15 | public async Task Should_get_access_token_using_restsharp()
16 | {
17 | LwaAuthorizationCredentials lwaAuthorizationCredentials = GetLwaAuthorizationCredentials();
18 | ILwaClient client = new RestSharpLwaClient(lwaAuthorizationCredentials);
19 |
20 | var response = await client.GetAccessTokenAsync();
21 |
22 | response.Should().NotBeNull();
23 | }
24 |
25 | [Fact]
26 | public async Task Should_get_access_token_using_httpclient()
27 | {
28 | LwaAuthorizationCredentials lwaAuthorizationCredentials = GetLwaAuthorizationCredentials();
29 | ILwaClient client = new HttpLwaClient(lwaAuthorizationCredentials);
30 |
31 | var response = await client.GetAccessTokenAsync();
32 |
33 | response.Should().NotBeNull();
34 | }
35 |
36 | private static LwaAuthorizationCredentials GetLwaAuthorizationCredentials()
37 | {
38 | var credentials = new SellingPartnerApiCredentialsFactory().CreateFromUserSecrets();
39 | var lwaAuthorizationCredentials = new LwaAuthorizationCredentials
40 | {
41 | ClientId = credentials.ClientId,
42 | ClientSecret = credentials.ClientSecret,
43 | Endpoint = new Uri(EndpointConstants.LwaToken),
44 | RefreshToken = credentials.RefreshToken,
45 | };
46 | return lwaAuthorizationCredentials;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.Auth.Tests/LwaAuthorizationSignerTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Amazon.SellingPartner.Auth.Core;
3 | using Amazon.SellingPartner.Auth.RestSharp;
4 | using Moq;
5 | using RestSharp;
6 | using Xunit;
7 |
8 | namespace Amazon.SellingPartner.Auth.Tests
9 | {
10 | public class LwaAuthorizationSignerTest
11 | {
12 | private static readonly LwaAuthorizationCredentials LwaAuthorizationCredentials = new LwaAuthorizationCredentials()
13 | {
14 | ClientId = "cid",
15 | ClientSecret = "csecret",
16 | Endpoint = new Uri("https://www.amazon.com")
17 | };
18 |
19 | private RestSharpLwaAuthorizationSigner lwaAuthorizationSignerUnderTest;
20 |
21 | public LwaAuthorizationSignerTest()
22 | {
23 | lwaAuthorizationSignerUnderTest = new RestSharpLwaAuthorizationSigner(LwaAuthorizationCredentials);
24 | }
25 |
26 | [Fact]
27 | public void ConstructorInitializesLWAClientWithCredentials()
28 | {
29 | Assert.Equal(LwaAuthorizationCredentials, lwaAuthorizationSignerUnderTest.RestSharpLwaClient.LWAAuthorizationCredentials);
30 | }
31 |
32 | [Fact]
33 | public void RequestIsSignedFromLWAClientProvidedToken()
34 | {
35 | string expectedAccessToken = "foo";
36 |
37 | var mockLWAClient = new Mock(LwaAuthorizationCredentials);
38 | mockLWAClient.Setup(lwaClient => lwaClient.GetAccessToken()).Returns(expectedAccessToken);
39 | lwaAuthorizationSignerUnderTest.RestSharpLwaClient = mockLWAClient.Object;
40 |
41 | IRestRequest restRequest = new RestRequest();
42 | restRequest = lwaAuthorizationSignerUnderTest.Sign(restRequest);
43 |
44 | Parameter actualAccessTokenHeader = restRequest.Parameters.Find(parameter =>
45 | ParameterType.HttpHeader.Equals(parameter.Type) && parameter.Name == RestSharpLwaAuthorizationSigner.AccessTokenHeaderName);
46 |
47 | Assert.Equal(expectedAccessToken, actualAccessTokenHeader.Value);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/LwaAccessTokenRequestMeta.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 |
4 | namespace Amazon.SellingPartner.Auth.Core
5 | {
6 | public class LwaAccessTokenRequestMeta : IEquatable
7 | {
8 | [JsonProperty(PropertyName = "grant_type")]
9 | public string GrantType { get; set; }
10 |
11 | [JsonProperty(PropertyName = "refresh_token")]
12 | public string RefreshToken { get; set; }
13 |
14 | [JsonProperty(PropertyName = "client_id")]
15 | public string ClientId { get; set; }
16 |
17 | [JsonProperty(PropertyName = "client_secret")]
18 | public string ClientSecret { get; set; }
19 |
20 | [JsonProperty(PropertyName = "scope")]
21 | public string Scope { get; set; }
22 |
23 | public bool Equals(LwaAccessTokenRequestMeta other)
24 | {
25 | if (ReferenceEquals(null, other)) return false;
26 | if (ReferenceEquals(this, other)) return true;
27 | return GrantType == other.GrantType && RefreshToken == other.RefreshToken && ClientId == other.ClientId && ClientSecret == other.ClientSecret && Scope == other.Scope;
28 | }
29 |
30 | public override bool Equals(object obj)
31 | {
32 | return obj is LwaAccessTokenRequestMeta other &&
33 | this.GrantType == other.GrantType &&
34 | this.RefreshToken == other.RefreshToken &&
35 | this.ClientId == other.ClientId &&
36 | this.ClientSecret == other.ClientSecret &&
37 | this.Scope == other.Scope;
38 | }
39 |
40 | public override int GetHashCode()
41 | {
42 | unchecked
43 | {
44 | var hashCode = (GrantType != null ? GrantType.GetHashCode() : 0);
45 | hashCode = (hashCode * 397) ^ (RefreshToken != null ? RefreshToken.GetHashCode() : 0);
46 | hashCode = (hashCode * 397) ^ (ClientId != null ? ClientId.GetHashCode() : 0);
47 | hashCode = (hashCode * 397) ^ (ClientSecret != null ? ClientSecret.GetHashCode() : 0);
48 | hashCode = (hashCode * 397) ^ (Scope != null ? Scope.GetHashCode() : 0);
49 | return hashCode;
50 | }
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Client/ApiException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 |
13 | namespace Amazon.SellingPartner.RestSharp.Orders.Client
14 | {
15 | ///
16 | /// API Exception
17 | ///
18 | public class ApiException : Exception
19 | {
20 | ///
21 | /// Gets or sets the error code (HTTP status code)
22 | ///
23 | /// The error code (HTTP status code).
24 | public int ErrorCode { get; set; }
25 |
26 | ///
27 | /// Gets or sets the error content (body json object)
28 | ///
29 | /// The error content (Http response body).
30 | public dynamic ErrorContent { get; private set; }
31 |
32 | ///
33 | /// Initializes a new instance of the class.
34 | ///
35 | public ApiException() {}
36 |
37 | ///
38 | /// Initializes a new instance of the class.
39 | ///
40 | /// HTTP status code.
41 | /// Error message.
42 | public ApiException(int errorCode, string message) : base(message)
43 | {
44 | this.ErrorCode = errorCode;
45 | }
46 |
47 | ///
48 | /// Initializes a new instance of the class.
49 | ///
50 | /// HTTP status code.
51 | /// Error message.
52 | /// Error content.
53 | public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message)
54 | {
55 | this.ErrorCode = errorCode;
56 | this.ErrorContent = errorContent;
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonSpOrdersTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Amazon.SellingPartner.Core;
4 | using Amazon.SellingPartner.IntegrationTests.Helpers;
5 | using Amazon.SellingPartner.Orders.Client;
6 | using FluentAssertions;
7 | using Xunit;
8 |
9 | namespace Amazon.SellingPartner.IntegrationTests
10 | {
11 | public class AmazonSpOrdersTests
12 | {
13 | private readonly IAmazonSellingPartnerOrdersClient _client;
14 |
15 | public AmazonSpOrdersTests()
16 | {
17 | _client = new DefaultSellingPartnerClientFactory().CreateOrdersClient();
18 | }
19 |
20 | [Fact]
21 | public async Task Should_get_order_by_id()
22 | {
23 | var orderId = "026-3243799-6137111";
24 |
25 | var response = await _client.GetOrderAsync(orderId);
26 |
27 | response.Should().NotBeNull();
28 | response.Payload.Should().NotBeNull();
29 | }
30 |
31 | [Fact]
32 | public async Task Should_get_order_items_by_id()
33 | {
34 | var orderId = "026-3243799-6137111";
35 |
36 | var response = await _client.GetOrderItemsAsync(orderId);
37 |
38 | response.Should().NotBeNull();
39 | response.Payload.Should().NotBeNull();
40 | }
41 |
42 | [Fact]
43 | public async Task Should_get_orders_by_date()
44 | {
45 | var startDate = new DateTime(2022, 03, 01, 0, 0, 0, DateTimeKind.Utc);
46 | var endDate = new DateTime(2022, 03, 07, 0, 0, 0, DateTimeKind.Utc);
47 | var marketplaceIds = new[] { AmazonMarketplace.UK.MarketplaceId };
48 |
49 | var response = await _client.GetOrdersAsync(marketplaceIds, createdAfter: startDate.ToAmazonDateTimeString(),
50 | createdBefore: endDate.ToAmazonDateTimeString());
51 |
52 | response.Should().NotBeNull();
53 | response.Payload.Should().NotBeNull();
54 |
55 | var nextToken = response.Payload.NextToken;
56 | while (!string.IsNullOrWhiteSpace(nextToken))
57 | {
58 | var nextResponse = await _client.GetOrdersAsync(marketplaceIds, nextToken: nextToken);
59 |
60 | nextResponse.Should().NotBeNull();
61 | nextResponse.Payload.Should().NotBeNull();
62 |
63 | nextToken = nextResponse.Payload.NextToken;
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/AmazonSpRestRequestUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Amazon.SecurityToken;
5 | using Amazon.SecurityToken.Model;
6 | using Amazon.SellingPartner.Auth.Core;
7 | using RestSharp;
8 |
9 | namespace Amazon.SellingPartner.Auth.RestSharp
10 | {
11 | public static class AmazonSpRestRequestUtil
12 | {
13 | public static LwaAuthorizationCredentials GetLwaAuthorizationCredentials(string clientId, string clientSecret, string refreshToken, string endpoint = "https://api.amazon.com/auth/o2/token")
14 | {
15 | var lwaAuthorizationCredentials = new LwaAuthorizationCredentials
16 | {
17 | ClientId = clientId,
18 | ClientSecret = clientSecret,
19 | Endpoint = new Uri(endpoint),
20 | RefreshToken = refreshToken,
21 | };
22 | return lwaAuthorizationCredentials;
23 | }
24 |
25 | public static IRestRequest AddSecurityTokenAndV4Sign(IRestRequest restRequest, string host, RegionEndpoint region, AssumeRoleResponse response)
26 | {
27 | restRequest.AddHeader("x-amz-security-token", response.Credentials.SessionToken);
28 |
29 | var awsAuthenticationCredentials = new AwsAuthenticationCredentials
30 | {
31 | AccessKeyId = response.Credentials.AccessKeyId,
32 | SecretKey = response.Credentials.SecretAccessKey,
33 | Region = region.SystemName
34 | };
35 | var signer = new RestSharpAwsSigV4Signer(awsAuthenticationCredentials);
36 |
37 | return signer.Sign(restRequest, host);
38 | }
39 |
40 | public static async Task AssumeRoleAsync(string roleArn, string accessKey, string secretKey, RegionEndpoint region, int durationSeconds = 3600)
41 | {
42 | AssumeRoleResponse response = null;
43 | using (var stsClient = new AmazonSecurityTokenServiceClient(accessKey, secretKey, region))
44 | {
45 | var req = new AssumeRoleRequest()
46 | {
47 | RoleArn = roleArn,
48 | DurationSeconds = durationSeconds,
49 | RoleSessionName = Guid.NewGuid().ToString()
50 | };
51 |
52 | response = await stsClient.AssumeRoleAsync(req, new CancellationToken());
53 | }
54 |
55 | return response;
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/AmazonSecurityTokenCredentialResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Amazon.SecurityToken;
5 | using Amazon.SecurityToken.Model;
6 |
7 | namespace Amazon.SellingPartner.Auth.Core
8 | {
9 | public class AmazonSecurityTokenCredentialResolver : IAmazonSecurityTokenCredentialResolver
10 | {
11 | private readonly string _accessKey;
12 | private readonly string _host;
13 |
14 | private readonly RegionEndpoint _region;
15 | private readonly string _roleArn;
16 | private readonly int _roleDurationSeconds;
17 | private readonly Func _roleSessionNameGenerator;
18 | private readonly string _secretKey;
19 |
20 | public AmazonSecurityTokenCredentialResolver(string host, string roleArn, string accessKey, string secretKey, RegionEndpoint region, int roleDurationSeconds = 3600,
21 | Func? roleSessionNameGenerator = null)
22 | {
23 | _host = new Uri(host).Host;
24 | _roleArn = roleArn;
25 | _accessKey = accessKey;
26 | _secretKey = secretKey;
27 | _region = region;
28 | _roleDurationSeconds = roleDurationSeconds;
29 | _roleSessionNameGenerator = roleSessionNameGenerator ?? (() => Guid.NewGuid().ToString());
30 | }
31 |
32 | public async Task GetCredentialsAsync(CancellationToken cancellationToken = default)
33 | {
34 | AssumeRoleResponse response = null;
35 | using (var stsClient = new AmazonSecurityTokenServiceClient(_accessKey, _secretKey, _region))
36 | {
37 | var req = new AssumeRoleRequest()
38 | {
39 | RoleArn = _roleArn,
40 | DurationSeconds = _roleDurationSeconds,
41 | RoleSessionName = _roleSessionNameGenerator.Invoke()
42 | };
43 |
44 | response = await stsClient.AssumeRoleAsync(req, cancellationToken);
45 | }
46 |
47 | return new AmazonSecurityTokenCredentials
48 | {
49 | SessionToken = response.Credentials.SessionToken,
50 | SecretAccessKey = response.Credentials.SecretAccessKey,
51 | AccessKeyId = response.Credentials.AccessKeyId,
52 | Expiration = response.Credentials.Expiration,
53 | Region = _region.SystemName,
54 | Host = _host
55 | };
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/HttpClient/AmazonSpAccessTokenHandlerFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using Amazon.SellingPartner.Auth.Core;
4 | using Amazon.SellingPartner.Auth.HttpClient;
5 | using Amazon.SellingPartner.Auth.HttpClient.Caching;
6 | using Microsoft.Extensions.Caching.Memory;
7 |
8 | namespace Amazon.SellingPartner.IntegrationTests.Helpers.HttpClient
9 | {
10 | public class AmazonSpAccessTokenHandlerFactory
11 | {
12 | public AmazonSpAccessTokenHandler Create(SellingPartnerApiCredentials credentials, string endpoint, RegionEndpoint region)
13 | {
14 | return InternalCreateV2(credentials, endpoint, region);
15 | }
16 |
17 | private AmazonSpAccessTokenHandler InternalCreateV1(SellingPartnerApiCredentials credentials, string endpoint, RegionEndpoint region)
18 | {
19 | AmazonSpAccessTokenHandler pipeline = new AmazonSpAccessTokenHandler(credentials.ClientId, credentials.ClientSecret, credentials.RefreshToken)
20 | {
21 | InnerHandler = new AmazonSpSecurityTokenHandler(new AmazonSecurityTokenCredentialResolver(endpoint, credentials.RoleARN, credentials.AWSKey, credentials.AWSSecret,
22 | region))
23 | {
24 | InnerHandler = new HttpClientHandler()
25 | }
26 | };
27 |
28 | return pipeline;
29 | }
30 |
31 | private AmazonSpAccessTokenHandler InternalCreateV2(SellingPartnerApiCredentials credentials, string endpoint, RegionEndpoint region)
32 | {
33 | var lwaAuthorizationCredentials = new LwaAuthorizationCredentials
34 | {
35 | ClientId = credentials.ClientId,
36 | ClientSecret = credentials.ClientSecret,
37 | Endpoint = new Uri("https://api.amazon.com/auth/o2/token"),
38 | RefreshToken = credentials.RefreshToken,
39 | };
40 |
41 | AmazonSpAccessTokenHandler pipeline = new AmazonSpAccessTokenHandler(new MemoryCacheHttpLwaClient(lwaAuthorizationCredentials, new MemoryCache(new MemoryCacheOptions())))
42 | {
43 | InnerHandler = new AmazonSpSecurityTokenHandler(new AmazonSecurityTokenCredentialResolver(endpoint, credentials.RoleARN, credentials.AWSKey, credentials.AWSSecret,
44 | region))
45 | {
46 | InnerHandler = new HttpClientHandler()
47 | }
48 | };
49 |
50 | return pipeline;
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/resources/swagger-codegen/templates/api_test.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | using System;
3 | using System.IO;
4 | using System.Collections.Generic;
5 | using System.Collections.ObjectModel;
6 | using System.Linq;
7 | using System.Reflection;
8 | using RestSharp;
9 | using NUnit.Framework;
10 |
11 | using {{packageName}}.Client;
12 | using {{packageName}}.{{apiPackage}};
13 | {{#hasImport}}using {{packageName}}.{{modelPackage}};
14 | {{/hasImport}}
15 |
16 | namespace {{packageName}}.Test
17 | {
18 | ///
19 | /// Class for testing {{classname}}
20 | ///
21 | ///
22 | /// This file is automatically generated by Swagger Codegen.
23 | /// Please update the test case below to test the API endpoint.
24 | ///
25 | [TestFixture]
26 | public class {{classname}}Tests
27 | {
28 | private {{classname}} instance;
29 |
30 | ///
31 | /// Setup before each unit test
32 | ///
33 | [SetUp]
34 | public void Init()
35 | {
36 | // TODO uncomment below to initialize instance for testing
37 | //instance = new {{classname}}();
38 | }
39 |
40 | ///
41 | /// Clean up after each unit test
42 | ///
43 | [TearDown]
44 | public void Cleanup()
45 | {
46 |
47 | }
48 |
49 | ///
50 | /// Test an instance of {{classname}}
51 | ///
52 | [Test]
53 | public void {{operationId}}InstanceTest()
54 | {
55 | // TODO uncomment below to test 'IsInstanceOfType' {{classname}}
56 | //Assert.IsInstanceOfType(typeof({{classname}}), instance, "instance is a {{classname}}");
57 | }
58 |
59 | {{#operations}}{{#operation}}
60 | ///
61 | /// Test {{operationId}}
62 | ///
63 | [Test]
64 | public void {{operationId}}Test()
65 | {
66 | // TODO uncomment below to test the method and replace null with proper value
67 | {{#allParams}}
68 | //{{{dataType}}} {{paramName}} = null;
69 | {{/allParams}}
70 | //{{#returnType}}var response = {{/returnType}}instance.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
71 | {{#returnType}}//Assert.IsInstanceOf<{{{returnType}}}> (response, "response is {{{returnType}}}");{{/returnType}}
72 | }
73 | {{/operation}}{{/operations}}
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonSpFinancesTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Amazon.SellingPartner.Finances.Client;
4 | using Amazon.SellingPartner.IntegrationTests.Helpers;
5 | using FluentAssertions;
6 | using Xunit;
7 |
8 | namespace Amazon.SellingPartner.IntegrationTests
9 | {
10 | public class AmazonSpFinancesTests
11 | {
12 | private readonly IAmazonSellingPartnerFinancesClient _client;
13 |
14 | public AmazonSpFinancesTests()
15 | {
16 | _client = new DefaultSellingPartnerClientFactory().CreateFinancesClient();
17 | }
18 |
19 | [Fact]
20 | public async Task Should_get_financial_events()
21 | {
22 | var startDate = new DateTime(2022, 03, 01);
23 | var endDate = new DateTime(2022, 03, 03);
24 |
25 | var response = await _client.ListFinancialEventsAsync(100, postedAfter: startDate, postedBefore: endDate);
26 |
27 | response.Should().NotBeNull();
28 | response.Payload.Should().NotBeNull();
29 |
30 | var nextToken = response.Payload.NextToken;
31 | while (!string.IsNullOrWhiteSpace(nextToken))
32 | {
33 | var nextResponse = await _client.ListFinancialEventsAsync(nextToken: nextToken);
34 |
35 | nextResponse.Should().NotBeNull();
36 | nextResponse.Payload.Should().NotBeNull();
37 |
38 | nextToken = nextResponse.Payload.NextToken;
39 | }
40 | }
41 |
42 | [Fact]
43 | public async Task Should_get_financial_event_groups()
44 | {
45 | var startDate = new DateTime(2022, 03, 01);
46 | var endDate = new DateTime(2022, 03, 03);
47 |
48 | var response = await _client.ListFinancialEventGroupsAsync(100, financialEventGroupStartedAfter: startDate, financialEventGroupStartedBefore: endDate);
49 |
50 | response.Should().NotBeNull();
51 | response.Payload.Should().NotBeNull();
52 |
53 | var nextToken = response.Payload.NextToken;
54 | while (!string.IsNullOrWhiteSpace(nextToken))
55 | {
56 | var nextResponse = await _client.ListFinancialEventGroupsAsync(nextToken: nextToken);
57 |
58 | nextResponse.Should().NotBeNull();
59 | nextResponse.Payload.Should().NotBeNull();
60 |
61 | nextToken = nextResponse.Payload.NextToken;
62 | }
63 | }
64 |
65 | [Fact]
66 | public async Task Should_get_financial_events_by_order_id()
67 | {
68 | var orderId = "026-3243799-6137111";
69 |
70 | var response = await _client.ListFinancialEventsByOrderIdAsync(orderId);
71 |
72 | response.Should().NotBeNull();
73 | response.Payload.Should().NotBeNull();
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.Core/Utils.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using System.Security.Cryptography;
3 | using System.Text;
4 |
5 | namespace Amazon.SellingPartner.Auth.Core
6 | {
7 | public static class Utils
8 | {
9 | public const string ValidUrlCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
10 |
11 | ///
12 | /// Returns URL encoded version of input data according to RFC-3986
13 | ///
14 | /// String to be URL-encoded
15 | /// URL encoded version of input data
16 | public static string UrlEncode(string data)
17 | {
18 | StringBuilder encoded = new StringBuilder();
19 | foreach (char symbol in Encoding.UTF8.GetBytes(data))
20 | {
21 | if (ValidUrlCharacters.IndexOf(symbol) != -1)
22 | {
23 | encoded.Append(symbol);
24 | }
25 | else
26 | {
27 | encoded.Append("%").Append(string.Format(CultureInfo.InvariantCulture, "{0:X2}", (int)symbol));
28 | }
29 | }
30 |
31 | return encoded.ToString();
32 | }
33 |
34 | ///
35 | /// Returns hashed value of input data using SHA256
36 | ///
37 | /// String to be hashed
38 | /// Hashed value of input data
39 | public static byte[] Hash(string data)
40 | {
41 | using var sha = new SHA256CryptoServiceProvider();
42 | return sha.ComputeHash(Encoding.UTF8.GetBytes(data));
43 | }
44 |
45 | ///
46 | /// Returns lowercase hexadecimal string of input byte array
47 | ///
48 | /// Data to be converted
49 | /// Lowercase hexadecimal string
50 | public static string ToHex(byte[] data)
51 | {
52 | StringBuilder sb = new StringBuilder();
53 |
54 | for (int i = 0; i < data.Length; i++)
55 | sb.Append(data[i].ToString("x2", CultureInfo.InvariantCulture));
56 |
57 | return sb.ToString();
58 | }
59 |
60 | ///
61 | /// Computes the hash of given string using the specified key with HMACSHA256
62 | ///
63 | /// Key
64 | /// String to be hashed
65 | /// Hashed value of input data
66 | public static byte[] GetKeyedHash(byte[] key, string value)
67 | {
68 | using KeyedHashAlgorithm hashAlgorithm = new HMACSHA256(key);
69 | hashAlgorithm.Initialize();
70 | return hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(value));
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.Auth.Tests/LwaAccessTokenRequestMetaBuilderTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Amazon.SellingPartner.Auth.Core;
4 | using Xunit;
5 |
6 | namespace Amazon.SellingPartner.Auth.Tests
7 | {
8 | public class LwaAccessTokenRequestMetaBuilderTest
9 | {
10 | private const string TestClientId = "cid";
11 | private const string TestClientSecret = "csecret";
12 | private const string TestRefreshToken = "rtoken";
13 | private static readonly Uri TestUri = new Uri("https://www.amazon.com");
14 | private LwaAccessTokenRequestMetaBuilder lwaAccessTokenRequestMetaBuilderUnderTest;
15 |
16 | public LwaAccessTokenRequestMetaBuilderTest()
17 | {
18 | lwaAccessTokenRequestMetaBuilderUnderTest = new LwaAccessTokenRequestMetaBuilder();
19 | }
20 |
21 | [Fact]
22 | public void LWAAuthorizationCredentialsWithoutScopesBuildsSellerTokenRequestMeta()
23 | {
24 | LwaAuthorizationCredentials lwaAuthorizationCredentials = new LwaAuthorizationCredentials()
25 | {
26 | ClientId = TestClientId,
27 | ClientSecret = TestClientSecret,
28 | Endpoint = TestUri,
29 | RefreshToken = TestRefreshToken
30 | };
31 |
32 | LwaAccessTokenRequestMeta expected = new LwaAccessTokenRequestMeta()
33 | {
34 | ClientId = TestClientId,
35 | ClientSecret = TestClientSecret,
36 | GrantType = LwaAccessTokenRequestMetaBuilder.SellerApiGrantType,
37 | RefreshToken = TestRefreshToken,
38 | Scope = null
39 | };
40 |
41 | LwaAccessTokenRequestMeta actual = lwaAccessTokenRequestMetaBuilderUnderTest.Build(lwaAuthorizationCredentials);
42 |
43 | Assert.Equal(expected, actual);
44 | }
45 |
46 | [Fact]
47 | public void LWAAuthorizationCredentialsWithScopesBuildsSellerlessTokenRequestMeta()
48 | {
49 | LwaAuthorizationCredentials lwaAuthorizationCredentials = new LwaAuthorizationCredentials()
50 | {
51 | ClientId = TestClientId,
52 | ClientSecret = TestClientSecret,
53 | Endpoint = TestUri,
54 | Scopes = new List() { ScopeConstants.ScopeMigrationApi, ScopeConstants.ScopeNotificationsApi }
55 | };
56 |
57 | LwaAccessTokenRequestMeta expected = new LwaAccessTokenRequestMeta()
58 | {
59 | ClientId = TestClientId,
60 | ClientSecret = TestClientSecret,
61 | GrantType = LwaAccessTokenRequestMetaBuilder.SellerlessApiGrantType,
62 | Scope = string.Format("{0} {1}", ScopeConstants.ScopeMigrationApi, ScopeConstants.ScopeNotificationsApi),
63 | RefreshToken = null
64 | };
65 |
66 | LwaAccessTokenRequestMeta actual = lwaAccessTokenRequestMetaBuilderUnderTest.Build(lwaAuthorizationCredentials);
67 |
68 | Assert.Equal(expected, actual);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.HttpClient/HttpLwaClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net.Http;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Amazon.SellingPartner.Auth.Core;
7 | using Newtonsoft.Json;
8 |
9 | namespace Amazon.SellingPartner.Auth.HttpClient
10 | {
11 | public class HttpLwaClient : ILwaClient
12 | {
13 | public const string AccessTokenKey = "access_token";
14 | public const string RefreshTokenKey = "refresh_token";
15 | public const string TokenTypeKey = "token_type";
16 | public const string ExpiresInKey = "expires_in";
17 |
18 | public const string JsonMediaType = "application/json; charset=utf-8";
19 |
20 | public HttpLwaClient(System.Net.Http.HttpClient httpClient, LwaAuthorizationCredentials lwaAuthorizationCredentials)
21 | {
22 | LWAAuthorizationCredentials = lwaAuthorizationCredentials;
23 | LWAAccessTokenRequestMetaBuilder = new LwaAccessTokenRequestMetaBuilder();
24 | HttpClient = httpClient;
25 | }
26 |
27 | public HttpLwaClient(LwaAuthorizationCredentials lwaAuthorizationCredentials) : this(
28 | new System.Net.Http.HttpClient() { BaseAddress = new Uri(lwaAuthorizationCredentials.Endpoint.GetLeftPart(UriPartial.Authority)) }, lwaAuthorizationCredentials)
29 | {
30 | }
31 |
32 | public System.Net.Http.HttpClient HttpClient { get; set; }
33 | public LwaAccessTokenRequestMetaBuilder LWAAccessTokenRequestMetaBuilder { get; set; }
34 | public LwaAuthorizationCredentials LWAAuthorizationCredentials { get; private set; }
35 |
36 | public virtual async Task GetTokenResponseAsync()
37 | {
38 | LwaAccessTokenRequestMeta lwaAccessTokenRequestMeta = LWAAccessTokenRequestMetaBuilder.Build(LWAAuthorizationCredentials);
39 |
40 | var jsonRequestBody = JsonConvert.SerializeObject(lwaAccessTokenRequestMeta);
41 |
42 | var request = new HttpRequestMessage(HttpMethod.Post, LWAAuthorizationCredentials.Endpoint.AbsolutePath);
43 | request.Content = new StringContent(jsonRequestBody, Encoding.UTF8, "application/json");
44 |
45 | LwaTokenResponse accessToken;
46 | try
47 | {
48 | HttpResponseMessage response = await HttpClient.SendAsync(request);
49 |
50 | if (!response.IsSuccessStatusCode)
51 | {
52 | throw new IOException("Unsuccessful LWA token exchange");
53 | }
54 |
55 | var content = await response.Content.ReadAsStringAsync();
56 |
57 | accessToken = JsonConvert.DeserializeObject(content);
58 | }
59 | catch (Exception e)
60 | {
61 | throw new SystemException("Error getting LWA Access Token", e);
62 | }
63 |
64 | return accessToken;
65 | }
66 |
67 | public virtual async Task GetAccessTokenAsync()
68 | {
69 | LwaTokenResponse token = await GetTokenResponseAsync();
70 | return token.AccessToken;
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Client/IReadableConfiguration.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System.Collections.Generic;
12 |
13 | namespace Amazon.SellingPartner.RestSharp.Orders.Client
14 | {
15 | ///
16 | /// Represents a readable-only configuration contract.
17 | ///
18 | public interface IReadableConfiguration
19 | {
20 | ///
21 | /// Gets the access token.
22 | ///
23 | /// Access token.
24 | string AccessToken { get; }
25 |
26 | ///
27 | /// Gets the API key.
28 | ///
29 | /// API key.
30 | IDictionary ApiKey { get; }
31 |
32 | ///
33 | /// Gets the API key prefix.
34 | ///
35 | /// API key prefix.
36 | IDictionary ApiKeyPrefix { get; }
37 |
38 | ///
39 | /// Gets the base path.
40 | ///
41 | /// Base path.
42 | string BasePath { get; }
43 |
44 | ///
45 | /// Gets the date time format.
46 | ///
47 | /// Date time foramt.
48 | string DateTimeFormat { get; }
49 |
50 | ///
51 | /// Gets the default header.
52 | ///
53 | /// Default header.
54 | IDictionary DefaultHeader { get; }
55 |
56 | ///
57 | /// Gets the temp folder path.
58 | ///
59 | /// Temp folder path.
60 | string TempFolderPath { get; }
61 |
62 | ///
63 | /// Gets the HTTP connection timeout (in milliseconds)
64 | ///
65 | /// HTTP connection timeout.
66 | int Timeout { get; }
67 |
68 | ///
69 | /// Gets the user agent.
70 | ///
71 | /// User agent.
72 | string UserAgent { get; }
73 |
74 | ///
75 | /// Gets the username.
76 | ///
77 | /// Username.
78 | string Username { get; }
79 |
80 | ///
81 | /// Gets the password.
82 | ///
83 | /// Password.
84 | string Password { get; }
85 |
86 | ///
87 | /// Gets the API key with prefix.
88 | ///
89 | /// API key identifier (authentication scheme).
90 | /// API key with prefix.
91 | string GetApiKeyWithPrefix(string apiKeyIdentifier);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonSpReportTests.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Net.Http;
4 | using System.Threading.Tasks;
5 | using Amazon.SellingPartner.Core;
6 | using Amazon.SellingPartner.IntegrationTests.Helpers;
7 | using Amazon.SellingPartner.Reports.Client;
8 | using FluentAssertions;
9 | using Xunit;
10 |
11 | namespace Amazon.SellingPartner.IntegrationTests
12 | {
13 | public class AmazonSpReportTests
14 | {
15 | private readonly IAmazonSellingPartnerReportsClient _client;
16 |
17 | public AmazonSpReportTests()
18 | {
19 | _client = new DefaultSellingPartnerClientFactory().CreateReportsClient();
20 | }
21 |
22 | [Fact]
23 | public async Task Should_get_seller_performance_report_end_to_end()
24 | {
25 | var reportType = "GET_V2_SELLER_PERFORMANCE_REPORT";
26 | var marketplaceIds = new List() { AmazonMarketplace.UK.MarketplaceId };
27 |
28 | await DownloadAndDecompressReportEndToEndAsync(marketplaceIds, reportType);
29 | }
30 |
31 | [Fact]
32 | public async Task Should_get_inventory_report_end_to_end()
33 | {
34 | var reportType = "GET_FLAT_FILE_OPEN_LISTINGS_DATA";
35 | var marketplaceIds = new List() { AmazonMarketplace.UK.MarketplaceId };
36 |
37 | await DownloadAndDecompressReportEndToEndAsync(marketplaceIds, reportType);
38 | }
39 |
40 | private async Task DownloadAndDecompressReportEndToEndAsync(ICollection marketplaceIds, string reportType)
41 | {
42 | var createResponse = await _client.CreateReportAsync(new CreateReportSpecification()
43 | {
44 | MarketplaceIds = marketplaceIds,
45 | ReportType = reportType,
46 | });
47 |
48 | var reportId = createResponse.ReportId;
49 |
50 | ReportProcessingStatus status;
51 | string reportDocumentId;
52 | do
53 | {
54 | await Task.Delay(15000);
55 | var getResponse = await _client.GetReportAsync(reportId);
56 | status = getResponse.ProcessingStatus;
57 | reportDocumentId = getResponse.ReportDocumentId;
58 | } while (status != ReportProcessingStatus.DONE);
59 |
60 | var documentResponse = await _client.GetReportDocumentAsync(reportDocumentId);
61 | var downloadUrl = documentResponse.Url;
62 |
63 | downloadUrl.Should().NotBeNull();
64 |
65 | var client = new HttpClient();
66 | var response = await client.GetAsync(downloadUrl);
67 | var filePath = Path.Combine(Path.GetTempPath(), reportType + (documentResponse.CompressionAlgorithm == ReportDocumentCompressionAlgorithm.GZIP ? ".gz" : ".report"));
68 |
69 | await using (var fs = new FileStream(filePath, FileMode.Create))
70 | await response.Content.CopyToAsync(fs);
71 |
72 | var bytes = await File.ReadAllBytesAsync(filePath);
73 | bytes.Should().NotBeNull();
74 | bytes.Should().NotBeEmpty();
75 |
76 | if (documentResponse.CompressionAlgorithm == ReportDocumentCompressionAlgorithm.GZIP)
77 | await GzipUtil.DecompressAsync(filePath);
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Core/AmazonMarketplace.cs:
--------------------------------------------------------------------------------
1 | namespace Amazon.SellingPartner.Core
2 | {
3 | ///
4 | /// https://developer-docs.amazon.com/sp-api/docs/marketplace-ids
5 | ///
6 | public sealed class AmazonMarketplace
7 | {
8 | // North America
9 | public static readonly AmazonMarketplace Canada = new AmazonMarketplace("North America", "Canada", "CA", "A2EUQ1WTGCTBG2");
10 | public static readonly AmazonMarketplace USA = new AmazonMarketplace("North America", "United States of America", "US", "ATVPDKIKX0DER");
11 | public static readonly AmazonMarketplace Mexico = new AmazonMarketplace("North America", "Mexico", "MX", "A1AM78C64UM0Y8");
12 | public static readonly AmazonMarketplace Brazil = new AmazonMarketplace("North America", "Brazil", "BR", "A2Q3Y263D00KWC");
13 |
14 | // Europe
15 | public static readonly AmazonMarketplace Spain = new AmazonMarketplace("Europe", "Spain", "ES", "A1RKKUPIHCS9HS");
16 | public static readonly AmazonMarketplace UK = new AmazonMarketplace("Europe", "United Kingdom", "UK", "A1F83G8C2ARO7P");
17 | public static readonly AmazonMarketplace France = new AmazonMarketplace("Europe", "France", "FR", "A13V1IB3VIYZZH");
18 | public static readonly AmazonMarketplace Netherlands = new AmazonMarketplace("Europe", "Netherlands", "NL", "A1805IZSGTT6HS");
19 | public static readonly AmazonMarketplace Germany = new AmazonMarketplace("Europe", "Germany", "DE", "A1PA6795UKMFR9");
20 | public static readonly AmazonMarketplace Italy = new AmazonMarketplace("Europe", "Italy", "IT", "APJ6JRA9NG5V4");
21 | public static readonly AmazonMarketplace Sweden = new AmazonMarketplace("Europe", "Sweden", "SE", "A2NODRKZP88ZB9");
22 | public static readonly AmazonMarketplace Poland = new AmazonMarketplace("Europe", "Poland", "PL", "A1C3SOZRARQ6R3");
23 | public static readonly AmazonMarketplace Egypt = new AmazonMarketplace("Europe", "Egypt", "EG", "ARBP9OOSHTCHU");
24 | public static readonly AmazonMarketplace Turkey = new AmazonMarketplace("Europe", "Turkey", "TR", "A33AVAJ2PDY3EV");
25 | public static readonly AmazonMarketplace SaudiArabia = new AmazonMarketplace("Europe", "Saudi Arabia", "SA", "A17E79C6D8DWNP");
26 | public static readonly AmazonMarketplace UAE = new AmazonMarketplace("Europe", "United Arab Emirates", "AE", "A2VIGQ35RCS4UG");
27 | public static readonly AmazonMarketplace India = new AmazonMarketplace("Europe", "India", "IN", "A21TJRUUN4KGV");
28 |
29 | // Far East
30 | public static readonly AmazonMarketplace Singapore = new AmazonMarketplace("Far East", "Singapore", "SG", "A19VAU5U5O7RUS");
31 | public static readonly AmazonMarketplace Australia = new AmazonMarketplace("Far East", "Australia", "AU", "A39IBJ37TRP1C6");
32 | public static readonly AmazonMarketplace Japan = new AmazonMarketplace("Far East", "Japan", "JP", "A1VC38T7YXB528");
33 |
34 | private AmazonMarketplace(string region, string country, string countryCode, string marketplaceId)
35 | {
36 | Region = region;
37 | Country = country;
38 | CountryCode = countryCode;
39 | MarketplaceId = marketplaceId;
40 | }
41 |
42 | public string Region { get; }
43 | public string Country { get; }
44 | public string CountryCode { get; }
45 | public string MarketplaceId { get; }
46 | }
47 | }
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/AmazonSpFeedsTests.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Net.Http;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Amazon.SellingPartner.Core;
7 | using Amazon.SellingPartner.Feed.Client;
8 | using Amazon.SellingPartner.IntegrationTests.Helpers;
9 | using FluentAssertions;
10 | using Xunit;
11 |
12 | namespace Amazon.SellingPartner.IntegrationTests
13 | {
14 | public class AmazonSpFeedsTests
15 | {
16 | private readonly IAmazonSellingPartnerFeedClient _client;
17 |
18 | public AmazonSpFeedsTests()
19 | {
20 | _client = new DefaultSellingPartnerClientFactory().CreateFeedClient();
21 | }
22 |
23 | [RunnableInDebugOnly]
24 | public async Task Should_upload_inventory_loader_feed_end_to_end()
25 | {
26 | var marketplaceIds = new List() { AmazonMarketplace.UK.MarketplaceId };
27 | var feedType = "POST_FLAT_FILE_INVLOADER_DATA";
28 | var contentType = "text/tab-separated-values; charset=utf-8"; // "text/xml; charset=UTF-8"
29 |
30 | var feedData = @"sku merchant-shipping-group-name
31 | 5249 uk|courier|std|0";
32 |
33 | var createFeedDocumentResponse = await _client.CreateFeedDocumentAsync(new CreateFeedDocumentSpecification()
34 | {
35 | ContentType = contentType
36 | });
37 |
38 |
39 | var httpClient = new HttpClient();
40 |
41 | var request = new HttpRequestMessage(HttpMethod.Put, createFeedDocumentResponse.Url);
42 | request.Content = new StringContent(feedData, Encoding.UTF8, "text/tab-separated-values");
43 |
44 | var uploadFeedResponse = await httpClient.SendAsync(request);
45 | uploadFeedResponse.EnsureSuccessStatusCode();
46 |
47 | var createFeedResponse = await _client.CreateFeedAsync(new CreateFeedSpecification()
48 | {
49 | InputFeedDocumentId = createFeedDocumentResponse.FeedDocumentId,
50 | FeedType = feedType,
51 | MarketplaceIds = marketplaceIds,
52 | });
53 |
54 | FeedProcessingStatus status;
55 | string feedDocumentId;
56 | do
57 | {
58 | await Task.Delay(15000);
59 | var feedResponse = await _client.GetFeedAsync(createFeedResponse.FeedId);
60 | status = feedResponse.ProcessingStatus;
61 | feedDocumentId = feedResponse.ResultFeedDocumentId;
62 | } while (status != FeedProcessingStatus.DONE);
63 |
64 | var feedDocumentResponse = await _client.GetFeedDocumentAsync(feedDocumentId);
65 |
66 | var response = await httpClient.GetAsync(feedDocumentResponse.Url);
67 | var filePath = Path.Combine(Path.GetTempPath(), feedType + (feedDocumentResponse.CompressionAlgorithm == FeedDocumentCompressionAlgorithm.GZIP ? ".gz" : ".data"));
68 |
69 | await using (var fs = new FileStream(filePath, FileMode.Create))
70 | await response.Content.CopyToAsync(fs);
71 |
72 | var bytes = await File.ReadAllBytesAsync(filePath);
73 | bytes.Should().NotBeNull();
74 | bytes.Should().NotBeEmpty();
75 |
76 | if (feedDocumentResponse.CompressionAlgorithm == FeedDocumentCompressionAlgorithm.GZIP)
77 | await GzipUtil.DecompressAsync(filePath);
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/RestSharpAwsSigV4Signer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using Amazon.SellingPartner.Auth.Core;
4 | using RestSharp;
5 |
6 | namespace Amazon.SellingPartner.Auth.RestSharp
7 | {
8 | public class RestSharpAwsSigV4Signer
9 | {
10 | private AwsAuthenticationCredentials awsCredentials;
11 |
12 | ///
13 | /// Constructor for RestSharpAwsSigV4Signer
14 | ///
15 | /// AWS Developer Account Credentials
16 | public RestSharpAwsSigV4Signer(AwsAuthenticationCredentials awsAuthenticationCredentials)
17 | {
18 | awsCredentials = awsAuthenticationCredentials;
19 | RestSharpAwsSignerHelper = new RestSharpAwsSignerHelper();
20 | }
21 |
22 | public virtual RestSharpAwsSignerHelper RestSharpAwsSignerHelper { get; set; }
23 |
24 | ///
25 | /// Signs a Request with AWS Signature Version 4
26 | ///
27 | /// RestRequest which needs to be signed
28 | /// Request endpoint
29 | /// RestRequest with AWS Signature
30 | public IRestRequest Sign(IRestRequest request, string host)
31 | {
32 | DateTime signingDate = RestSharpAwsSignerHelper.InitializeHeaders(request, host);
33 | string signedHeaders = RestSharpAwsSignerHelper.ExtractSignedHeaders(request);
34 |
35 | string hashedCanonicalRequest = CreateCanonicalRequest(request, signedHeaders);
36 |
37 | string stringToSign = RestSharpAwsSignerHelper.BuildStringToSign(signingDate,
38 | hashedCanonicalRequest,
39 | awsCredentials.Region);
40 |
41 | string signature = RestSharpAwsSignerHelper.CalculateSignature(stringToSign,
42 | signingDate,
43 | awsCredentials.SecretKey,
44 | awsCredentials.Region);
45 |
46 | RestSharpAwsSignerHelper.AddSignature(request,
47 | awsCredentials.AccessKeyId,
48 | signedHeaders,
49 | signature,
50 | awsCredentials.Region,
51 | signingDate);
52 |
53 | return request;
54 | }
55 |
56 | private string CreateCanonicalRequest(IRestRequest restRequest, string signedHeaders)
57 | {
58 | var canonicalizedRequest = new StringBuilder();
59 | //Request Method
60 | canonicalizedRequest.AppendFormat("{0}\n", restRequest.Method);
61 |
62 | //CanonicalURI
63 | canonicalizedRequest.AppendFormat("{0}\n", RestSharpAwsSignerHelper.ExtractCanonicalURIParameters(restRequest.Resource));
64 |
65 | //CanonicalQueryString
66 | canonicalizedRequest.AppendFormat("{0}\n", RestSharpAwsSignerHelper.ExtractCanonicalQueryString(restRequest));
67 |
68 | //CanonicalHeaders
69 | canonicalizedRequest.AppendFormat("{0}\n", RestSharpAwsSignerHelper.ExtractCanonicalHeaders(restRequest));
70 |
71 | //SignedHeaders
72 | canonicalizedRequest.AppendFormat("{0}\n", signedHeaders);
73 |
74 | // Hash(digest) the payload in the body
75 | canonicalizedRequest.AppendFormat(RestSharpAwsSignerHelper.HashRequestBody(restRequest));
76 |
77 | string canonicalRequest = canonicalizedRequest.ToString();
78 |
79 | //Create a digest(hash) of the canonical request
80 | return Utils.ToHex(Utils.Hash(canonicalRequest));
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/resources/swagger-codegen/templates/IReadableConfiguration.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | using System.Collections.Generic;
4 | using Amazon.SellingPartnerAPIAA;
5 |
6 | namespace {{packageName}}.Client
7 | {
8 | ///
9 | /// Represents a readable-only configuration contract.
10 | ///
11 | public interface IReadableConfiguration
12 | {
13 | ///
14 | /// Gets the access token.
15 | ///
16 | /// Access token.
17 | string AccessToken { get; }
18 |
19 | ///
20 | /// Gets the API key.
21 | ///
22 | /// API key.
23 | IDictionary ApiKey { get; }
24 |
25 | ///
26 | /// Gets the API key prefix.
27 | ///
28 | /// API key prefix.
29 | IDictionary ApiKeyPrefix { get; }
30 |
31 | ///
32 | /// Gets the base path.
33 | ///
34 | /// Base path.
35 | string BasePath { get; }
36 |
37 | ///
38 | /// Gets the date time format.
39 | ///
40 | /// Date time foramt.
41 | string DateTimeFormat { get; }
42 |
43 | ///
44 | /// Gets the default header.
45 | ///
46 | /// Default header.
47 | IDictionary DefaultHeader { get; }
48 |
49 | ///
50 | /// Gets the temp folder path.
51 | ///
52 | /// Temp folder path.
53 | string TempFolderPath { get; }
54 |
55 | ///
56 | /// Gets the HTTP connection timeout (in milliseconds)
57 | ///
58 | /// HTTP connection timeout.
59 | int Timeout { get; }
60 |
61 | ///
62 | /// Gets the user agent.
63 | ///
64 | /// User agent.
65 | string UserAgent { get; }
66 |
67 | ///
68 | /// Gets the username.
69 | ///
70 | /// Username.
71 | string Username { get; }
72 |
73 | ///
74 | /// Gets the password.
75 | ///
76 | /// Password.
77 | string Password { get; }
78 |
79 | ///
80 | /// Gets the API key with prefix.
81 | ///
82 | /// API key identifier (authentication scheme).
83 | /// API key with prefix.
84 | string GetApiKeyWithPrefix(string apiKeyIdentifier);
85 |
86 | ///
87 | /// Gets the LWAAuthorizationCredentials for Amazon Selling Partner API Authorization
88 | ///
89 | /// AuthorizationCredentials
90 | LWAAuthorizationCredentials AuthorizationCredentials { get; }
91 |
92 | ///
93 | /// Gets the AWSAuthenticationCredentials for Amazon Selling Partner API Authentication
94 | ///
95 | /// AuthenticationCredentials
96 | AWSAuthenticationCredentials AuthenticationCredentials { get; }
97 |
98 | ///
99 | /// Gets the RateLimitConfigurationOnRequests for Amazon Selling Partner API RateLimit
100 | ///
101 | /// RateLimitConfiguration
102 | RateLimitConfiguration RateLimitConfig { get; }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.HttpClient/HttpRequestMessageAWSSigV4Signer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using System.Text;
4 | using Amazon.SellingPartner.Auth.Core;
5 |
6 | namespace Amazon.SellingPartner.Auth.HttpClient
7 | {
8 | public class HttpRequestMessageAWSSigV4Signer
9 | {
10 | private AwsAuthenticationCredentials awsCredentials;
11 |
12 | ///
13 | /// Constructor for AWSSigV4Signer
14 | ///
15 | /// AWS Developer Account Credentials
16 | public HttpRequestMessageAWSSigV4Signer(AwsAuthenticationCredentials awsAuthenticationCredentials)
17 | {
18 | awsCredentials = awsAuthenticationCredentials;
19 | HttpRequestMessageAwsSignerHelper = new HttpRequestMessageAWSSignerHelper();
20 | }
21 |
22 | public virtual HttpRequestMessageAWSSignerHelper HttpRequestMessageAwsSignerHelper { get; set; }
23 |
24 | ///
25 | /// Signs a Request with AWS Signature Version 4
26 | ///
27 | /// RestRequest which needs to be signed
28 | /// Request endpoint
29 | /// RestRequest with AWS Signature
30 | public HttpRequestMessage Sign(HttpRequestMessage request, string host)
31 | {
32 | DateTime signingDate = HttpRequestMessageAwsSignerHelper.InitializeHeaders(request, host);
33 | string signedHeaders = HttpRequestMessageAwsSignerHelper.ExtractSignedHeaders(request);
34 |
35 | string hashedCanonicalRequest = CreateCanonicalRequest(request, signedHeaders);
36 |
37 | string stringToSign = HttpRequestMessageAwsSignerHelper.BuildStringToSign(signingDate,
38 | hashedCanonicalRequest,
39 | awsCredentials.Region);
40 |
41 | string signature = HttpRequestMessageAwsSignerHelper.CalculateSignature(stringToSign,
42 | signingDate,
43 | awsCredentials.SecretKey,
44 | awsCredentials.Region);
45 |
46 | HttpRequestMessageAwsSignerHelper.AddSignature(request,
47 | awsCredentials.AccessKeyId,
48 | signedHeaders,
49 | signature,
50 | awsCredentials.Region,
51 | signingDate);
52 |
53 | return request;
54 | }
55 |
56 | private string CreateCanonicalRequest(HttpRequestMessage request, string signedHeaders)
57 | {
58 | var canonicalizedRequest = new StringBuilder();
59 | //Request Method
60 | canonicalizedRequest.AppendFormat("{0}\n", request.Method);
61 |
62 | //CanonicalURI
63 | canonicalizedRequest.AppendFormat("{0}\n", HttpRequestMessageAwsSignerHelper.ExtractCanonicalURIParameters(request.RequestUri.AbsolutePath));
64 |
65 | //CanonicalQueryString
66 | canonicalizedRequest.AppendFormat("{0}\n", HttpRequestMessageAwsSignerHelper.ExtractCanonicalQueryString(request));
67 |
68 | //CanonicalHeaders
69 | canonicalizedRequest.AppendFormat("{0}\n", HttpRequestMessageAwsSignerHelper.ExtractCanonicalHeaders(request));
70 |
71 | //SignedHeaders
72 | canonicalizedRequest.AppendFormat("{0}\n", signedHeaders);
73 |
74 | // Hash(digest) the payload in the body
75 | canonicalizedRequest.AppendFormat(HttpRequestMessageAwsSignerHelper.HashRequestBody(request));
76 |
77 | string canonicalRequest = canonicalizedRequest.ToString();
78 |
79 | //Create a digest(hash) of the canonical request
80 | return Utils.ToHex(Utils.Hash(canonicalRequest));
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Model/OrderList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel.DataAnnotations;
14 | using System.Runtime.Serialization;
15 | using System.Text;
16 | using Newtonsoft.Json;
17 |
18 | namespace Amazon.SellingPartner.RestSharp.Orders.Model
19 | {
20 | ///
21 | /// A list of orders.
22 | ///
23 | [DataContract]
24 | public partial class OrderList : List, IEquatable, IValidatableObject
25 | {
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public OrderList() : base()
30 | {
31 | }
32 |
33 | ///
34 | /// Returns the string presentation of the object
35 | ///
36 | /// String presentation of the object
37 | public override string ToString()
38 | {
39 | var sb = new StringBuilder();
40 | sb.Append("class OrderList {\n");
41 | sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
42 | sb.Append("}\n");
43 | return sb.ToString();
44 | }
45 |
46 | ///
47 | /// Returns the JSON string presentation of the object
48 | ///
49 | /// JSON string presentation of the object
50 | public string ToJson()
51 | {
52 | return JsonConvert.SerializeObject(this, Formatting.Indented);
53 | }
54 |
55 | ///
56 | /// Returns true if objects are equal
57 | ///
58 | /// Object to be compared
59 | /// Boolean
60 | public override bool Equals(object input)
61 | {
62 | return this.Equals(input as OrderList);
63 | }
64 |
65 | ///
66 | /// Returns true if OrderList instances are equal
67 | ///
68 | /// Instance of OrderList to be compared
69 | /// Boolean
70 | public bool Equals(OrderList input)
71 | {
72 | if (input == null)
73 | return false;
74 |
75 | return base.Equals(input);
76 | }
77 |
78 | ///
79 | /// Gets the hash code
80 | ///
81 | /// Hash code
82 | public override int GetHashCode()
83 | {
84 | unchecked // Overflow is fine, just wrap
85 | {
86 | int hashCode = base.GetHashCode();
87 | return hashCode;
88 | }
89 | }
90 |
91 | ///
92 | /// To validate all properties of the instance
93 | ///
94 | /// Validation context
95 | /// Validation Result
96 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
97 | {
98 | yield break;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Model/ErrorList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel.DataAnnotations;
14 | using System.Runtime.Serialization;
15 | using System.Text;
16 | using Newtonsoft.Json;
17 |
18 | namespace Amazon.SellingPartner.RestSharp.Orders.Model
19 | {
20 | ///
21 | /// A list of error responses returned when a request is unsuccessful.
22 | ///
23 | [DataContract]
24 | public partial class ErrorList : List, IEquatable, IValidatableObject
25 | {
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public ErrorList() : base()
30 | {
31 | }
32 |
33 | ///
34 | /// Returns the string presentation of the object
35 | ///
36 | /// String presentation of the object
37 | public override string ToString()
38 | {
39 | var sb = new StringBuilder();
40 | sb.Append("class ErrorList {\n");
41 | sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
42 | sb.Append("}\n");
43 | return sb.ToString();
44 | }
45 |
46 | ///
47 | /// Returns the JSON string presentation of the object
48 | ///
49 | /// JSON string presentation of the object
50 | public string ToJson()
51 | {
52 | return JsonConvert.SerializeObject(this, Formatting.Indented);
53 | }
54 |
55 | ///
56 | /// Returns true if objects are equal
57 | ///
58 | /// Object to be compared
59 | /// Boolean
60 | public override bool Equals(object input)
61 | {
62 | return this.Equals(input as ErrorList);
63 | }
64 |
65 | ///
66 | /// Returns true if ErrorList instances are equal
67 | ///
68 | /// Instance of ErrorList to be compared
69 | /// Boolean
70 | public bool Equals(ErrorList input)
71 | {
72 | if (input == null)
73 | return false;
74 |
75 | return base.Equals(input);
76 | }
77 |
78 | ///
79 | /// Gets the hash code
80 | ///
81 | /// Hash code
82 | public override int GetHashCode()
83 | {
84 | unchecked // Overflow is fine, just wrap
85 | {
86 | int hashCode = base.GetHashCode();
87 | return hashCode;
88 | }
89 | }
90 |
91 | ///
92 | /// To validate all properties of the instance
93 | ///
94 | /// Validation context
95 | /// Validation Result
96 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
97 | {
98 | yield break;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Model/OrderItemList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel.DataAnnotations;
14 | using System.Runtime.Serialization;
15 | using System.Text;
16 | using Newtonsoft.Json;
17 |
18 | namespace Amazon.SellingPartner.RestSharp.Orders.Model
19 | {
20 | ///
21 | /// A list of order items.
22 | ///
23 | [DataContract]
24 | public partial class OrderItemList : List, IEquatable, IValidatableObject
25 | {
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public OrderItemList() : base()
30 | {
31 | }
32 |
33 | ///
34 | /// Returns the string presentation of the object
35 | ///
36 | /// String presentation of the object
37 | public override string ToString()
38 | {
39 | var sb = new StringBuilder();
40 | sb.Append("class OrderItemList {\n");
41 | sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
42 | sb.Append("}\n");
43 | return sb.ToString();
44 | }
45 |
46 | ///
47 | /// Returns the JSON string presentation of the object
48 | ///
49 | /// JSON string presentation of the object
50 | public string ToJson()
51 | {
52 | return JsonConvert.SerializeObject(this, Formatting.Indented);
53 | }
54 |
55 | ///
56 | /// Returns true if objects are equal
57 | ///
58 | /// Object to be compared
59 | /// Boolean
60 | public override bool Equals(object input)
61 | {
62 | return this.Equals(input as OrderItemList);
63 | }
64 |
65 | ///
66 | /// Returns true if OrderItemList instances are equal
67 | ///
68 | /// Instance of OrderItemList to be compared
69 | /// Boolean
70 | public bool Equals(OrderItemList input)
71 | {
72 | if (input == null)
73 | return false;
74 |
75 | return base.Equals(input);
76 | }
77 |
78 | ///
79 | /// Gets the hash code
80 | ///
81 | /// Hash code
82 | public override int GetHashCode()
83 | {
84 | unchecked // Overflow is fine, just wrap
85 | {
86 | int hashCode = base.GetHashCode();
87 | return hashCode;
88 | }
89 | }
90 |
91 | ///
92 | /// To validate all properties of the instance
93 | ///
94 | /// Validation context
95 | /// Validation Result
96 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
97 | {
98 | yield break;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Model/PromotionIdList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel.DataAnnotations;
14 | using System.Runtime.Serialization;
15 | using System.Text;
16 | using Newtonsoft.Json;
17 |
18 | namespace Amazon.SellingPartner.RestSharp.Orders.Model
19 | {
20 | ///
21 | /// A list of promotion identifiers provided by the seller when the promotions were created.
22 | ///
23 | [DataContract]
24 | public partial class PromotionIdList : List, IEquatable, IValidatableObject
25 | {
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public PromotionIdList() : base()
30 | {
31 | }
32 |
33 | ///
34 | /// Returns the string presentation of the object
35 | ///
36 | /// String presentation of the object
37 | public override string ToString()
38 | {
39 | var sb = new StringBuilder();
40 | sb.Append("class PromotionIdList {\n");
41 | sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
42 | sb.Append("}\n");
43 | return sb.ToString();
44 | }
45 |
46 | ///
47 | /// Returns the JSON string presentation of the object
48 | ///
49 | /// JSON string presentation of the object
50 | public string ToJson()
51 | {
52 | return JsonConvert.SerializeObject(this, Formatting.Indented);
53 | }
54 |
55 | ///
56 | /// Returns true if objects are equal
57 | ///
58 | /// Object to be compared
59 | /// Boolean
60 | public override bool Equals(object input)
61 | {
62 | return this.Equals(input as PromotionIdList);
63 | }
64 |
65 | ///
66 | /// Returns true if PromotionIdList instances are equal
67 | ///
68 | /// Instance of PromotionIdList to be compared
69 | /// Boolean
70 | public bool Equals(PromotionIdList input)
71 | {
72 | if (input == null)
73 | return false;
74 |
75 | return base.Equals(input);
76 | }
77 |
78 | ///
79 | /// Gets the hash code
80 | ///
81 | /// Hash code
82 | public override int GetHashCode()
83 | {
84 | unchecked // Overflow is fine, just wrap
85 | {
86 | int hashCode = base.GetHashCode();
87 | return hashCode;
88 | }
89 | }
90 |
91 | ///
92 | /// To validate all properties of the instance
93 | ///
94 | /// Validation context
95 | /// Validation Result
96 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
97 | {
98 | yield break;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/tests/Amazon.SellingPartner.IntegrationTests/Helpers/SafeSellingPartnerClientFactory.cs:
--------------------------------------------------------------------------------
1 | using Amazon.SellingPartner.Feed.Client;
2 | using Amazon.SellingPartner.Finances.Client;
3 | using Amazon.SellingPartner.FulfillmentInbound.Client;
4 | using Amazon.SellingPartner.IntegrationTests.Helpers.HttpClient;
5 | using Amazon.SellingPartner.Orders.Client;
6 | using Amazon.SellingPartner.ProductFees.Client;
7 | using Amazon.SellingPartner.Reports.Client;
8 | using Amazon.SellingPartner.Sales.Client;
9 | using Amazon.SellingPartner.Serialization.NewtonsoftJson;
10 |
11 | namespace Amazon.SellingPartner.IntegrationTests.Helpers
12 | {
13 | public class SafeSellingPartnerClientFactory : SellingPartnerClientFactory
14 | {
15 | private readonly TestAmazonSpHttpClientFactory _httpClientFactory;
16 |
17 | public SafeSellingPartnerClientFactory()
18 | {
19 | _httpClientFactory = new TestAmazonSpHttpClientFactory();
20 | }
21 |
22 | public override IAmazonSellingPartnerFinancesClient CreateFinancesClient()
23 | {
24 | return new AmazonSellingPartnerFinancesClient(_httpClientFactory.Create())
25 | {
26 | JsonSerializerSettings =
27 | {
28 | ContractResolver = new AmazonSellingPartnerSafeContractResolver()
29 | }
30 | };
31 | }
32 |
33 | public override IAmazonSellingPartnerFulfillmentInboundClient CreateFulfillmentInboundClient()
34 | {
35 | return new AmazonSellingPartnerFulfillmentInboundClient(_httpClientFactory.Create())
36 | {
37 | JsonSerializerSettings =
38 | {
39 | ContractResolver = new AmazonSellingPartnerSafeContractResolver()
40 | }
41 | };
42 | }
43 |
44 | public override IAmazonSellingPartnerOrdersClient CreateOrdersClient()
45 | {
46 | return new AmazonSellingPartnerOrdersClient(_httpClientFactory.Create())
47 | {
48 | JsonSerializerSettings =
49 | {
50 | ContractResolver = new AmazonSellingPartnerSafeContractResolver()
51 | }
52 | };
53 | }
54 |
55 | public override IAmazonSellingPartnerProductFeesClient CreateProductFeesClient()
56 | {
57 | return new AmazonSellingPartnerProductFeesClient(_httpClientFactory.Create())
58 | {
59 | JsonSerializerSettings =
60 | {
61 | ContractResolver = new AmazonSellingPartnerSafeContractResolver()
62 | }
63 | };
64 | }
65 |
66 | public override IAmazonSellingPartnerReportsClient CreateReportsClient()
67 | {
68 | return new AmazonSellingPartnerReportsClient(_httpClientFactory.Create())
69 | {
70 | JsonSerializerSettings =
71 | {
72 | ContractResolver = new AmazonSellingPartnerSafeContractResolver()
73 | }
74 | };
75 | }
76 |
77 | public override IAmazonSellingPartnerSalesClient CreateSalesClient()
78 | {
79 | return new AmazonSellingPartnerSalesClient(_httpClientFactory.Create())
80 | {
81 | JsonSerializerSettings =
82 | {
83 | ContractResolver = new AmazonSellingPartnerSafeContractResolver()
84 | }
85 | };
86 | }
87 |
88 | public override IAmazonSellingPartnerFeedClient CreateFeedClient()
89 | {
90 | return new AmazonSellingPartnerFeedClient(_httpClientFactory.Create())
91 | {
92 | JsonSerializerSettings =
93 | {
94 | ContractResolver = new AmazonSellingPartnerSafeContractResolver()
95 | }
96 | };
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/src/Amazon.SellingPartner.Auth.RestSharp/RestSharpLwaClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 | using Amazon.SellingPartner.Auth.Core;
5 | using Newtonsoft.Json;
6 | using Newtonsoft.Json.Linq;
7 | using RestSharp;
8 |
9 | namespace Amazon.SellingPartner.Auth.RestSharp
10 | {
11 | public class RestSharpLwaClient : ILwaClient
12 | {
13 | public const string AccessTokenKey = "access_token";
14 | public const string RefreshTokenKey = "refresh_token";
15 | public const string TokenTypeKey = "token_type";
16 | public const string ExpiresInKey = "expires_in";
17 |
18 | public const string JsonMediaType = "application/json; charset=utf-8";
19 |
20 |
21 | public RestSharpLwaClient(LwaAuthorizationCredentials lwaAuthorizationCredentials)
22 | {
23 | LWAAuthorizationCredentials = lwaAuthorizationCredentials;
24 | LWAAccessTokenRequestMetaBuilder = new LwaAccessTokenRequestMetaBuilder();
25 | var baseUrl = LWAAuthorizationCredentials.Endpoint.GetLeftPart(UriPartial.Authority);
26 | RestClient = new RestClient(baseUrl);
27 | }
28 |
29 | public IRestClient RestClient { get; set; }
30 | public LwaAccessTokenRequestMetaBuilder LWAAccessTokenRequestMetaBuilder { get; set; }
31 | public LwaAuthorizationCredentials LWAAuthorizationCredentials { get; private set; }
32 |
33 | public Task GetTokenResponseAsync() => Task.FromResult(GetTokenResponse());
34 |
35 | public Task GetAccessTokenAsync() => Task.FromResult(GetAccessToken());
36 |
37 | public virtual LwaTokenResponse GetTokenResponse()
38 | {
39 | LwaAccessTokenRequestMeta lwaAccessTokenRequestMeta = LWAAccessTokenRequestMetaBuilder.Build(LWAAuthorizationCredentials);
40 | var accessTokenRequest = new RestRequest(LWAAuthorizationCredentials.Endpoint.AbsolutePath, Method.POST);
41 |
42 | string jsonRequestBody = JsonConvert.SerializeObject(lwaAccessTokenRequestMeta);
43 |
44 | accessTokenRequest.AddParameter(JsonMediaType, jsonRequestBody, ParameterType.RequestBody);
45 |
46 | LwaTokenResponse accessToken = new LwaTokenResponse();
47 | try
48 | {
49 | var response = RestClient.Execute(accessTokenRequest);
50 |
51 | if (!IsSuccessful(response))
52 | {
53 | throw new IOException("Unsuccessful LWA token exchange", response.ErrorException);
54 | }
55 |
56 | JObject responseJson = JObject.Parse(response.Content);
57 |
58 | accessToken.AccessToken = responseJson.GetValue(AccessTokenKey)?.ToString();
59 | accessToken.RefreshToken = responseJson.GetValue(RefreshTokenKey)?.ToString();
60 | accessToken.TokenType = responseJson.GetValue(TokenTypeKey)?.ToString();
61 | accessToken.ExpiresIn = responseJson.GetValue(ExpiresInKey)?.ToObject();
62 | }
63 | catch (Exception e)
64 | {
65 | throw new SystemException("Error getting LWA Access Token", e);
66 | }
67 |
68 | return accessToken;
69 | }
70 |
71 | ///
72 | /// Retrieves access token from LWA
73 | ///
74 | /// LWA AccessTokenRequest metadata
75 | /// LWA Access Token
76 | public virtual string GetAccessToken()
77 | {
78 | var token = GetTokenResponse();
79 | return token.AccessToken;
80 | }
81 |
82 | private bool IsSuccessful(IRestResponse response)
83 | {
84 | int statusCode = (int)response.StatusCode;
85 | return statusCode >= 200 && statusCode <= 299 && response.ResponseStatus == ResponseStatus.Completed;
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Model/OrderItemBuyerInfoList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel.DataAnnotations;
14 | using System.Runtime.Serialization;
15 | using System.Text;
16 | using Newtonsoft.Json;
17 |
18 | namespace Amazon.SellingPartner.RestSharp.Orders.Model
19 | {
20 | ///
21 | /// A single order item's buyer information list.
22 | ///
23 | [DataContract]
24 | public partial class OrderItemBuyerInfoList : List, IEquatable, IValidatableObject
25 | {
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public OrderItemBuyerInfoList() : base()
30 | {
31 | }
32 |
33 | ///
34 | /// Returns the string presentation of the object
35 | ///
36 | /// String presentation of the object
37 | public override string ToString()
38 | {
39 | var sb = new StringBuilder();
40 | sb.Append("class OrderItemBuyerInfoList {\n");
41 | sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
42 | sb.Append("}\n");
43 | return sb.ToString();
44 | }
45 |
46 | ///
47 | /// Returns the JSON string presentation of the object
48 | ///
49 | /// JSON string presentation of the object
50 | public string ToJson()
51 | {
52 | return JsonConvert.SerializeObject(this, Formatting.Indented);
53 | }
54 |
55 | ///
56 | /// Returns true if objects are equal
57 | ///
58 | /// Object to be compared
59 | /// Boolean
60 | public override bool Equals(object input)
61 | {
62 | return this.Equals(input as OrderItemBuyerInfoList);
63 | }
64 |
65 | ///
66 | /// Returns true if OrderItemBuyerInfoList instances are equal
67 | ///
68 | /// Instance of OrderItemBuyerInfoList to be compared
69 | /// Boolean
70 | public bool Equals(OrderItemBuyerInfoList input)
71 | {
72 | if (input == null)
73 | return false;
74 |
75 | return base.Equals(input);
76 | }
77 |
78 | ///
79 | /// Gets the hash code
80 | ///
81 | /// Hash code
82 | public override int GetHashCode()
83 | {
84 | unchecked // Overflow is fine, just wrap
85 | {
86 | int hashCode = base.GetHashCode();
87 | return hashCode;
88 | }
89 | }
90 |
91 | ///
92 | /// To validate all properties of the instance
93 | ///
94 | /// Validation context
95 | /// Validation Result
96 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
97 | {
98 | yield break;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Model/PaymentMethodDetailItemList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel.DataAnnotations;
14 | using System.Runtime.Serialization;
15 | using System.Text;
16 | using Newtonsoft.Json;
17 |
18 | namespace Amazon.SellingPartner.RestSharp.Orders.Model
19 | {
20 | ///
21 | /// A list of payment method detail items.
22 | ///
23 | [DataContract]
24 | public partial class PaymentMethodDetailItemList : List, IEquatable, IValidatableObject
25 | {
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public PaymentMethodDetailItemList() : base()
30 | {
31 | }
32 |
33 | ///
34 | /// Returns the string presentation of the object
35 | ///
36 | /// String presentation of the object
37 | public override string ToString()
38 | {
39 | var sb = new StringBuilder();
40 | sb.Append("class PaymentMethodDetailItemList {\n");
41 | sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
42 | sb.Append("}\n");
43 | return sb.ToString();
44 | }
45 |
46 | ///
47 | /// Returns the JSON string presentation of the object
48 | ///
49 | /// JSON string presentation of the object
50 | public string ToJson()
51 | {
52 | return JsonConvert.SerializeObject(this, Formatting.Indented);
53 | }
54 |
55 | ///
56 | /// Returns true if objects are equal
57 | ///
58 | /// Object to be compared
59 | /// Boolean
60 | public override bool Equals(object input)
61 | {
62 | return this.Equals(input as PaymentMethodDetailItemList);
63 | }
64 |
65 | ///
66 | /// Returns true if PaymentMethodDetailItemList instances are equal
67 | ///
68 | /// Instance of PaymentMethodDetailItemList to be compared
69 | /// Boolean
70 | public bool Equals(PaymentMethodDetailItemList input)
71 | {
72 | if (input == null)
73 | return false;
74 |
75 | return base.Equals(input);
76 | }
77 |
78 | ///
79 | /// Gets the hash code
80 | ///
81 | /// Hash code
82 | public override int GetHashCode()
83 | {
84 | unchecked // Overflow is fine, just wrap
85 | {
86 | int hashCode = base.GetHashCode();
87 | return hashCode;
88 | }
89 | }
90 |
91 | ///
92 | /// To validate all properties of the instance
93 | ///
94 | /// Validation context
95 | /// Validation Result
96 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
97 | {
98 | yield break;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.RestSharp.Orders/Model/PaymentExecutionDetailItemList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Selling Partner API for Orders
3 | *
4 | * The Selling Partner API for Orders helps you programmatically retrieve order information. These APIs let you develop fast, flexible, custom applications in areas like order synchronization, order research, and demand-based decision support tools.
5 | *
6 | * OpenAPI spec version: v0
7 | *
8 | * Generated by: https://github.com/swagger-api/swagger-codegen.git
9 | */
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel.DataAnnotations;
14 | using System.Runtime.Serialization;
15 | using System.Text;
16 | using Newtonsoft.Json;
17 |
18 | namespace Amazon.SellingPartner.RestSharp.Orders.Model
19 | {
20 | ///
21 | /// A list of payment execution detail items.
22 | ///
23 | [DataContract]
24 | public partial class PaymentExecutionDetailItemList : List, IEquatable, IValidatableObject
25 | {
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public PaymentExecutionDetailItemList() : base()
30 | {
31 | }
32 |
33 | ///
34 | /// Returns the string presentation of the object
35 | ///
36 | /// String presentation of the object
37 | public override string ToString()
38 | {
39 | var sb = new StringBuilder();
40 | sb.Append("class PaymentExecutionDetailItemList {\n");
41 | sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n");
42 | sb.Append("}\n");
43 | return sb.ToString();
44 | }
45 |
46 | ///
47 | /// Returns the JSON string presentation of the object
48 | ///
49 | /// JSON string presentation of the object
50 | public string ToJson()
51 | {
52 | return JsonConvert.SerializeObject(this, Formatting.Indented);
53 | }
54 |
55 | ///
56 | /// Returns true if objects are equal
57 | ///
58 | /// Object to be compared
59 | /// Boolean
60 | public override bool Equals(object input)
61 | {
62 | return this.Equals(input as PaymentExecutionDetailItemList);
63 | }
64 |
65 | ///
66 | /// Returns true if PaymentExecutionDetailItemList instances are equal
67 | ///
68 | /// Instance of PaymentExecutionDetailItemList to be compared
69 | /// Boolean
70 | public bool Equals(PaymentExecutionDetailItemList input)
71 | {
72 | if (input == null)
73 | return false;
74 |
75 | return base.Equals(input);
76 | }
77 |
78 | ///
79 | /// Gets the hash code
80 | ///
81 | /// Hash code
82 | public override int GetHashCode()
83 | {
84 | unchecked // Overflow is fine, just wrap
85 | {
86 | int hashCode = base.GetHashCode();
87 | return hashCode;
88 | }
89 | }
90 |
91 | ///
92 | /// To validate all properties of the instance
93 | ///
94 | /// Validation context
95 | /// Validation Result
96 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
97 | {
98 | yield break;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Sales.Client/nswag.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime": "Net60",
3 | "defaultVariables": null,
4 | "documentGenerator": {
5 | "fromDocument": {
6 | "json": "sales.json",
7 | "url": "",
8 | "output": null
9 | }
10 | },
11 | "codeGenerators": {
12 | "openApiToCSharpClient": {
13 | "exceptionClass": "AmazonSellingPartnerSalesApiException",
14 | "className": "AmazonSellingPartnerSalesClient",
15 | "namespace": "Amazon.SellingPartner.Sales.Client",
16 | "output": "AmazonSellingPartnerSalesClient.cs",
17 | "clientBaseClass": null,
18 | "configurationClass": null,
19 | "generateClientClasses": true,
20 | "generateClientInterfaces": true,
21 | "clientBaseInterface": null,
22 | "injectHttpClient": true,
23 | "disposeHttpClient": true,
24 | "protectedMethods": [],
25 | "generateExceptionClasses": true,
26 | "wrapDtoExceptions": true,
27 | "useHttpClientCreationMethod": false,
28 | "httpClientType": "System.Net.Http.HttpClient",
29 | "useHttpRequestMessageCreationMethod": false,
30 | "useBaseUrl": false,
31 | "generateBaseUrlProperty": false,
32 | "generateSyncMethods": false,
33 | "generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
34 | "exposeJsonSerializerSettings": true,
35 | "clientClassAccessModifier": "public",
36 | "typeAccessModifier": "public",
37 | "generateContractsOutput": false,
38 | "contractsNamespace": null,
39 | "contractsOutputFilePath": null,
40 | "parameterDateTimeFormat": "s",
41 | "parameterDateFormat": "yyyy-MM-dd",
42 | "generateUpdateJsonSerializerSettingsMethod": true,
43 | "useRequestAndResponseSerializationSettings": false,
44 | "serializeTypeInformation": false,
45 | "queryNullValue": "",
46 | "operationGenerationMode": "MultipleClientsFromOperationId",
47 | "additionalNamespaceUsages": [],
48 | "additionalContractNamespaceUsages": [],
49 | "generateOptionalParameters": true,
50 | "generateJsonMethods": true,
51 | "enforceFlagEnums": false,
52 | "parameterArrayType": "System.Collections.Generic.IEnumerable",
53 | "parameterDictionaryType": "System.Collections.Generic.IDictionary",
54 | "responseArrayType": "System.Collections.Generic.ICollection",
55 | "responseDictionaryType": "System.Collections.Generic.IDictionary",
56 | "wrapResponses": false,
57 | "wrapResponseMethods": [],
58 | "generateResponseClasses": true,
59 | "responseClass": "SwaggerResponse",
60 | "requiredPropertiesMustBeDefined": true,
61 | "dateType": "System.DateTime",
62 | "jsonConverters": null,
63 | "anyType": "object",
64 | "dateTimeType": "System.DateTime",
65 | "timeType": "System.TimeSpan",
66 | "timeSpanType": "System.TimeSpan",
67 | "arrayType": "System.Collections.Generic.ICollection",
68 | "arrayInstanceType": "System.Collections.ObjectModel.Collection",
69 | "dictionaryType": "System.Collections.Generic.IDictionary",
70 | "dictionaryInstanceType": "System.Collections.Generic.Dictionary",
71 | "arrayBaseType": "System.Collections.ObjectModel.Collection",
72 | "dictionaryBaseType": "System.Collections.Generic.Dictionary",
73 | "classStyle": "Poco",
74 | "jsonLibrary": "NewtonsoftJson",
75 | "generateDefaultValues": true,
76 | "generateDataAnnotations": true,
77 | "excludedTypeNames": [],
78 | "excludedParameterNames": [],
79 | "handleReferences": false,
80 | "generateImmutableArrayProperties": false,
81 | "generateImmutableDictionaryProperties": false,
82 | "jsonSerializerSettingsTransformationMethod": null,
83 | "inlineNamedArrays": false,
84 | "inlineNamedDictionaries": false,
85 | "inlineNamedTuples": true,
86 | "inlineNamedAny": false,
87 | "generateDtoTypes": true,
88 | "generateOptionalPropertiesAsNullable": false,
89 | "generateNullableReferenceTypes": false,
90 | "templateDirectory": null,
91 | "typeNameGeneratorType": null,
92 | "propertyNameGeneratorType": null,
93 | "enumNameGeneratorType": null,
94 | "serviceHost": null,
95 | "serviceSchemes": null,
96 | "newLineBehavior": "Auto"
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Feed.Client/nswag.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime": "Net60",
3 | "defaultVariables": null,
4 | "documentGenerator": {
5 | "fromDocument": {
6 | "json": "feeds_2021-06-30.json",
7 | "url": "",
8 | "output": null
9 | }
10 | },
11 | "codeGenerators": {
12 | "openApiToCSharpClient": {
13 | "exceptionClass": "AmazonSellingPartnerFeedApiException",
14 | "className": "AmazonSellingPartnerFeedClient",
15 | "namespace": "Amazon.SellingPartner.Feed.Client",
16 | "output": "AmazonSellingPartnerFeedClient.cs",
17 | "clientBaseClass": null,
18 | "configurationClass": null,
19 | "generateClientClasses": true,
20 | "generateClientInterfaces": true,
21 | "clientBaseInterface": null,
22 | "injectHttpClient": true,
23 | "disposeHttpClient": true,
24 | "protectedMethods": [],
25 | "generateExceptionClasses": true,
26 | "wrapDtoExceptions": true,
27 | "useHttpClientCreationMethod": false,
28 | "httpClientType": "System.Net.Http.HttpClient",
29 | "useHttpRequestMessageCreationMethod": false,
30 | "useBaseUrl": false,
31 | "generateBaseUrlProperty": false,
32 | "generateSyncMethods": false,
33 | "generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
34 | "exposeJsonSerializerSettings": true,
35 | "clientClassAccessModifier": "public",
36 | "typeAccessModifier": "public",
37 | "generateContractsOutput": false,
38 | "contractsNamespace": null,
39 | "contractsOutputFilePath": null,
40 | "parameterDateTimeFormat": "s",
41 | "parameterDateFormat": "yyyy-MM-dd",
42 | "generateUpdateJsonSerializerSettingsMethod": true,
43 | "useRequestAndResponseSerializationSettings": false,
44 | "serializeTypeInformation": false,
45 | "queryNullValue": "",
46 | "operationGenerationMode": "MultipleClientsFromOperationId",
47 | "additionalNamespaceUsages": [],
48 | "additionalContractNamespaceUsages": [],
49 | "generateOptionalParameters": true,
50 | "generateJsonMethods": true,
51 | "enforceFlagEnums": false,
52 | "parameterArrayType": "System.Collections.Generic.IEnumerable",
53 | "parameterDictionaryType": "System.Collections.Generic.IDictionary",
54 | "responseArrayType": "System.Collections.Generic.ICollection",
55 | "responseDictionaryType": "System.Collections.Generic.IDictionary",
56 | "wrapResponses": false,
57 | "wrapResponseMethods": [],
58 | "generateResponseClasses": true,
59 | "responseClass": "SwaggerResponse",
60 | "requiredPropertiesMustBeDefined": true,
61 | "dateType": "System.DateTime",
62 | "jsonConverters": null,
63 | "anyType": "object",
64 | "dateTimeType": "System.DateTime",
65 | "timeType": "System.TimeSpan",
66 | "timeSpanType": "System.TimeSpan",
67 | "arrayType": "System.Collections.Generic.ICollection",
68 | "arrayInstanceType": "System.Collections.ObjectModel.Collection",
69 | "dictionaryType": "System.Collections.Generic.IDictionary",
70 | "dictionaryInstanceType": "System.Collections.Generic.Dictionary",
71 | "arrayBaseType": "System.Collections.ObjectModel.Collection",
72 | "dictionaryBaseType": "System.Collections.Generic.Dictionary",
73 | "classStyle": "Poco",
74 | "jsonLibrary": "NewtonsoftJson",
75 | "generateDefaultValues": true,
76 | "generateDataAnnotations": true,
77 | "excludedTypeNames": [],
78 | "excludedParameterNames": [],
79 | "handleReferences": false,
80 | "generateImmutableArrayProperties": false,
81 | "generateImmutableDictionaryProperties": false,
82 | "jsonSerializerSettingsTransformationMethod": null,
83 | "inlineNamedArrays": false,
84 | "inlineNamedDictionaries": false,
85 | "inlineNamedTuples": true,
86 | "inlineNamedAny": false,
87 | "generateDtoTypes": true,
88 | "generateOptionalPropertiesAsNullable": false,
89 | "generateNullableReferenceTypes": false,
90 | "templateDirectory": null,
91 | "typeNameGeneratorType": null,
92 | "propertyNameGeneratorType": null,
93 | "enumNameGeneratorType": null,
94 | "serviceHost": null,
95 | "serviceSchemes": null,
96 | "newLineBehavior": "Auto"
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Orders.Client/nswag.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime": "Net60",
3 | "defaultVariables": null,
4 | "documentGenerator": {
5 | "fromDocument": {
6 | "json": "ordersV0.json",
7 | "url": "",
8 | "output": null
9 | }
10 | },
11 | "codeGenerators": {
12 | "openApiToCSharpClient": {
13 | "exceptionClass": "AmazonSellingPartnerOrdersApiException",
14 | "className": "AmazonSellingPartnerOrdersClient",
15 | "namespace": "Amazon.SellingPartner.Orders.Client",
16 | "output": "AmazonSellingPartnerOrdersClient.cs",
17 | "clientBaseClass": null,
18 | "configurationClass": null,
19 | "generateClientClasses": true,
20 | "generateClientInterfaces": true,
21 | "clientBaseInterface": null,
22 | "injectHttpClient": true,
23 | "disposeHttpClient": true,
24 | "protectedMethods": [],
25 | "generateExceptionClasses": true,
26 | "wrapDtoExceptions": true,
27 | "useHttpClientCreationMethod": false,
28 | "httpClientType": "System.Net.Http.HttpClient",
29 | "useHttpRequestMessageCreationMethod": false,
30 | "useBaseUrl": false,
31 | "generateBaseUrlProperty": false,
32 | "generateSyncMethods": false,
33 | "generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
34 | "exposeJsonSerializerSettings": true,
35 | "clientClassAccessModifier": "public",
36 | "typeAccessModifier": "public",
37 | "generateContractsOutput": false,
38 | "contractsNamespace": null,
39 | "contractsOutputFilePath": null,
40 | "parameterDateTimeFormat": "s",
41 | "parameterDateFormat": "yyyy-MM-dd",
42 | "generateUpdateJsonSerializerSettingsMethod": true,
43 | "useRequestAndResponseSerializationSettings": false,
44 | "serializeTypeInformation": false,
45 | "queryNullValue": "",
46 | "operationGenerationMode": "MultipleClientsFromOperationId",
47 | "additionalNamespaceUsages": [],
48 | "additionalContractNamespaceUsages": [],
49 | "generateOptionalParameters": true,
50 | "generateJsonMethods": true,
51 | "enforceFlagEnums": false,
52 | "parameterArrayType": "System.Collections.Generic.IEnumerable",
53 | "parameterDictionaryType": "System.Collections.Generic.IDictionary",
54 | "responseArrayType": "System.Collections.Generic.ICollection",
55 | "responseDictionaryType": "System.Collections.Generic.IDictionary",
56 | "wrapResponses": false,
57 | "wrapResponseMethods": [],
58 | "generateResponseClasses": true,
59 | "responseClass": "SwaggerResponse",
60 | "requiredPropertiesMustBeDefined": true,
61 | "dateType": "System.DateTime",
62 | "jsonConverters": null,
63 | "anyType": "object",
64 | "dateTimeType": "System.DateTime",
65 | "timeType": "System.TimeSpan",
66 | "timeSpanType": "System.TimeSpan",
67 | "arrayType": "System.Collections.Generic.ICollection",
68 | "arrayInstanceType": "System.Collections.ObjectModel.Collection",
69 | "dictionaryType": "System.Collections.Generic.IDictionary",
70 | "dictionaryInstanceType": "System.Collections.Generic.Dictionary",
71 | "arrayBaseType": "System.Collections.ObjectModel.Collection",
72 | "dictionaryBaseType": "System.Collections.Generic.Dictionary",
73 | "classStyle": "Poco",
74 | "jsonLibrary": "NewtonsoftJson",
75 | "generateDefaultValues": true,
76 | "generateDataAnnotations": true,
77 | "excludedTypeNames": [],
78 | "excludedParameterNames": [],
79 | "handleReferences": false,
80 | "generateImmutableArrayProperties": false,
81 | "generateImmutableDictionaryProperties": false,
82 | "jsonSerializerSettingsTransformationMethod": null,
83 | "inlineNamedArrays": false,
84 | "inlineNamedDictionaries": false,
85 | "inlineNamedTuples": true,
86 | "inlineNamedAny": false,
87 | "generateDtoTypes": true,
88 | "generateOptionalPropertiesAsNullable": false,
89 | "generateNullableReferenceTypes": false,
90 | "templateDirectory": null,
91 | "typeNameGeneratorType": null,
92 | "propertyNameGeneratorType": null,
93 | "enumNameGeneratorType": null,
94 | "serviceHost": null,
95 | "serviceSchemes": null,
96 | "newLineBehavior": "Auto"
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/src/Clients/Amazon.SellingPartner.Sellers.Client/nswag.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime": "Net60",
3 | "defaultVariables": null,
4 | "documentGenerator": {
5 | "fromDocument": {
6 | "json": "sellers.json",
7 | "url": "",
8 | "output": null
9 | }
10 | },
11 | "codeGenerators": {
12 | "openApiToCSharpClient": {
13 | "exceptionClass": "AmazonSellingPartnerSellersApiException",
14 | "className": "AmazonSellingPartnerSellersClient",
15 | "namespace": "Amazon.SellingPartner.Sellers.Client",
16 | "output": "AmazonSellingPartnerSellersClient.cs",
17 | "clientBaseClass": null,
18 | "configurationClass": null,
19 | "generateClientClasses": true,
20 | "generateClientInterfaces": true,
21 | "clientBaseInterface": null,
22 | "injectHttpClient": true,
23 | "disposeHttpClient": true,
24 | "protectedMethods": [],
25 | "generateExceptionClasses": true,
26 | "wrapDtoExceptions": true,
27 | "useHttpClientCreationMethod": false,
28 | "httpClientType": "System.Net.Http.HttpClient",
29 | "useHttpRequestMessageCreationMethod": false,
30 | "useBaseUrl": false,
31 | "generateBaseUrlProperty": false,
32 | "generateSyncMethods": false,
33 | "generatePrepareRequestAndProcessResponseAsAsyncMethods": false,
34 | "exposeJsonSerializerSettings": true,
35 | "clientClassAccessModifier": "public",
36 | "typeAccessModifier": "public",
37 | "generateContractsOutput": false,
38 | "contractsNamespace": null,
39 | "contractsOutputFilePath": null,
40 | "parameterDateTimeFormat": "s",
41 | "parameterDateFormat": "yyyy-MM-dd",
42 | "generateUpdateJsonSerializerSettingsMethod": true,
43 | "useRequestAndResponseSerializationSettings": false,
44 | "serializeTypeInformation": false,
45 | "queryNullValue": "",
46 | "operationGenerationMode": "MultipleClientsFromOperationId",
47 | "additionalNamespaceUsages": [],
48 | "additionalContractNamespaceUsages": [],
49 | "generateOptionalParameters": true,
50 | "generateJsonMethods": true,
51 | "enforceFlagEnums": false,
52 | "parameterArrayType": "System.Collections.Generic.IEnumerable",
53 | "parameterDictionaryType": "System.Collections.Generic.IDictionary",
54 | "responseArrayType": "System.Collections.Generic.ICollection",
55 | "responseDictionaryType": "System.Collections.Generic.IDictionary",
56 | "wrapResponses": false,
57 | "wrapResponseMethods": [],
58 | "generateResponseClasses": true,
59 | "responseClass": "SwaggerResponse",
60 | "requiredPropertiesMustBeDefined": true,
61 | "dateType": "System.DateTime",
62 | "jsonConverters": null,
63 | "anyType": "object",
64 | "dateTimeType": "System.DateTime",
65 | "timeType": "System.TimeSpan",
66 | "timeSpanType": "System.TimeSpan",
67 | "arrayType": "System.Collections.Generic.ICollection",
68 | "arrayInstanceType": "System.Collections.ObjectModel.Collection",
69 | "dictionaryType": "System.Collections.Generic.IDictionary",
70 | "dictionaryInstanceType": "System.Collections.Generic.Dictionary",
71 | "arrayBaseType": "System.Collections.ObjectModel.Collection",
72 | "dictionaryBaseType": "System.Collections.Generic.Dictionary",
73 | "classStyle": "Poco",
74 | "jsonLibrary": "NewtonsoftJson",
75 | "generateDefaultValues": true,
76 | "generateDataAnnotations": true,
77 | "excludedTypeNames": [],
78 | "excludedParameterNames": [],
79 | "handleReferences": false,
80 | "generateImmutableArrayProperties": false,
81 | "generateImmutableDictionaryProperties": false,
82 | "jsonSerializerSettingsTransformationMethod": null,
83 | "inlineNamedArrays": false,
84 | "inlineNamedDictionaries": false,
85 | "inlineNamedTuples": true,
86 | "inlineNamedAny": false,
87 | "generateDtoTypes": true,
88 | "generateOptionalPropertiesAsNullable": false,
89 | "generateNullableReferenceTypes": false,
90 | "templateDirectory": null,
91 | "typeNameGeneratorType": null,
92 | "propertyNameGeneratorType": null,
93 | "enumNameGeneratorType": null,
94 | "serviceHost": null,
95 | "serviceSchemes": null,
96 | "newLineBehavior": "Auto"
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------