mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-05-18 19:48:23 +00:00
Migration from Amazon MWS to Selling Partner API
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
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();
|
||||
try
|
||||
{
|
||||
credential = new FikaAmazonAPI.AmazonCredential();
|
||||
credential.AccessKey = ConfigurationManager.AppSettings["SpapiAccessKey"];
|
||||
credential.SecretKey = ConfigurationManager.AppSettings["SpapiSecretKey"];
|
||||
credential.RoleArn = ConfigurationManager.AppSettings["SpapiRoleArn"];
|
||||
credential.ClientId = ConfigurationManager.AppSettings["SpapiClientId"];
|
||||
credential.ClientSecret = ConfigurationManager.AppSettings["SpapiClientSecret"];
|
||||
credential.RefreshToken = ConfigurationManager.AppSettings["SpapiRefreshToken"];
|
||||
credential.MarketPlaceID = ConfigurationManager.AppSettings["SpapiMarketplaceId"];
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user