Skip to content

Commit 108f838

Browse files
committed
sync ebay
1 parent 1a1b510 commit 108f838

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

api/services/ebay_publish_service.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@
3232
"Poor": "USED_ACCEPTABLE",
3333
}
3434

35+
# Catégories feuille « cartes à jouer / TCG » (descripteur d’état carte obligatoire — Metadata / MIP eBay).
36+
_TCG_LEAF_CATEGORY_IDS = frozenset({"183050", "183454", "261328"})
37+
# Descripteur « état de la carte » (cartes non gradées) — name + value IDs eBay.
38+
_CARD_CONDITION_DESCRIPTOR_NAME = "40001"
39+
_APP_TO_CARD_CONDITION_VALUE_ID: dict[str, str] = {
40+
"Mint": "400010",
41+
"Near Mint": "400010",
42+
"NM": "400010",
43+
"Excellent": "400011",
44+
"Good": "400012",
45+
"Lightly Played": "400015",
46+
"Played": "400016",
47+
"Poor": "400017",
48+
}
49+
3550
_MARKETPLACE_CURRENCY: dict[str, str] = {
3651
"EBAY_US": "USD",
3752
"EBAY_GB": "GBP",
@@ -48,6 +63,12 @@ def _ebay_condition(app_condition: str) -> str:
4863
return _CONDITION_TO_EBAY.get(app_condition.strip(), "USED_EXCELLENT")
4964

5065

66+
def _card_condition_descriptor_value_id(app_condition: str) -> str:
67+
"""ID valeur du descripteur « Card Condition » (cartes non gradées), voir MIP eBay."""
68+
key = (app_condition or "").strip()
69+
return _APP_TO_CARD_CONDITION_VALUE_ID.get(key, "400010")
70+
71+
5172
def _listing_price_eur(article: Article) -> Decimal:
5273
if article.sell_price is not None:
5374
return article.sell_price
@@ -161,6 +182,15 @@ async def publish_article_to_ebay(
161182
},
162183
}
163184

185+
category_id = effective_ebay_category_id(ms).strip()
186+
if category_id in _TCG_LEAF_CATEGORY_IDS:
187+
inv_payload["conditionDescriptors"] = [
188+
{
189+
"name": _CARD_CONDITION_DESCRIPTOR_NAME,
190+
"values": [_card_condition_descriptor_value_id(article.condition)],
191+
}
192+
]
193+
164194
headers = {
165195
"Authorization": f"Bearer {token}",
166196
"Content-Type": "application/json",

0 commit comments

Comments
 (0)