etsy-python 1.2.3__py3-none-any.whl → 1.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
etsy_python/_version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Version information for etsy-python package."""
2
2
 
3
- __version__ = "1.2.3"
3
+ __version__ = "1.2.4"
@@ -1,6 +1,6 @@
1
1
  import warnings
2
2
  from enum import Enum
3
- from typing import Any, Dict, List, Optional
3
+ from typing import Any, Dict, Iterable, List, Optional
4
4
 
5
5
 
6
6
  def warn_removed_legacy_param(operation_id: str) -> None:
@@ -25,6 +25,21 @@ def warn_removed_legacy_param(operation_id: str) -> None:
25
25
  )
26
26
 
27
27
 
28
+ def join_ids(name: str, ids: Iterable[Any]) -> str:
29
+ """Join a required list of IDs into Etsy's comma-separated query value.
30
+
31
+ Raises ``TypeError`` for a string (iterating it would split the ID into
32
+ characters) and ``ValueError`` when no IDs are given, so a request Etsy
33
+ would reject is caught before it is sent.
34
+ """
35
+ if isinstance(ids, (str, bytes)):
36
+ raise TypeError(f"{name} must be a list of IDs, not a string")
37
+ joined = ",".join(map(str, ids)) if ids is not None else ""
38
+ if not joined:
39
+ raise ValueError(f"{name} is required and must contain at least one ID")
40
+ return joined
41
+
42
+
28
43
  def generate_get_uri(uri: str, params: Optional[Dict[str, Any]] = None) -> str:
29
44
  if not params:
30
45
  return uri
@@ -2,7 +2,7 @@ import warnings
2
2
  from dataclasses import dataclass
3
3
  from typing import Optional, List, Dict, Any, Union
4
4
 
5
- from etsy_python.v3.common.Utils import warn_removed_legacy_param
5
+ from etsy_python.v3.common.Utils import join_ids, warn_removed_legacy_param
6
6
  from etsy_python.v3.enums.Listing import Includes, State, SortOn, SortOrder
7
7
  from etsy_python.v3.exceptions.RequestException import RequestException
8
8
  from etsy_python.v3.models.Listing import (
@@ -150,7 +150,7 @@ class ListingResource:
150
150
  ) -> Union[Response, RequestException]:
151
151
  endpoint = "/listings/batch"
152
152
  query_params: Dict[str, Any] = {
153
- "listing_ids": ",".join(list(map(str, listing_ids))),
153
+ "listing_ids": join_ids("listing_ids", listing_ids),
154
154
  "includes": ",".join(list(map(lambda inc: inc.value, includes)))
155
155
  if includes is not None
156
156
  else None,
@@ -179,7 +179,7 @@ class ListingResource:
179
179
  ) -> Union[Response, RequestException]:
180
180
  endpoint = "/listings/batch/inventory"
181
181
  query_params: Dict[str, Any] = {
182
- "listing_ids": ",".join(list(map(str, listing_ids))),
182
+ "listing_ids": join_ids("listing_ids", listing_ids),
183
183
  }
184
184
  return self.session.make_request(endpoint, query_params=query_params)
185
185
 
@@ -188,7 +188,7 @@ class ListingResource:
188
188
  ) -> Union[Response, RequestException]:
189
189
  endpoint = "/listings/batch/shipping"
190
190
  query_params: Dict[str, Any] = {
191
- "listing_ids": ",".join(list(map(str, listing_ids))),
191
+ "listing_ids": join_ids("listing_ids", listing_ids),
192
192
  }
193
193
  return self.session.make_request(endpoint, query_params=query_params)
194
194
 
@@ -260,18 +260,21 @@ class ListingResource:
260
260
  def get_listings_by_shop_section_id(
261
261
  self,
262
262
  shop_id: int,
263
- shop_section_ids: Optional[List[int]] = None,
263
+ shop_section_ids: List[int],
264
264
  limit: int = 25,
265
265
  offset: int = 0,
266
266
  sort_on: SortOn = SortOn.CREATED,
267
267
  sort_order: SortOrder = SortOrder.DESC,
268
268
  legacy: Optional[bool] = None,
269
269
  ) -> Union[Response, RequestException]:
270
+ """Get listings in the given shop sections.
271
+
272
+ Raises ``ValueError`` if ``shop_section_ids`` is empty and
273
+ ``TypeError`` if it is a string, before any request is sent.
274
+ """
270
275
  endpoint = f"/shops/{shop_id}/shop-sections/listings"
271
276
  query_params: Dict[str, Any] = {
272
- "shop_section_ids": ",".join(list(map(str, shop_section_ids)))
273
- if shop_section_ids is not None
274
- else None,
277
+ "shop_section_ids": join_ids("shop_section_ids", shop_section_ids),
275
278
  "limit": limit,
276
279
  "offset": offset,
277
280
  "sort_on": sort_on.value,
@@ -2,6 +2,7 @@ import warnings
2
2
  from dataclasses import dataclass
3
3
  from typing import Union, Dict, Any, List
4
4
 
5
+ from etsy_python.v3.common.Utils import join_ids
5
6
  from etsy_python.v3.exceptions.RequestException import RequestException
6
7
  from etsy_python.v3.resources.Session import EtsyClient
7
8
  from etsy_python.v3.resources.Response import Response
@@ -16,7 +17,7 @@ class PaymentResource:
16
17
  ) -> Union[Response, RequestException]:
17
18
  endpoint = f"/shops/{shop_id}/payment-account/ledger-entries/payments"
18
19
  query_params: Dict[str, Any] = {
19
- "ledger_entry_ids": ",".join(list(map(str, ledger_entry_ids)))
20
+ "ledger_entry_ids": join_ids("ledger_entry_ids", ledger_entry_ids)
20
21
  }
21
22
  return self.session.make_request(endpoint, query_params=query_params)
22
23
 
@@ -42,5 +43,5 @@ class PaymentResource:
42
43
  self, shop_id: int, payment_ids: List[int]
43
44
  ) -> Union[Response, RequestException]:
44
45
  endpoint = f"/shops/{shop_id}/payments"
45
- query_params: Dict[str, Any] = {"payment_ids": ",".join(list(map(str, payment_ids)))}
46
+ query_params: Dict[str, Any] = {"payment_ids": join_ids("payment_ids", payment_ids)}
46
47
  return self.session.make_request(endpoint, query_params=query_params)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: etsy-python
3
- Version: 1.2.3
3
+ Version: 1.2.4
4
4
  Summary: Etsy API Client Library for Python
5
5
  Author: Amit Ray
6
6
  Author-email: mail@amitray.dev
@@ -1,11 +1,11 @@
1
1
  etsy_python/__init__.py,sha256=Xm1g_vbx8ePxmwQ6z-CAhz6_XNgJt7WYT8B5GdOQBcU,72
2
- etsy_python/_version.py,sha256=_nAucEp8K2gZ5Bj2MGk3ziiNts-4Vo7wpgHQi-JwH24,73
2
+ etsy_python/_version.py,sha256=nKWiuXri-g-Jp66p1fkuyXnHw-sKbV99BMHIVFfeA10,73
3
3
  etsy_python/v3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  etsy_python/v3/auth/OAuth.py,sha256=o4rZ1AoN_KvcoQOoBtW3wVgOOF0uJLjYPffuqrdX5ts,2239
5
5
  etsy_python/v3/auth/__init__.py,sha256=5qxAsOoBBneUIfPjmu0gwnd4lHNXebyvRr8V94zxzwA,29
6
6
  etsy_python/v3/common/Env.py,sha256=1CzXyv__9xC_BYAIXZr0ytRkSKG9tMwJ6qvkB5OjeIU,525
7
7
  etsy_python/v3/common/Request.py,sha256=mnhH-XUJbGUiMUFqoWUaClT_xyz3s4fJCZIULmm5lL0,452
8
- etsy_python/v3/common/Utils.py,sha256=53z1hU6gu3-0wh9bFhXhLIuYUGrdQO0cs42y250ZtFc,2941
8
+ etsy_python/v3/common/Utils.py,sha256=zjwBnPmxQSoz8D7hvOpg9QBLbU6JZPGT-g8YTmwF3SU,3579
9
9
  etsy_python/v3/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  etsy_python/v3/enums/HolidayPreferences.py,sha256=z7S6rxlTWPPADUJIaAIUJYtF9bqaePBTpmGw39mbnt4,1180
11
11
  etsy_python/v3/enums/Language.py,sha256=JFw3CdB-VU5tz-pTc9N9cfHDnHFV0V2d7Hx2F8xiKR4,186
@@ -32,7 +32,7 @@ etsy_python/v3/models/ShopReturnPolicy.py,sha256=1A2ePna6hfS2Je6m18nR9LV-x_DcAvr
32
32
  etsy_python/v3/models/Utils.py,sha256=B2AX2BaqFwdEjdB3miiWaMSelO4u64SV4aa7jE7T4eE,421
33
33
  etsy_python/v3/models/__init__.py,sha256=wqm5-ZHKOcHikjKYcY6xT-oJ1PPp9V7sNVxo0dz0oG4,1155
34
34
  etsy_python/v3/resources/HolidayPreferences.py,sha256=NvGJbetRKiaWS4Opea8Ujx6Ds5_AlmSu7K62xzdcjgE,1287
35
- etsy_python/v3/resources/Listing.py,sha256=80d5uxMU6_TjCdYrLSbwLEsW4Us65UNMHohQst13lLg,12184
35
+ etsy_python/v3/resources/Listing.py,sha256=wFbnrhfoGVXeOso49vNYv50N5gOMK-9E0GTTebAWe50,12313
36
36
  etsy_python/v3/resources/ListingFile.py,sha256=8o1y2vR5bKQA0RkNqUp0plznwA9V5F956S73cWqxF_M,1581
37
37
  etsy_python/v3/resources/ListingImage.py,sha256=ntDKL80h12q2GipI9xKxTD8GQGOSDRTuL2TguViEQBw,1520
38
38
  etsy_python/v3/resources/ListingInventory.py,sha256=x3TQx6t7lGDtuV7G7kKrIuYvCxaJmCsLGTP9MJrkOMw,2197
@@ -42,7 +42,7 @@ etsy_python/v3/resources/ListingTranslation.py,sha256=YPegknYGzxqbTqnp2kcngBT1Z7
42
42
  etsy_python/v3/resources/ListingVariationImages.py,sha256=29r4dy-_jFeSR_uc-eziETOOEE2jG80qOrQBCK4A9IU,1109
43
43
  etsy_python/v3/resources/ListingVideo.py,sha256=w_MKVfp87o5DvErZ8N2-0cmlyG2s6EdKyqwgJ4GvItE,2446
44
44
  etsy_python/v3/resources/Miscellaneous.py,sha256=XLPgdfj6-ozBI6cD9zztK1xHnGtOLA0SoTICWVTeBZo,743
45
- etsy_python/v3/resources/Payment.py,sha256=s5y6fQXB3nlmB4NvMNssvL35kWvEvuNL_kqmMwIjngk,1915
45
+ etsy_python/v3/resources/Payment.py,sha256=nLG1nAZermuupVROznqZ6zYyvwKUPnujwj06EOrQ9o0,1967
46
46
  etsy_python/v3/resources/PaymentLedgerEntry.py,sha256=-DZt586d3loa9lUeJIkXGVTdQQPT0SFmel7Pt_u4CoQ,1173
47
47
  etsy_python/v3/resources/ProcessingProfile.py,sha256=PAzgN-YABSrjAKnM6dT5rz0GuteAzWZNy7arQSo9ZbY,2417
48
48
  etsy_python/v3/resources/Receipt.py,sha256=YqM2jjtqhb9ffvBhfK3HxyADCoHgO7UUTweGa2JYOXM,3176
@@ -62,8 +62,8 @@ etsy_python/v3/resources/__init__.py,sha256=IN6luuFIavLVbARxzg585uPyEKDzsh9BzEGa
62
62
  etsy_python/v3/resources/enums/RateLimit.py,sha256=vqbXWjCYXIJz1rzrlB0KmHkBbTCzV4dJbnwa6Qw-7aI,237
63
63
  etsy_python/v3/resources/enums/Request.py,sha256=5uRdrCLC9Gu5N55D-YWZeBmcQD5aDNB2CRx321F3uII,179
64
64
  etsy_python/v3/resources/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
- etsy_python-1.2.3.dist-info/licenses/LICENSE,sha256=FlZBgDGu0cnkgWwW-N0xxiZ3GkySmgH3ejOK76Hr32I,1065
66
- etsy_python-1.2.3.dist-info/METADATA,sha256=MLPGyaanhS5NVcBsrAr34ByimhxM1rqtAyJhLK6PCp0,15985
67
- etsy_python-1.2.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
68
- etsy_python-1.2.3.dist-info/top_level.txt,sha256=VFIw33_p9_8pq81cULjVi_mpreBx64_crxZjmFbHlGY,12
69
- etsy_python-1.2.3.dist-info/RECORD,,
65
+ etsy_python-1.2.4.dist-info/licenses/LICENSE,sha256=FlZBgDGu0cnkgWwW-N0xxiZ3GkySmgH3ejOK76Hr32I,1065
66
+ etsy_python-1.2.4.dist-info/METADATA,sha256=2ycPMDDc7tjCXm1VCJWXrY2_PySEqN9n_QjFalCmnEo,15985
67
+ etsy_python-1.2.4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
68
+ etsy_python-1.2.4.dist-info/top_level.txt,sha256=VFIw33_p9_8pq81cULjVi_mpreBx64_crxZjmFbHlGY,12
69
+ etsy_python-1.2.4.dist-info/RECORD,,