Skip to content

Commit 0caa5a0

Browse files
committed
feat: ebay
1 parent 108f838 commit 0caa5a0

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

api/services/ebay_publish_service.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ def _ebay_condition(app_condition: str) -> str:
6363
return _CONDITION_TO_EBAY.get(app_condition.strip(), "USED_EXCELLENT")
6464

6565

66+
def _ebay_condition_for_category(category_id: str, app_condition: str) -> str:
67+
"""
68+
Pour les catégories cartes TCG avec descripteur « état de la carte », eBay attend l’état article
69+
**4000 = USED_VERY_GOOD** (carte non gradée), pas **3000 = USED_EXCELLENT** — sinon erreur 25059
70+
à la publication. Voir condition-id-values (trading cards) dans la doc eBay.
71+
"""
72+
if category_id.strip() in _TCG_LEAF_CATEGORY_IDS:
73+
c = (app_condition or "").strip()
74+
if c in ("Poor", "Played"):
75+
return "USED_ACCEPTABLE"
76+
if c in ("Good", "Lightly Played"):
77+
return "USED_GOOD"
78+
return "USED_VERY_GOOD"
79+
return _ebay_condition(app_condition)
80+
81+
6682
def _card_condition_descriptor_value_id(app_condition: str) -> str:
6783
"""ID valeur du descripteur « Card Condition » (cartes non gradées), voir MIP eBay."""
6884
key = (app_condition or "").strip()
@@ -170,9 +186,11 @@ async def publish_article_to_ebay(
170186
price = _listing_price_eur(article)
171187
price_str = f"{price.quantize(Decimal('0.01'))}"
172188

189+
category_id = effective_ebay_category_id(ms).strip()
190+
173191
inv_payload: dict[str, Any] = {
174192
"availability": {"shipToLocationAvailability": {"quantity": 1}},
175-
"condition": _ebay_condition(article.condition),
193+
"condition": _ebay_condition_for_category(category_id, article.condition),
176194
"conditionDescription": html.escape((article.condition or "")[:1000]),
177195
"product": {
178196
"title": title,
@@ -182,7 +200,6 @@ async def publish_article_to_ebay(
182200
},
183201
}
184202

185-
category_id = effective_ebay_category_id(ms).strip()
186203
if category_id in _TCG_LEAF_CATEGORY_IDS:
187204
inv_payload["conditionDescriptors"] = [
188205
{

0 commit comments

Comments
 (0)