You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using Amazon.SellingPartnerApiSDK.AmazonSpApiSDK.Models.Exceptions;
|
|
|
|
|
using Amazon.SellingPartnerApiSDK.Misc;
|
|
|
|
|
using Amazon.SellingPartnerApiSDK.Services;
|
|
|
|
|
|
|
|
|
|
namespace Amazon.SellingPartnerApiSDK
|
|
|
|
|
{
|
|
|
|
|
public class AmazonConnection
|
|
|
|
|
{
|
|
|
|
|
private AmazonCredential Credentials { get; set; }
|
|
|
|
|
|
|
|
|
|
public MarketPlace GetCurrentMarketplace => Credentials.MarketPlace;
|
|
|
|
|
|
|
|
|
|
public string GetCurrentSellerId => Credentials.SellerId;
|
|
|
|
|
|
|
|
|
|
private readonly UnauthorizedAccessException _noCredentials =
|
|
|
|
|
new UnauthorizedAccessException("Amazon凭据信息不存在,无法请求API!");
|
|
|
|
|
|
|
|
|
|
#region ShippingV2
|
|
|
|
|
|
|
|
|
|
private readonly ShippingV2Service _shippingV2;
|
|
|
|
|
|
|
|
|
|
public ShippingV2Service ShippingV2 => this._shippingV2 ?? throw _noCredentials;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public AmazonConnection(AmazonCredential credentials)
|
|
|
|
|
{
|
|
|
|
|
this.Credentials = credentials ??
|
|
|
|
|
throw new AmazonUnauthorizedException(
|
|
|
|
|
"Amazon凭据信息不存在,无法请求API!");
|
|
|
|
|
|
|
|
|
|
_shippingV2 = new ShippingV2Service(this.Credentials);
|
|
|
|
|
|
|
|
|
|
AmazonCredential.DebugMode = Credentials.IsDebugMode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|