-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ListingTranslation.py
46 lines (40 loc) · 1.59 KB
/
ListingTranslation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from dataclasses import dataclass
from typing import Union
from etsy_python.v3.exceptions.RequestException import RequestException
from etsy_python.v3.models.Listing import (
CreateListingTranslationRequest,
UpdateListingTranslationRequest,
)
from etsy_python.v3.resources.Session import EtsyClient
from etsy_python.v3.resources.enums.Request import Method
from etsy_python.v3.resources.Response import Response
@dataclass
class ListingTranslationResource:
session: EtsyClient
def create_listing_translation(
self,
shop_id: int,
listing_id: int,
language: str,
listing_translation: CreateListingTranslationRequest,
) -> Union[Response, RequestException]:
endpoint = f"/shops/{shop_id}/listings/{listing_id}/translations/{language}"
return self.session.make_request(
endpoint, method=Method.POST, payload=listing_translation
)
def get_listing_translation(
self, shop_id: int, listing_id: int, language: str
) -> Union[Response, RequestException]:
endpoint = f"/shops/{shop_id}/listings/{listing_id}/translations/{language}"
return self.session.make_request(endpoint)
def update_listing_translation(
self,
shop_id: int,
listing_id: int,
language: str,
listing_translation: UpdateListingTranslationRequest,
) -> Union[Response, RequestException]:
endpoint = f"/shops/{shop_id}/listings/{listing_id}/translations/{language}"
return self.session.make_request(
endpoint, method=Method.PUT, payload=listing_translation
)