Skip to content

Commit 6fed3e1

Browse files
committed
Add MarketPlaceId to AmazonCredential
1 parent 4fc45ae commit 6fed3e1

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Source/FikaAmazonAPI/AmazonConnection.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,19 @@ private void ValidateCredentials(AmazonCredential Credentials)
157157
else if (string.IsNullOrEmpty(Credentials.RefreshToken))
158158
throw new AmazonInvalidInputException($"InvalidInput, RefreshToken cannot be empty!");
159159
else if (Credentials.MarketPlace == null)
160-
throw new AmazonInvalidInputException($"InvalidInput, MarketPlace cannot be null!");
160+
{
161+
if (string.IsNullOrEmpty(Credentials.MarketPlaceID))
162+
{
163+
throw new AmazonInvalidInputException($"InvalidInput, MarketPlace or MarketPlaceID cannot be null for both!");
164+
}
165+
else
166+
{
167+
Credentials.MarketPlace = MarketPlace.GetMarketPlaceByID(Credentials.MarketPlaceID);
168+
}
169+
}
170+
161171
}
162172
public MarketPlace GetCurrentMarketplace { get { return Credentials.MarketPlace; } }
173+
public string GetCurrentSellerID { get { return Credentials.SellerID; } }
163174
}
164175
}

Source/FikaAmazonAPI/AmazonCredential.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ public class AmazonCredential
2121
public int MaxThrottledRetryCount { get; set; } = 3;
2222
public ShippingBusiness? ShippingBusiness { get; set; }
2323
public bool IsDebugMode { get; set; }
24+
public string MarketPlaceID { get; set; }
25+
public string SellerID { get; set; }
2426

2527
public AmazonCredential()
2628
{
2729
CacheTokenData = new CacheTokenData();
2830
}
29-
public AmazonCredential(string AccessKey, string SecretKey, string RoleArn, string ClientId, string ClientSecret,string RefreshToken)
31+
public AmazonCredential(string AccessKey, string SecretKey, string RoleArn, string ClientId, string ClientSecret, string RefreshToken)
3032
{
3133
this.AccessKey = AccessKey;
3234
this.SecretKey = SecretKey;

Source/FikaAmazonAPI/Utils/MarketPlace.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using FikaAmazonAPI.AmazonSpApiSDK.Models.Exceptions;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using static FikaAmazonAPI.ConstructFeed.BaseXML;
45

@@ -34,7 +35,11 @@ public static MarketPlace GetMarketPlaceByID(string id)
3435
//FarEast
3536
list.Add(Singapore); list.Add(Australia); list.Add(Japan);
3637

37-
return list.FirstOrDefault(a => a.ID == id);
38+
var marketpalce = list.FirstOrDefault(a => a.ID == id);
39+
if (marketpalce == null)
40+
throw new AmazonInvalidInputException($"InvalidInput, MarketPlace or MarketPlaceID cannot be null for both!");
41+
42+
return marketpalce;
3843
}
3944

4045
public static MarketPlace GetMarketplaceByCountryCode(string countryCode)

0 commit comments

Comments
 (0)