Migration from Amazon MWS to Selling Partner API

This commit is contained in:
Bobbie Hodgetts
2024-04-11 12:26:13 +01:00
committed by GitHub
parent e054278cdd
commit a7bc00e73a
1318 changed files with 2778105 additions and 5936 deletions

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Amazon
{
public class ProductCompetitivePrice
{
public string Asin { get; private set; }
/// <summary>
/// The competitive price of a product in 'New' condition
/// </summary>
public decimal CompetitivePrice { get; private set; }
public bool CompetitivePriceIsSet { get; private set; }
public bool IsBuyBox { get; private set; }
public bool BuyBoxBelongsToRequester { get; private set; }
public int OffersCountNew { get; private set; }
public int OffersCountUsed { get; private set; }
public ProductCompetitivePrice(string asin, decimal competitivePrice, bool competitivePriceIsSet,
bool isBuyBox, bool buyBoxBelongsToRequester, int offersCountNew, int offersCountUsed)
{
this.Asin = asin;
this.CompetitivePrice = competitivePrice;
this.CompetitivePriceIsSet = competitivePriceIsSet;
this.IsBuyBox = isBuyBox;
this.BuyBoxBelongsToRequester = buyBoxBelongsToRequester;
this.OffersCountNew = offersCountNew;
this.OffersCountUsed = offersCountUsed;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Amazon
{
public class ProductFeeEstimate
{
public int ProductId { get; set; }
public string Asin { get; set; }
public bool IsAmazonFulfilled { get; set; }
public DateTime TimeOfFeeEstimation { get; set; }
public decimal TotalFeeEstimate { get; set; }
public decimal PriceToEstimateFeeListingPrice { get; set; }
public decimal PriceToEstimateFeeShipping { get; set; }
public decimal PriceToEstimateFeePoints { get; set; }
public decimal ReferralFee { get; set; }
public decimal VariableClosingFee { get; set; }
public decimal PerItemFee { get; set; }
public decimal FulfillmentFees { get; set; }
public decimal OtherFee_Exception { get; set; }
public string CurrencyCode { get; set; }
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.AmazonFba
{
public class ShippingPlanItem
{
/// <summary>
/// Initializes a new instance of the <see cref="ShippingPlanItem" /> class.
/// </summary>
/// <param name="skuNumber">The seller SKU of the item. (required).</param>
/// <param name="asin">The Amazon Standard Identification Number (ASIN) of the item. (required).</param>
/// <param name="condition">Condition (required).</param>
/// <param name="quantity">Quantity (required).</param>
public ShippingPlanItem(string skuNumber, string asin, string condition, int quantity)
{
// to ensure "SellerSKU" is required (not null)
if (skuNumber == null)
{
throw new Exception("SellerSKU is a required property for InboundShipmentPlanRequestItem and cannot be null");
}
else
{
this.SkuNumber = skuNumber;
}
// to ensure "ASIN" is required (not null)
if (asin == null)
{
throw new Exception("ASIN is a required property for InboundShipmentPlanRequestItem and cannot be null");
}
else
{
this.ASIN = asin;
}
// to ensure "Condition" is required (not null)
if (condition == null)
{
throw new Exception("Condition is a required property for InboundShipmentPlanRequestItem and cannot be null");
}
else
{
this.Condition = condition;
}
// to ensure "Quantity" is required (not null)
if (quantity == 0)
{
throw new Exception("Quantity is a required property for InboundShipmentPlanRequestItem and cannot be null");
}
else
{
this.Quantity = quantity;
}
}
/// <summary>
/// Gets or Sets Condition
/// </summary>
public string Condition { get; set; }
/// <summary>
/// The seller SKU of the item.
/// </summary>
/// <value>The seller SKU of the item.</value>
public string SkuNumber { get; set; }
/// <summary>
/// The Amazon Standard Identification Number (ASIN) of the item.
/// </summary>
/// <value>The Amazon Standard Identification Number (ASIN) of the item.</value>
public string ASIN { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
public int Quantity { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Credentials
{
public class AmazonSPAPI
{
public string AccessKey { get; private set; }
public string SecretKey { get; private set; }
public string RoleArn { get; private set; }
public string ClientId { get; private set; }
public string ClientSecret { get; private set; }
public string RefreshToken { get; private set; }
public AmazonSPAPI(string accessKey, string secretKey, string roleArn, string clientId, string clientSecret, string refreshToken)
{
this.AccessKey = accessKey;
this.SecretKey = secretKey;
this.RoleArn = roleArn;
this.ClientId = clientId;
this.ClientSecret = clientSecret;
this.RefreshToken = refreshToken;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Credentials
{
public class bnhtradeDB
{
public string DataSource { get; private set; }
public string UserId { get; private set; }
public string UserPassword { get; private set; }
public string InitialCatalog { get; private set; } = "e2A";
public bool PersistSecurityInfo { get; private set; } = true;
public bool MultipleActiveResultSets { get; private set; } = true;
public string ConnectionString
{ get
{
return "Data Source=" + DataSource + ";Initial Catalog=" + InitialCatalog + ";Persist Security Info=" + PersistSecurityInfo.ToString()
+ ";User ID=" + UserId + ";Password=" + UserPassword + ";MultipleActiveResultSets=" + MultipleActiveResultSets.ToString();
}
}
public bnhtradeDB (string source, string userId, string userPassword)
{
this.DataSource = source;
this.UserId = userId;
this.UserPassword = userPassword;
}
}
}

View File

@@ -10,6 +10,16 @@ namespace bnhtrade.Core.Model.Import
{
public List<SettlementLine> SettlementLineList { get; set; } = new List<SettlementLine>();
public AmazonSettlement()
{
}
public AmazonSettlement(AmazonSettlementHeader toCopy) : base (toCopy)
{
}
public bool SettlementLineListIsSet
{
get

View File

@@ -9,27 +9,49 @@ namespace bnhtrade.Core.Model.Import
{
public class AmazonSettlementHeader
{
private string marketplaceName = null;
private string settlementId = null;
private string currencyCode = null;
private DateTime? startDate = null;
private DateTime? endDate = null;
private DateTime? depositDate = null;
private decimal? totalAmount = null;
private bool? isProcessed = null;
private string spapiReportId = null;
public string MarketPlaceName
public AmazonSettlementHeader()
{
get;
set;
}
public AmazonSettlementHeader(AmazonSettlementHeader toCopy)
{
this.marketplaceName = toCopy.MarketPlaceName;
this.settlementId = toCopy.SettlementId;
this.currencyCode = toCopy.CurrencyCode;
if (toCopy.StartDateIsSet) { this.startDate = toCopy.StartDate; }
if (toCopy.EndDateIsSet) { this.endDate = toCopy.endDate; }
if (toCopy.DepositDateIsSet) { this.depositDate = toCopy.DepositDate; }
if (toCopy.TotalAmountIsSet) { this.totalAmount = toCopy.TotalAmount; }
if (toCopy.IsProcessedIsSet) { this.isProcessed = toCopy.IsProcessed; }
if (toCopy.SpapiReportIdIsSet) { this.spapiReportId = toCopy.SpapiReportId; }
}
public string MarketPlaceName
{
get { return marketplaceName; }
set { this.marketplaceName = value; }
}
public bool MarketPlaceNameIsSet
{
get { return MarketPlaceName != null; }
get { return marketplaceName != null; }
}
public string SettlementId
{
get;
set;
get { return this.settlementId; }
set { this.settlementId = value; }
}
public bool SettlementIdIsSet
@@ -83,8 +105,8 @@ namespace bnhtrade.Core.Model.Import
public string CurrencyCode
{
get;
set;
get { return this.currencyCode; }
set { this.currencyCode = value; }
}
public bool CurrencyCodeIsSet
@@ -103,5 +125,16 @@ namespace bnhtrade.Core.Model.Import
{
get { return isProcessed != null; }
}
public string SpapiReportId
{
get { return this.spapiReportId; }
set { this.spapiReportId = value; }
}
public bool SpapiReportIdIsSet
{
get { return this.spapiReportId != null; }
}
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Product
{
public class ProductInfo
{
private string titleBody;
public ProductInfo(string title, int categoryId, int procurementControlId = 1)
{
Title = title;
ProductCategoryID = categoryId;
ProductProcurementControlID = procurementControlId;
}
public int ProductID { get; set; }
public string Title
{
get
{
if (titleBody != null)
{
if (TitleSuffix == null) { return titleBody; }
else { return titleBody + " (" + TitleSuffix + ")"; }
}
else
{
return null;
}
}
set
{
titleBody = value;
}
}
public string TitleSuffix { get; set; }
public int ProductCategoryID { get; set; }
public int? ProductCategorySubID { get; set; }
//public int? ProductImageID { get; set; }
public DateTime? ReleaseDate { get; set; }
public bool ReleaseDateIsSet
{
get { return ReleaseDate != null; }
}
public decimal? RecommendedRetailPrice { get; set; }
public decimal? MaxPrice { get; set; }
public string AmazonASIN { get; set; }
public string Manufacturer { get; set; }
public decimal? PackageWeightKilogram { get; set; }
public decimal? PackageDimensionHeightMeter { get; private set; }
public decimal? PackageDimensionWidthMeter { get; private set; }
public decimal? PackageDimensionLengthMeter { get; private set; }
public int? CatId { get; set; }
public int ProductProcurementControlID { get; set; }
public bool? ManualCompetativePriceUpdate { get; set; }
public bool? AmazonBuyBoxActive { get; set; }
public DateTime? AmazonBuyBoxActiveUpdated { get; set; }
public bool IsActive { get; set; }
public bool IsDraft { get; set; }
public DateTime RecordCreated { get; set; }
public DateTime RecordModified { get; set; }
public void SetPackageDimension (decimal heightMeter, decimal widthMeter, decimal lengthMeter)
{
if (heightMeter <= 0 || widthMeter <=0 || lengthMeter <= 0)
{
throw new Exception("Dimension must be greater than 0");
}
PackageDimensionHeightMeter = heightMeter;
PackageDimensionWidthMeter = widthMeter;
PackageDimensionLengthMeter = lengthMeter;
}
}
}

View File

@@ -8,74 +8,28 @@ namespace bnhtrade.Core.Model.Sku
{
public class Sku
{
private bool? isActive;
private int? conditionId;
private int? productId;
public int ConditionId
{
get { return conditionId.GetValueOrDefault(); }
set { conditionId = value; }
}
public bool ConditionIdIsSet
{
get { return conditionId != null; }
}
public string ConditionTitle
{
get;
set;
}
public bool ConditionTitleIsSet
{
get { return ConditionTitle != null; }
}
public int ProductId
{
get { return productId.GetValueOrDefault(); }
set { productId = value; }
}
public bool ProductIdIsSet
{
get { return productId != null; }
}
public string ProductTitle
{
get;
set;
}
public bool ProductTitleIsSet
{
get { return ProductTitle != null; }
}
public string SkuNumber
{
get;
set;
}
public bool SkuNumberIsSet
{
get { return SkuNumber != null; }
}
public string TaxCode
public Model.Product.ProductInfo ProductInfo
{
get;
set;
}
public bool TaxCodeIsSet
public Model.Sku.SkuConditionInfo ConditionInfo
{
get { return TaxCode != null; }
get;
set;
}
public Model.Account.TaxCodeInfo TaxCodeInfo
{
get;
set;
}
public string AmazonFNSKU
@@ -84,20 +38,10 @@ namespace bnhtrade.Core.Model.Sku
set;
}
public bool AmazonFNSKUIsSet
public bool? IsActive
{
get { return AmazonFNSKU != null; }
}
public bool IsActive
{
get { return (bool)isActive; }
set { isActive = value; }
}
public bool IsActiveIsSet
{
get { return isActive != null; }
get;
set;
}
}
}
}

View File

@@ -8,9 +8,7 @@ namespace bnhtrade.Core.Model.Sku
{
public class SkuConditionInfo
{
public int SkuConditionId { get; set; }
public string SkuConditionNumber { get; set; }
public string SkuConditionCode { get; set; }
public string TitleShort { get; set; }