fix: wire up auto Business Policy setup trigger on 20403 error
This commit is contained in:
@@ -20,7 +20,8 @@ public class EbayListingService
|
||||
private string? _fulfillmentPolicyId;
|
||||
private string? _paymentPolicyId;
|
||||
private string? _returnPolicyId;
|
||||
private string? _merchantLocationKey;
|
||||
|
||||
private bool _triedPolicySetup;
|
||||
|
||||
public EbayListingService(EbayAuthService auth, EbayCategoryService categoryService)
|
||||
{
|
||||
@@ -35,6 +36,7 @@ public class EbayListingService
|
||||
_paymentPolicyId = null;
|
||||
_returnPolicyId = null;
|
||||
_merchantLocationKey = null;
|
||||
_triedPolicySetup = false;
|
||||
}
|
||||
|
||||
public async Task<string> PostListingAsync(ListingDraft draft)
|
||||
@@ -92,8 +94,17 @@ public class EbayListingService
|
||||
var json = await res.Content.ReadAsStringAsync();
|
||||
|
||||
if (!res.IsSuccessStatusCode)
|
||||
{
|
||||
if (!_triedPolicySetup && json.Contains("20403"))
|
||||
{
|
||||
_triedPolicySetup = true;
|
||||
await SetupDefaultBusinessPoliciesAsync(token);
|
||||
await EnsurePoliciesAndLocationAsync(token, postcode);
|
||||
return;
|
||||
}
|
||||
throw new HttpRequestException(
|
||||
$"Could not fetch fulfillment policies ({(int)res.StatusCode}): {json}");
|
||||
}
|
||||
|
||||
var arr = JObject.Parse(json)["fulfillmentPolicies"] as JArray;
|
||||
_fulfillmentPolicyId = arr?.Count > 0
|
||||
@@ -519,3 +530,5 @@ public class EbayListingService
|
||||
return req;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user