Files
bnhtrade/src/bnhtrade.Core/Data/Amazon/SellingPartnerAPI/SpApiConnection.cs
T
Bobbie Hodgetts 91ef9acc78 SP-API stock reconciliation
Amazon had depreciated a number of reports that were used for stock reconciliation. Application now uses the new fba ledger report to reconcile. It is currently untested, as this requires data from Amazon. Methods that require testing will return a 'NotImplementedException'.

Also, removed the depreciated ILMerge and replaced with ILRepack.

Plus much more tidying up, and improvements.
2024-05-07 08:24:00 +01:00

54 lines
2.1 KiB
C#

using FikaAmazonAPI;
using FikaAmazonAPI.Utils;
using FikaAmazonAPI.AmazonSpApiSDK.Models.Token;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static FikaAmazonAPI.AmazonSpApiSDK.Services.EnvironemntManager;
namespace bnhtrade.Core.Data.Amazon.SellingPartnerAPI
{
class SpApiConnection
{
public AmazonConnection Connection { get; private set; }
//public MarketPlace MarketPlace { get; private set; }
//public string MarketPlaceId { get; private set; }
public SpApiConnection()
{
InnitConnection();
}
private void InnitConnection()
{
// attempt to create credential object from app.local.config
var credential = new FikaAmazonAPI.AmazonCredential();
var config = new Config().GetConfiguration();
try
{
string dataSource = config.AppSettings.Settings["DbDataSource"].Value;
credential = new FikaAmazonAPI.AmazonCredential();
//credential.AccessKey = config.AppSettings.Settings["SpapiAccessKey"].Value;
//credential.SecretKey = config.AppSettings.Settings["SpapiSecretKey"].Value;
//credential.RoleArn = config.AppSettings.Settings["SpapiRoleArn"].Value;
credential.ClientId = config.AppSettings.Settings["SpapiClientId"].Value;
credential.ClientSecret = config.AppSettings.Settings["SpapiClientSecret"].Value;
credential.RefreshToken = config.AppSettings.Settings["SpapiRefreshToken"].Value;
credential.MarketPlaceID = config.AppSettings.Settings["SpapiMarketplaceId"].Value;
//credential.IsDebugMode = true;
credential.MaxThrottledRetryCount = 3;
}
catch (Exception ex)
{
throw new Exception("Unable to retirve Amazon SP API credentials: " + ex.Message);
}
this.Connection = new AmazonConnection(credential);
}
}
}