python-picnic-api2 1.3.0__tar.gz → 1.3.1__tar.gz

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.
Files changed (28) hide show
  1. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/PKG-INFO +1 -1
  2. python_picnic_api2-1.3.1/README.md +102 -0
  3. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/pyproject.toml +1 -1
  4. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/src/python_picnic_api2/client.py +1 -1
  5. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/tests/test_client.py +9 -1
  6. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/uv.lock +1 -1
  7. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.devcontainer/devcontainer.json +0 -0
  8. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.env.example +0 -0
  9. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  10. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  11. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.github/dependabot.yml +0 -0
  12. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.github/release.yml +0 -0
  13. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.github/workflows/ci.yaml +0 -0
  14. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.github/workflows/it.yaml +0 -0
  15. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.github/workflows/release.yml +0 -0
  16. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/.gitignore +0 -0
  17. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/LICENSE.md +0 -0
  18. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/README.rst +0 -0
  19. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/codecov.yml +0 -0
  20. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/integration_tests/__init__.py +0 -0
  21. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/integration_tests/test_client.py +0 -0
  22. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/integration_tests/test_helper.py +0 -0
  23. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/integration_tests/test_session.py +0 -0
  24. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/src/python_picnic_api2/__init__.py +0 -0
  25. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/src/python_picnic_api2/helper.py +0 -0
  26. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/src/python_picnic_api2/session.py +0 -0
  27. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/tests/__init__.py +0 -0
  28. {python_picnic_api2-1.3.0 → python_picnic_api2-1.3.1}/tests/test_session.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-picnic-api2
3
- Version: 1.3.0
3
+ Version: 1.3.1
4
4
  Project-URL: homepage, https://github.com/codesalatdev/python-picnic-api
5
5
  Project-URL: repository, https://github.com/codesalatdev/python-picnic-api
6
6
  Author-email: Mike Brink <mjh.brink@icloud.com>, CodeSalat <pypi@codesalat.dev>
@@ -0,0 +1,102 @@
1
+ # Python-Picnic-API
2
+
3
+ **This library is undergoing rapid changes as is the Picnic API itself. It is mainly intended for use within Home Assistant, but there are integration tests running regularly checking for failures in features not used bu the Home Assistant integration**
4
+
5
+ Fork of the Unofficial Python wrapper for the [Picnic](https://picnic.app) API. While not all API methods have been implemented yet, you'll find most of what you need to build a working application are available.
6
+
7
+ This library is not affiliated with Picnic and retrieves data from the endpoints of the mobile application. **Use at your own risk.**
8
+
9
+ ## Credits
10
+
11
+ A big thanks to @MikeBrink for building the first versions of this library.
12
+
13
+ @maartenpaul and @thijmen-j continously provided fixes that were then merged into this fork.
14
+
15
+ ## Getting started
16
+
17
+ The easiest way to install is directly from pip:
18
+
19
+ ```bash
20
+ $ pip install python-picnic-api2
21
+ ```
22
+
23
+ Then create a new instance of `PicnicAPI` and login using your credentials:
24
+
25
+ ```python
26
+ from python_picnic_api2 import PicnicAPI
27
+
28
+ picnic = PicnicAPI(username='username', password='password', country_code="NL")
29
+ ```
30
+
31
+ The country_code parameter defaults to `NL`, but you have to change it if you live in a different country than the Netherlands (ISO 3166-1 Alpha-2). This obviously only works for countries that picnic services.
32
+
33
+ ## Searching for an article
34
+
35
+ ```python
36
+ picnic.search('coffee')
37
+ ```
38
+
39
+ ```python
40
+ [{'items': [{'id': 's1019822', 'name': 'Lavazza Caffè Crema e Aroma Bohnen', 'decorators': [], 'display_price': 1799, 'image_id': 'aecbf7d3b018025ec78daf5a1099b6842a860a2e3faeceec777c13d708ce442c', 'max_count': 99, 'unit_quantity': '1kg', 'sole_article_id': None}, ... ]}]
41
+ ```
42
+
43
+ ## Get article by ID
44
+
45
+ ```python
46
+ picnic.get_article("s1019822")
47
+ ```
48
+ ```python
49
+ {'name': 'Lavazza Caffè Crema e Aroma Bohnen', 'id': 's1019822'}
50
+ ```
51
+
52
+ ## Get article by GTIN (EAN)
53
+ ```python
54
+ picnic.get_article_by_gtin("8000070025400")
55
+ ```
56
+ ```python
57
+ {'name': 'Lavazza Caffè Crema e Aroma Bohnen', 'id': 's1019822'}
58
+ ```
59
+
60
+ ## Check cart
61
+
62
+ ```python
63
+ picnic.get_cart()
64
+ ```
65
+
66
+ ```python
67
+ {'type': 'ORDER', 'id': 'shopping_cart', 'items': [{'type': 'ORDER_LINE', 'id': '1470', 'items': [{'type': 'ORDER_ARTICLE', 'id': 's1019822', 'name': 'Lavazza Caffè Crema e Aroma Bohnen',...
68
+ ```
69
+
70
+ ## Manipulating your cart
71
+ All of these methods will return the shopping cart.
72
+
73
+ ```python
74
+ # Add product with ID "s1019822" 2x
75
+ picnic.add_product("s1019822", 2)
76
+
77
+ # Remove product with ID "s1019822" 1x
78
+ picnic.remove_product("s1019822")
79
+
80
+ # Clear your cart
81
+ picnic.clear_cart()
82
+ ```
83
+
84
+ ## See upcoming deliveries
85
+
86
+ ```python
87
+ picnic.get_current_deliveries()
88
+ ```
89
+
90
+ ```python
91
+ [{'delivery_id': 'XXYYZZ', 'creation_time': '2025-04-28T08:08:41.666+02:00', 'slot': {'slot_id': 'XXYYZZ', 'hub_id': '...
92
+ ```
93
+
94
+ ## See available delivery slots
95
+
96
+ ```python
97
+ picnic.get_delivery_slots()
98
+ ```
99
+
100
+ ```python
101
+ {'delivery_slots': [{'slot_id': 'XXYYZZ', 'hub_id': 'YYY', 'fc_id': 'FCX', 'window_start': '2025-04-29T17:15:00.000+02:00', 'window_end': '2025-04-29T19:15:00.000+02:00'...
102
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-picnic-api2"
3
- version = "1.3.0"
3
+ version = "1.3.1"
4
4
  description = ""
5
5
  readme = "README.rst"
6
6
  license = {text = "Apache-2.0"}
@@ -114,7 +114,7 @@ class PicnicAPI:
114
114
  return None
115
115
 
116
116
  color_regex = re.compile(r"#\(#\d{6}\)")
117
- producer = re.sub(color_regex, "", str(article_details[1]["markdown"]))
117
+ producer = re.sub(color_regex, "", str(article_details[1].get("markdown", "")))
118
118
  article_name = re.sub(color_regex, "", str(article_details[0]["markdown"]))
119
119
 
120
120
  article = {"name": f"{producer} {article_name}", "id": article_id}
@@ -23,7 +23,8 @@ class TestClient(unittest.TestCase):
23
23
  return self.json_data
24
24
 
25
25
  def setUp(self) -> None:
26
- self.session_patcher = patch("python_picnic_api2.client.PicnicAPISession")
26
+ self.session_patcher = patch(
27
+ "python_picnic_api2.client.PicnicAPISession")
27
28
  self.session_mock = self.session_patcher.start()
28
29
  self.client = PicnicAPI(username="test@test.nl", password="test")
29
30
  self.expected_base_url = DEFAULT_URL.format("nl", "15")
@@ -106,6 +107,13 @@ class TestClient(unittest.TestCase):
106
107
  headers=PICNIC_HEADERS,
107
108
  )
108
109
 
110
+ def test_get_article(self):
111
+ self.client.get_article("p3f2qa")
112
+ self.session_mock().get.assert_called_with(
113
+ "https://storefront-prod.nl.picnicinternational.com/api/15/pages/product-details-page-root?id=p3f2qa",
114
+ headers=PICNIC_HEADERS,
115
+ )
116
+
109
117
  def test_get_article_by_gtin(self):
110
118
  self.client.get_article_by_gtin("123456789")
111
119
  self.session_mock().get.assert_called_with(
@@ -197,7 +197,7 @@ wheels = [
197
197
 
198
198
  [[package]]
199
199
  name = "python-picnic-api2"
200
- version = "1.3.0"
200
+ version = "1.3.1"
201
201
  source = { editable = "." }
202
202
  dependencies = [
203
203
  { name = "requests" },