Skip to content

Commit 9a0a442

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 6c5f17a + 5a92af8 commit 9a0a442

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

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/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/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

Source/FikaAmazonAPI/Services/TokenGeneration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static async Task<TokenResponse> RefreshAccessTokenAsync(AmazonCredential
3232
if (tokenDataType == TokenDataType.Grantless)
3333
lwaCredentials.Scopes = new List<string>() { ScopeConstants.ScopeMigrationAPI, ScopeConstants.ScopeNotificationsAPI };
3434

35-
var Client = new LWAClient(lwaCredentials);
35+
var Client = new LWAClient(lwaCredentials, credentials.ProxyAddress);
3636
var accessToken = await Client.GetAccessTokenAsync(cancellationToken);
3737

3838
return accessToken;

0 commit comments

Comments
 (0)