Skip to content

Commit a98b111

Browse files
authored
Merge branch 'abuzuhri:main' into main
2 parents 1f7f4bf + 836fa40 commit a98b111

File tree

13 files changed

+101
-17
lines changed

13 files changed

+101
-17
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ For more information about keys please check [New Amazon doc for create keys Dev
9797
---
9898
## Usage
9999

100+
> ### Please be aware there has been a change to the _Orders.GetOrderAddress()_ method please reference the new sample code for more details.
101+
100102
### Configuration
103+
You can configure a connection like so please see [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/Program.cs) for the relevant code file.
101104
```CSharp
102105
AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()
103106
{
@@ -125,6 +128,25 @@ AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()
125128

126129
```
127130

131+
### Configuration using a proxy
132+
Please see [here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/Program.cs) for the relevant code file.
133+
>```csharp
134+
>AmazonConnection amazonConnection = new AmazonConnection(new AmazonCredential()
135+
>{
136+
> AccessKey = "AKIAXXXXXXXXXXXXXXX",
137+
> SecretKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
138+
> RoleArn = "arn:aws:iam::XXXXXXXXXXXXX:role/XXXXXXXXXXXX",
139+
> ClientId = "amzn1.application-XXX-client.XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
140+
> ClientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
141+
> RefreshToken= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
142+
> MarketPlaceID = "A2VIGQ35RCS4UG",
143+
> ProxyAddress = "http(s)://xxx.xxx.xxx.xxx:xxxx",
144+
>});
145+
>```
146+
>> * Assign your proxy address to the ProxyAddress Property and you'll be able to use a proxy account.
147+
>>
148+
>> ***This is not required and will operate normally without the ProxyAddress being set.***
149+
128150
### Order List, For more orders sample please check [Here](https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/ReportsSample.cs).
129151
```CSharp
130152
ParameterOrderList serachOrderList = new ParameterOrderList();

Source/FikaAmazonAPI.SampleCode/OrdersSample.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ public void GetOrderBuyerInfo()
102102

103103
public void GetOrderAddress()
104104
{
105+
// This method has been changed and is a breaking change
106+
// If you would like the default behavior please reference the
107+
// ShippingAddress variable
105108
var Address = amazonConnection.Orders.GetOrderAddress("402-0467973-4229120");
109+
var BuyerCompanyName = Address.BuyerCompanyName;
110+
var ShippingAddress = Address.ShippingAddress;
111+
var DeliveryPreferences = Address.DeliveryPreferences;
106112
}
107113

108114

Source/FikaAmazonAPI.SampleCode/Program.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ static async Task Main(string[] args)
2727
SellerID = config.GetSection("FikaAmazonAPI:SellerId").Value,
2828
IsDebugMode = true
2929
});
30+
31+
AmazonConnection amazonConnectionUsingAProxy = new AmazonConnection(new AmazonCredential()
32+
{
33+
AccessKey = config.GetSection("FikaAmazonAPI:AccessKey").Value,
34+
SecretKey = config.GetSection("FikaAmazonAPI:SecretKey").Value,
35+
RoleArn = config.GetSection("FikaAmazonAPI:RoleArn").Value,
36+
ClientId = config.GetSection("FikaAmazonAPI:ClientId").Value,
37+
ClientSecret = config.GetSection("FikaAmazonAPI:ClientSecret").Value,
38+
RefreshToken = config.GetSection("FikaAmazonAPI:RefreshToken").Value,
39+
MarketPlaceID = config.GetSection("FikaAmazonAPI:MarketPlaceID").Value,
40+
SellerID = config.GetSection("FikaAmazonAPI:SellerId").Value,
41+
IsDebugMode = true,
42+
ProxyAddress = config.GetSection("FikaAmazonAPI:ProxyAddress").Value,
43+
});
3044

3145
var search = amazonConnection.ProductType.SearchDefinitionsProductTypes(new Parameter.ProductTypes.SearchDefinitionsProductTypesParameter
3246
{

Source/FikaAmazonAPI.SampleCode/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"ClientId": "amzn1.application-oa2-client.0000000000000000000000000000",
77
"ClientSecret": "000000000000000000000000000000000000",
88
"RefreshToken": "Atzr|00000000000000000000000000000000000000000000",
9-
"MarketPlaceID": "A2VIGQ35RCS4UG"
9+
"MarketPlaceID": "A2VIGQ35RCS4UG",
10+
"ProxyAddress": "http://localhost:8080",
1011
}
1112
}

Source/FikaAmazonAPI/AmazonCredential.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ public class AmazonCredential
2323
public bool IsDebugMode { get; set; }
2424
public string MarketPlaceID { get; set; }
2525
public string SellerID { get; set; }
26+
public string ProxyAddress { get; set; }
2627

2728
public AmazonCredential()
2829
{
2930
CacheTokenData = new CacheTokenData();
3031
}
31-
public AmazonCredential(string AccessKey, string SecretKey, string RoleArn, string ClientId, string ClientSecret, string RefreshToken)
32+
public AmazonCredential(string AccessKey, string SecretKey, string RoleArn, string ClientId, string ClientSecret, string RefreshToken, string ProxyAddress = null)
3233
{
3334
this.AccessKey = AccessKey;
3435
this.SecretKey = SecretKey;
3536
this.RoleArn = RoleArn;
3637
this.ClientId = ClientId;
3738
this.ClientSecret = ClientSecret;
3839
this.RefreshToken = RefreshToken;
40+
this.ProxyAddress = ProxyAddress;
3941
CacheTokenData = new CacheTokenData();
4042
}
4143

Source/FikaAmazonAPI/AmazonSpApiSDK/Models/Orders/PackageDetail.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IO;
66
using System.Runtime.Serialization;
77
using System.Text;
8+
using FikaAmazonAPI.Utils;
89

910
namespace FikaAmazonAPI.AmazonSpApiSDK.Models.Orders
1011
{
@@ -120,6 +121,7 @@ public PackageDetail() { }
120121
/// The shipping date for the package. Must be in ISO-8601 date/time format.
121122
/// </summary>
122123
/// <value>The shipping date for the package. Must be in ISO-8601 date/time format.</value>
124+
[JsonConverter(typeof(Iso8601DateTimeConverter))]
123125
[DataMember(Name = "shipDate", EmitDefaultValue = false)]
124126
public DateTime? ShipDate { get; set; }
125127

Source/FikaAmazonAPI/AmazonSpApiSDK/Runtime/LWAClient.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,27 @@ public class LWAClient
1818
public LWAAuthorizationCredentials LWAAuthorizationCredentials { get; private set; }
1919

2020

21-
public LWAClient(LWAAuthorizationCredentials lwaAuthorizationCredentials)
21+
public LWAClient(LWAAuthorizationCredentials lwaAuthorizationCredentials, string proxyAddress = null)
2222
{
2323

2424
LWAAuthorizationCredentials = lwaAuthorizationCredentials;
2525
LWAAccessTokenRequestMetaBuilder = new LWAAccessTokenRequestMetaBuilder();
2626
// RestClient = new RestClient(LWAAuthorizationCredentials.Endpoint.GetLeftPart(UriPartial.Authority));
27-
RestClient =
28-
RestClientSingleton.GetRestClient(
29-
LWAAuthorizationCredentials.Endpoint.GetLeftPart(UriPartial.Authority));
27+
if (string.IsNullOrWhiteSpace(proxyAddress))
28+
{
29+
RestClient = new RestClient(LWAAuthorizationCredentials.Endpoint.GetLeftPart(UriPartial.Authority));
30+
}else
31+
{
32+
var options = new RestClientOptions(LWAAuthorizationCredentials.Endpoint.GetLeftPart(UriPartial.Authority))
33+
{
34+
Proxy = new System.Net.WebProxy()
35+
{
36+
Address = new Uri(proxyAddress)
37+
}
38+
};
39+
40+
RestClient = new RestClient(options);
41+
}
3042
}
3143

3244

Source/FikaAmazonAPI/FikaAmazonAPI.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<Product>CSharp Amazon Sp API</Product>
88
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
99
<LangVersion>8.0</LangVersion>
10-
<Version>1.6.2</Version>
11-
<AssemblyVersion>1.6.2</AssemblyVersion>
12-
<FileVersion>1.6.2</FileVersion>
10+
<Version>1.6.4</Version>
11+
<AssemblyVersion>1.6.4</AssemblyVersion>
12+
<FileVersion>1.6.4</FileVersion>
1313
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1414
<PackageProjectUrl>https://github.com/abuzuhri/Amazon-SP-API-CSharp</PackageProjectUrl>
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Source/FikaAmazonAPI/Services/OrderService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ public async Task<OrderItemsBuyerInfoList> GetOrderItemsBuyerInfoAsync(string or
186186
return response.Payload;
187187
}
188188

189-
public Address GetOrderAddress(string orderId) =>
189+
public OrderAddress GetOrderAddress(string orderId) =>
190190
Task.Run(() => GetOrderAddressAsync(orderId)).ConfigureAwait(false).GetAwaiter().GetResult();
191-
public async Task<Address> GetOrderAddressAsync(string orderId, CancellationToken cancellationToken = default)
191+
public async Task<OrderAddress> GetOrderAddressAsync(string orderId, CancellationToken cancellationToken = default)
192192
{
193193
await CreateAuthorizedRequestAsync(OrdersApiUrls.OrderShipmentInfo(orderId), RestSharp.Method.Get, cancellationToken: cancellationToken);
194194
var response = await ExecuteRequestAsync<GetOrderAddressResponse>(Utils.RateLimitType.Order_GetOrderAddress, cancellationToken);
195-
return response.Payload.ShippingAddress;
195+
return response.Payload;
196196
}
197197

198198
public bool UpdateShipmentStatus(string orderId, UpdateShipmentStatusRequest updateShipmentStatusRequest) =>

Source/FikaAmazonAPI/Services/RequestService.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,24 @@ public RequestService(AmazonCredential amazonCredential)
5656

5757
private void CreateRequest(string url, RestSharp.Method method)
5858
{
59-
RequestClient = RestClientSingleton.GetRestClient(ApiBaseUrl);
60-
// RequestClient = new RestClient(ApiBaseUrl);
61-
// RequestClient.UseNewtonsoftJson();
59+
if (string.IsNullOrWhiteSpace(AmazonCredential.ProxyAddress))
60+
{
61+
RequestClient = new RestClient(ApiBaseUrl);
62+
}
63+
else
64+
{
65+
var options = new RestClientOptions(ApiBaseUrl)
66+
{
67+
Proxy = new System.Net.WebProxy()
68+
{
69+
Address = new Uri(AmazonCredential.ProxyAddress)
70+
}
71+
};
72+
73+
RequestClient = new RestClient(options);
74+
}
75+
76+
RequestClient.UseNewtonsoftJson();
6277
Request = new RestRequest(url, method);
6378
}
6479

0 commit comments

Comments
 (0)