🔥 AMAZON测试案例调整

master
wufan 4 months ago
parent 9b5a65f01c
commit 0926699563

@ -23,20 +23,20 @@ public class SampleShippingV2Tests : SampleTestsBase
{
ShipTo = new Address
{
Name = "Maria Mata",
AddressLine1 = "2760 W Yowlumne Ave, Ste A",
StateOrRegion = "CA",
City = "Porterville",
Name = "Courtesy Chakma",
AddressLine1 = "14420 97TH AVE BSMT DOOR JAMAICA",
StateOrRegion = "NY",
City = "JAMAICA",
CountryCode = "US",
PostalCode = "93257",
PostalCode = "11435-4424",
},
ShipDate = new DateTime(2024,10,30),
ShipDate = new DateTime(2024,10,25,15,30,0),
ShipFrom = new Address
{
Name = "EDDIE",
Name = "bosonshop",
AddressLine1 = "11190 White Birch Dr Suite 100",
StateOrRegion = "CA",
City = "Rancho Cucamonga",
City = "RanchoCucamonga",
CountryCode = "US",
PostalCode = "91730",
},
@ -61,28 +61,28 @@ public class SampleShippingV2Tests : SampleTestsBase
Value = 200,
Unit = "USD"
},
PackageClientReferenceId = "111-0844329-0173888",
PackageClientReferenceId = "111-0844329-0DAWDAV",
IsHazmat = false,
Items = new ItemList
{
new Item
{
// ItemValue = new Currency
// {
// Value = 200,
// Unit = "USD"
// },
ItemValue = new Currency
{
Value = 200,
Unit = "USD"
},
Quantity = 1,
Weight = new Weight
{
Unit = WeightUnitEnum.POUND,
Value = 20
},
// LiquidVolume = new LiquidVolume
// {
// Unit = LiquidVolume.UnitEnum.ML,
// Value = 2000
// },
LiquidVolume = new LiquidVolume
{
Unit = LiquidVolumeUnitEnum.ML,
Value = 2000
},
}
}
}

@ -22,7 +22,8 @@ public class SampleTestsBase
MarketPlace.US.Id
)
{
IsDebugMode = true
IsDebugMode = true,
ShippingBusiness = Constants.ShippingBusiness.AmazonShipping_US
};
return credential;

@ -80,6 +80,8 @@ namespace Amazon.SellingPartnerApiSDK
/// </summary>
public int MaxThrottledRetryCount { get; set; } = 3;
public ShippingBusiness? ShippingBusiness { get; set; }
/// <summary>
/// 是否启用调试模式
/// </summary>

@ -0,0 +1,34 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Xml.Serialization;
namespace Amazon.SellingPartnerApiSDK.Misc
{
public static class LinqHelper
{
public static string GetEnumMemberValue<T>(this T value) where T : Enum
{
return typeof(T)
.GetTypeInfo()
.DeclaredMembers
.SingleOrDefault(x => x.Name == value.ToString())
?.GetCustomAttribute<EnumMemberAttribute>(false)
?.Value;
}
public static string SerializeObject<T>(this T toSerialize)
{
XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());
using (StringWriter textWriter = new StringWriter())
{
xmlSerializer.Serialize(textWriter, toSerialize);
return textWriter.ToString();
}
}
}
}

@ -97,6 +97,7 @@ namespace Amazon.SellingPartnerApiSDK.Services
{
RestHeader();
AddAccessToken();
AddShippingBusinessId();
var response = await RequestClient.ExecuteAsync<T>(Request, cancellationToken);
LogRequest(Request, response);
SaveLastRequestHeader(response.Headers);
@ -284,6 +285,13 @@ namespace Amazon.SellingPartnerApiSDK.Services
}
}
private void AddShippingBusinessId()
{
if (AmazonCredential.ShippingBusiness.HasValue)
Request.AddOrUpdateHeader(ShippingBusinessIdHeaderName,
AmazonCredential.ShippingBusiness.Value.GetEnumMemberValue());
}
private async Task RefreshTokenAsync(CacheTokenData.TokenDataType tokenDataType = CacheTokenData.TokenDataType.Normal,
CreateRestrictedDataTokenRequest requestPii = null, CancellationToken cancellationToken = default)
{

Loading…
Cancel
Save