branddrive-python-sdk 0.1.0__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.
Files changed (45) hide show
  1. branddrive/__init__.py +33 -0
  2. branddrive/client.py +134 -0
  3. branddrive/config.py +15 -0
  4. branddrive/dataclasses/__init__.py +118 -0
  5. branddrive/dataclasses/_utils.py +8 -0
  6. branddrive/dataclasses/customers.py +66 -0
  7. branddrive/dataclasses/expenses.py +155 -0
  8. branddrive/dataclasses/invoices.py +131 -0
  9. branddrive/dataclasses/payment_links.py +134 -0
  10. branddrive/dataclasses/pos.py +141 -0
  11. branddrive/dataclasses/products.py +166 -0
  12. branddrive/dataclasses/purchase_orders.py +141 -0
  13. branddrive/dataclasses/services.py +76 -0
  14. branddrive/dataclasses/vendors.py +48 -0
  15. branddrive/dataclasses/wallets.py +72 -0
  16. branddrive/exceptions.py +35 -0
  17. branddrive/protocols/__init__.py +43 -0
  18. branddrive/protocols/analytics.py +61 -0
  19. branddrive/protocols/customers.py +42 -0
  20. branddrive/protocols/expenses.py +69 -0
  21. branddrive/protocols/invoices.py +81 -0
  22. branddrive/protocols/payment_links.py +49 -0
  23. branddrive/protocols/pos.py +88 -0
  24. branddrive/protocols/products.py +150 -0
  25. branddrive/protocols/purchase_orders.py +68 -0
  26. branddrive/protocols/services.py +56 -0
  27. branddrive/protocols/vendors.py +39 -0
  28. branddrive/protocols/wallets.py +52 -0
  29. branddrive/resources/__init__.py +125 -0
  30. branddrive/resources/_utils.py +10 -0
  31. branddrive/resources/analytics.py +198 -0
  32. branddrive/resources/customers.py +194 -0
  33. branddrive/resources/expenses.py +209 -0
  34. branddrive/resources/invoices.py +268 -0
  35. branddrive/resources/payment_links.py +265 -0
  36. branddrive/resources/pos.py +353 -0
  37. branddrive/resources/products.py +612 -0
  38. branddrive/resources/purchase_orders.py +235 -0
  39. branddrive/resources/services.py +184 -0
  40. branddrive/resources/vendors.py +152 -0
  41. branddrive/resources/wallets.py +204 -0
  42. branddrive_python_sdk-0.1.0.dist-info/METADATA +132 -0
  43. branddrive_python_sdk-0.1.0.dist-info/RECORD +45 -0
  44. branddrive_python_sdk-0.1.0.dist-info/WHEEL +5 -0
  45. branddrive_python_sdk-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,265 @@
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ from typing import Any
5
+ from urllib.parse import quote
6
+
7
+ import httpx
8
+
9
+ from ..exceptions import handle_api_exception
10
+ from ..dataclasses.payment_links import (
11
+ PaymentLinkCategoryCreate,
12
+ PaymentLinkCategoryData,
13
+ PaymentLinkCreate,
14
+ PaymentLinkPayData,
15
+ PaymentLinkSubscriptionDuration,
16
+ PaymentLinkUpdate,
17
+ )
18
+
19
+
20
+ class _PaymentLinkResource:
21
+ def __init__(self, client: httpx.Client) -> None:
22
+ self.client = client
23
+
24
+ @staticmethod
25
+ def _validate_id(name: str, value: int) -> str:
26
+ if isinstance(value, bool) or not isinstance(value, int):
27
+ raise TypeError(f"{name} must be an integer")
28
+ if value < 1:
29
+ raise ValueError(f"{name} must be greater than 0")
30
+ return quote(str(value), safe="")
31
+
32
+ @staticmethod
33
+ def _validate_string(name: str, value: str) -> None:
34
+ if not isinstance(value, str):
35
+ raise TypeError(f"{name} must be a string")
36
+ if not value.strip():
37
+ raise ValueError(f"{name} must not be empty")
38
+
39
+ @staticmethod
40
+ def _validate_amount(amount: int | float) -> None:
41
+ if isinstance(amount, bool) or not isinstance(amount, (int, float)):
42
+ raise TypeError("amount must be a number")
43
+ if isinstance(amount, float) and not math.isfinite(amount):
44
+ raise ValueError("amount must be finite")
45
+ if amount <= 0:
46
+ raise ValueError("amount must be greater than 0")
47
+
48
+ @staticmethod
49
+ def _validate_subscription_duration(
50
+ duration: PaymentLinkSubscriptionDuration | None,
51
+ ) -> None:
52
+ allowed = {"MONTHLY", "YEARLY", "HOURLY", "DAILY"}
53
+ if duration is None:
54
+ return
55
+ if not isinstance(duration, str):
56
+ raise TypeError("sub_duration must be a string")
57
+ if duration not in allowed:
58
+ raise ValueError("sub_duration must be MONTHLY, YEARLY, HOURLY, or DAILY")
59
+
60
+ def _validate_category_data(self, category: PaymentLinkCategoryData) -> None:
61
+ if category.amount is not None:
62
+ self._validate_amount(category.amount)
63
+ if category.title is not None:
64
+ self._validate_string("category title", category.title)
65
+ if category.description is not None and not isinstance(
66
+ category.description,
67
+ str,
68
+ ):
69
+ raise TypeError("category description must be a string")
70
+ if category.id is not None:
71
+ self._validate_id("category_id", category.id)
72
+
73
+ def _handle_response(self, response: httpx.Response) -> dict[str, Any]:
74
+ if not response.is_success:
75
+ raise handle_api_exception(response)
76
+ return response.json()
77
+
78
+
79
+ class PaymentLinkCategory(_PaymentLinkResource):
80
+ def add_category(
81
+ self,
82
+ payment_link_id: int,
83
+ category_data: PaymentLinkCategoryCreate,
84
+ ) -> dict[str, Any]:
85
+ """Add a priced category to a payment link."""
86
+ payment_link_path_id = self._validate_id(
87
+ "payment_link_id",
88
+ payment_link_id,
89
+ )
90
+ self._validate_amount(category_data.amount)
91
+ self._validate_string("title", category_data.title)
92
+ if category_data.description is not None and not isinstance(
93
+ category_data.description,
94
+ str,
95
+ ):
96
+ raise TypeError("description must be a string")
97
+ response = self.client.request(
98
+ "POST",
99
+ f"/api/v1/payment-link/{payment_link_path_id}/category",
100
+ json=category_data.to_dict(),
101
+ )
102
+ return self._handle_response(response)
103
+
104
+ def remove_category(
105
+ self,
106
+ payment_link_id: int,
107
+ category_id: int,
108
+ ) -> dict[str, Any]:
109
+ """Remove a category from a payment link."""
110
+ payment_link_path_id = self._validate_id(
111
+ "payment_link_id",
112
+ payment_link_id,
113
+ )
114
+ category_path_id = self._validate_id("category_id", category_id)
115
+ response = self.client.request(
116
+ "DELETE",
117
+ f"/api/v1/payment-link/{payment_link_path_id}/category/{category_path_id}",
118
+ )
119
+ return self._handle_response(response)
120
+
121
+
122
+ class PaymentLink(_PaymentLinkResource):
123
+ def __init__(self, client: httpx.Client) -> None:
124
+ super().__init__(client)
125
+ self.categories = PaymentLinkCategory(client)
126
+
127
+ def create_payment_link(
128
+ self,
129
+ payment_link_data: PaymentLinkCreate,
130
+ ) -> dict[str, Any]:
131
+ """Create a payment link."""
132
+ for name, value in (
133
+ ("description", payment_link_data.description),
134
+ ("title", payment_link_data.title),
135
+ ("payment_link_path", payment_link_data.payment_link_path),
136
+ ("categories", payment_link_data.categories),
137
+ ):
138
+ self._validate_string(name, value)
139
+ if not isinstance(payment_link_data.is_amount_fixed, bool):
140
+ raise TypeError("is_amount_fixed must be a boolean")
141
+ if payment_link_data.is_sub is not None and not isinstance(
142
+ payment_link_data.is_sub,
143
+ bool,
144
+ ):
145
+ raise TypeError("is_sub must be a boolean")
146
+ if payment_link_data.sub_interval is not None:
147
+ self._validate_id("sub_interval", payment_link_data.sub_interval)
148
+ self._validate_subscription_duration(payment_link_data.sub_duration)
149
+ for name, value in (
150
+ ("redirect_url", payment_link_data.redirect_url),
151
+ ("bg_image", payment_link_data.bg_image),
152
+ ):
153
+ if value is not None and not isinstance(value, str):
154
+ raise TypeError(f"{name} must be a string")
155
+ response = self.client.request(
156
+ "POST",
157
+ "/api/v1/payment-link",
158
+ json=payment_link_data.to_dict(),
159
+ )
160
+ return self._handle_response(response)
161
+
162
+ def list_payment_links(self) -> dict[str, Any]:
163
+ """Get all payment links."""
164
+ response = self.client.request(
165
+ "GET",
166
+ "/api/v1/payment-link",
167
+ )
168
+ return self._handle_response(response)
169
+
170
+ def list_payments(self) -> dict[str, Any]:
171
+ """Get all payments made through payment links."""
172
+ response = self.client.request(
173
+ "GET",
174
+ "/api/v1/payment-link/payment",
175
+ )
176
+ return self._handle_response(response)
177
+
178
+ def pay(self, payment_data: PaymentLinkPayData) -> dict[str, Any]:
179
+ """Submit a payment through a payment link."""
180
+ for name, value in (
181
+ ("payment_link_code", payment_data.payment_link_code),
182
+ ("customer_email", payment_data.customer_email),
183
+ ("first_name", payment_data.first_name),
184
+ ("last_name", payment_data.last_name),
185
+ ("phone_number", payment_data.phone_number),
186
+ ):
187
+ self._validate_string(name, value)
188
+ self._validate_amount(payment_data.amount)
189
+ response = self.client.request(
190
+ "POST",
191
+ "/api/v1/payment-link/pay",
192
+ json=payment_data.to_dict(),
193
+ )
194
+ return self._handle_response(response)
195
+
196
+ def validate_payment_link(self, code: str) -> dict[str, Any]:
197
+ """Validate a payment link using its secret code."""
198
+ self._validate_string("code", code)
199
+ code_path = quote(code, safe="")
200
+ response = self.client.request(
201
+ "GET",
202
+ f"/api/v1/payment-link/{code_path}/validate",
203
+ )
204
+ return self._handle_response(response)
205
+
206
+ def update_payment_link(
207
+ self,
208
+ payment_link_id: int,
209
+ payment_link_data: PaymentLinkUpdate,
210
+ ) -> dict[str, Any]:
211
+ """Update a payment link."""
212
+ payment_link_path_id = self._validate_id(
213
+ "payment_link_id",
214
+ payment_link_id,
215
+ )
216
+ payload = payment_link_data.to_dict()
217
+ if not payload:
218
+ raise ValueError("At least one payment link field must be provided")
219
+ for name, value in (
220
+ ("description", payment_link_data.description),
221
+ ("title", payment_link_data.title),
222
+ ("payment_link_path", payment_link_data.payment_link_path),
223
+ ):
224
+ if value is not None:
225
+ self._validate_string(name, value)
226
+ for name, value in (
227
+ ("redirect_url", payment_link_data.redirect_url),
228
+ ("bg_image", payment_link_data.bg_image),
229
+ ):
230
+ if value is not None and not isinstance(value, str):
231
+ raise TypeError(f"{name} must be a string")
232
+ if payment_link_data.sub_interval is not None:
233
+ self._validate_id("sub_interval", payment_link_data.sub_interval)
234
+ self._validate_subscription_duration(payment_link_data.sub_duration)
235
+ if payment_link_data.is_amount_fixed is not None and not isinstance(
236
+ payment_link_data.is_amount_fixed,
237
+ bool,
238
+ ):
239
+ raise TypeError("is_amount_fixed must be a boolean")
240
+ if payment_link_data.is_sub is not None and not isinstance(
241
+ payment_link_data.is_sub,
242
+ bool,
243
+ ):
244
+ raise TypeError("is_sub must be a boolean")
245
+ if payment_link_data.categories is not None:
246
+ for category in payment_link_data.categories:
247
+ self._validate_category_data(category)
248
+ response = self.client.request(
249
+ "PATCH",
250
+ f"/api/v1/payment-link/{payment_link_path_id}",
251
+ json=payload,
252
+ )
253
+ return self._handle_response(response)
254
+
255
+ def delete_payment_link(self, payment_link_id: int) -> dict[str, Any]:
256
+ """Delete a payment link."""
257
+ payment_link_path_id = self._validate_id(
258
+ "payment_link_id",
259
+ payment_link_id,
260
+ )
261
+ response = self.client.request(
262
+ "DELETE",
263
+ f"/api/v1/payment-link/{payment_link_path_id}",
264
+ )
265
+ return self._handle_response(response)
@@ -0,0 +1,353 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Iterable, Optional
4
+ from urllib.parse import quote
5
+
6
+ import httpx
7
+
8
+ from ..exceptions import handle_api_exception
9
+ from ..dataclasses.pos import (
10
+ POSCreate,
11
+ POSPaymentProcurement,
12
+ POSProductProcurement,
13
+ POSProcurementUpdate,
14
+ POSVoidData,
15
+ PosUpdate,
16
+ )
17
+
18
+ class POS:
19
+ def __init__(self, client: httpx.Client) -> None:
20
+ self.client = client
21
+
22
+ def _handle_response(self, response: httpx.Response) -> dict[str, Any]:
23
+ if not response.is_success:
24
+ raise handle_api_exception(response)
25
+ return response.json()
26
+
27
+ @staticmethod
28
+ def _validate_id(name: str, value: int) -> str:
29
+ if isinstance(value, bool) or not isinstance(value, int):
30
+ raise TypeError(f"{name} must be an integer")
31
+ if value < 1:
32
+ raise ValueError(f"{name} must be greater than 0")
33
+ return quote(str(value), safe="")
34
+
35
+ @classmethod
36
+ def _serialize_procurements(
37
+ cls,
38
+ procurements: Optional[Iterable[POSPaymentProcurement]],
39
+ ) -> list[dict[str, Any]]:
40
+ return [
41
+ procurement.to_dict()
42
+ for procurement in procurements or ()
43
+ ]
44
+
45
+ @classmethod
46
+ def _serialize_order_procurements(
47
+ cls,
48
+ procurements: Iterable[POSProductProcurement],
49
+ ) -> list[dict[str, int]]:
50
+ serialized = []
51
+ for procurement in procurements:
52
+ if isinstance(procurement.quantity, bool) or not isinstance(
53
+ procurement.quantity, int
54
+ ):
55
+ raise TypeError("quantity must be an integer")
56
+ if procurement.quantity < 1:
57
+ raise ValueError("quantity must be greater than 0")
58
+
59
+ for name, value in (
60
+ ("product_id", procurement.product_id),
61
+ ("service_id", procurement.service_id),
62
+ ):
63
+ if value is not None:
64
+ cls._validate_id(name, value)
65
+ serialized.append(procurement.to_dict())
66
+ return serialized
67
+
68
+ def create_pos(self, pos_data: POSCreate) -> dict[str, Any]:
69
+ """Create a point-of-sale order."""
70
+ for name, value in (
71
+ ("customer_id", pos_data.customer_id),
72
+ ("branch_id", pos_data.branch_id),
73
+ ("table_id", pos_data.table_id),
74
+ ):
75
+ if value is not None:
76
+ self._validate_id(name, value)
77
+
78
+ response = self.client.request(
79
+ "POST",
80
+ "/api/v1/pos",
81
+ json=pos_data.to_dict(),
82
+ )
83
+ return self._handle_response(response)
84
+
85
+ def add_payment(
86
+ self,
87
+ pos_id: int,
88
+ procurements: Optional[Iterable[POSPaymentProcurement]] = None,
89
+ ) -> dict[str, Any]:
90
+ """Add payment procurement entries to a POS order."""
91
+ pos_path_id = self._validate_id("pos_id", pos_id)
92
+ response = self.client.request(
93
+ "POST",
94
+ f"/api/v1/pos/{pos_path_id}/payment",
95
+ json={"procurements": self._serialize_procurements(procurements)},
96
+ )
97
+ return self._handle_response(response)
98
+
99
+ def add_service_procurement(
100
+ self,
101
+ pos_id: int,
102
+ procurements: Iterable[POSProductProcurement],
103
+ ) -> dict[str, Any]:
104
+ """Add service procurements to an existing POS order."""
105
+ pos_path_id = self._validate_id("pos_id", pos_id)
106
+ payload = self._serialize_order_procurements(procurements)
107
+ response = self.client.request(
108
+ "POST",
109
+ f"/api/v1/pos/{pos_path_id}/procurement",
110
+ json={"procurements": payload},
111
+ )
112
+ return self._handle_response(response)
113
+
114
+ def add_product_procurement(
115
+ self,
116
+ pos_id: int,
117
+ procurements: Iterable[POSProductProcurement],
118
+ ) -> dict[str, Any]:
119
+ """Add product procurements to an existing POS order."""
120
+ return self.add_service_procurement(pos_id, procurements)
121
+
122
+ def send_to_kitchen(self, pos_id: int) -> dict[str, Any]:
123
+ """Send a POS order's procurements to the kitchen."""
124
+ self._validate_id("pos_id", pos_id)
125
+ response = self.client.request(
126
+ "POST",
127
+ "/api/v1/pos/kitchen",
128
+ json={"posId": pos_id},
129
+ )
130
+ return self._handle_response(response)
131
+
132
+ def list_pos(
133
+ self,
134
+ offset: int = 0,
135
+ limit: int = 10,
136
+ branch_id: Optional[int] = None,
137
+ type: str = "closed",
138
+ ) -> dict[str, Any]:
139
+ """List POS orders with pagination and optional branch filtering."""
140
+ for name, value in (("offset", offset), ("limit", limit)):
141
+ if isinstance(value, bool) or not isinstance(value, int):
142
+ raise TypeError(f"{name} must be an integer")
143
+ if offset < 0:
144
+ raise ValueError("offset must be greater than or equal to 0")
145
+ if limit < 1:
146
+ raise ValueError("limit must be greater than 0")
147
+ if branch_id is not None:
148
+ self._validate_id("branch_id", branch_id)
149
+ if not isinstance(type, str) or not type:
150
+ raise ValueError("type must be a non-empty string")
151
+
152
+ params: dict[str, Any] = {
153
+ "offset": offset,
154
+ "type": type,
155
+ "limit": limit,
156
+ }
157
+ if branch_id is not None:
158
+ params["branchId"] = branch_id
159
+
160
+ response = self.client.request(
161
+ "GET",
162
+ "/api/v1/pos",
163
+ params=params,
164
+ )
165
+ return self._handle_response(response)
166
+
167
+ def retrieve_pos(
168
+ self,
169
+ pos_id: Optional[int] = None,
170
+ customer_name: Optional[str] = None,
171
+ ) -> dict[str, Any]:
172
+ """Retrieve a POS order by its ID or customer name."""
173
+ if (pos_id is None) == (customer_name is None):
174
+ raise ValueError("Provide exactly one of pos_id or customer_name")
175
+
176
+ params: dict[str, int | str] = {}
177
+ if pos_id is not None:
178
+ self._validate_id("pos_id", pos_id)
179
+ params["posId"] = pos_id
180
+ if customer_name is not None:
181
+ if not isinstance(customer_name, str) or not customer_name.strip():
182
+ raise ValueError("customer_name must be a non-empty string")
183
+ params["custName"] = customer_name
184
+
185
+ response = self.client.request(
186
+ "GET",
187
+ "/api/v1/pos/getBy",
188
+ params=params,
189
+ )
190
+ return self._handle_response(response)
191
+
192
+ def customer_view(self, pos_id: int) -> dict[str, Any]:
193
+ """Get the customer-facing view of a POS order."""
194
+ pos_path_id = self._validate_id("pos_id", pos_id)
195
+ response = self.client.request(
196
+ "GET",
197
+ f"/api/v1/pos/{pos_path_id}/customer/view",
198
+ )
199
+ return self._handle_response(response)
200
+
201
+ def kitchen_list(
202
+ self,
203
+ start_date: Optional[str] = None,
204
+ end_date: Optional[str] = None,
205
+ search: Optional[str] = None,
206
+ ) -> dict[str, Any]:
207
+ """Get kitchen orders, optionally filtered by date and search text."""
208
+ payload: dict[str, str] = {}
209
+ for name, value in (
210
+ ("start_date", start_date),
211
+ ("end_date", end_date),
212
+ ("search", search),
213
+ ):
214
+ if value is not None:
215
+ if not isinstance(value, str):
216
+ raise TypeError(f"{name} must be a string")
217
+ if value:
218
+ api_name = {
219
+ "start_date": "startDate",
220
+ "end_date": "endDate",
221
+ "search": "search",
222
+ }[name]
223
+ payload[api_name] = value
224
+
225
+ response = self.client.request(
226
+ "GET",
227
+ "/api/v1/pos/kitchen",
228
+ json=payload,
229
+ )
230
+ return self._handle_response(response)
231
+
232
+ def update_pos(self, pos_id: int, pos_data: PosUpdate) -> dict[str, Any]:
233
+ """Update a POS order."""
234
+ pos_path_id = self._validate_id("pos_id", pos_id)
235
+ for name, value in (
236
+ ("customer_id", pos_data.customer_id),
237
+ ("branch_id", pos_data.branch_id),
238
+ ("table_id", pos_data.table_id),
239
+ ):
240
+ if value is not None:
241
+ self._validate_id(name, value)
242
+ payload = pos_data.to_dict()
243
+ if not payload:
244
+ raise ValueError("At least one POS field must be provided")
245
+
246
+ response = self.client.request(
247
+ "PATCH",
248
+ f"/api/v1/pos/{pos_path_id}",
249
+ json=payload,
250
+ )
251
+ return self._handle_response(response)
252
+
253
+ def void_pos(
254
+ self,
255
+ pos_id: int,
256
+ pos_data: Optional[POSVoidData] = None,
257
+ ) -> dict[str, Any]:
258
+ """Void a POS order."""
259
+ pos_path_id = self._validate_id("pos_id", pos_id)
260
+ payload = pos_data.to_dict() if pos_data is not None else {}
261
+ if pos_data is not None and pos_data.procurements is not None:
262
+ payload['procurements'] = self._serialize_procurements(pos_data.procurements)
263
+
264
+ for name, key in (
265
+ ("customer_id", "customerId"),
266
+ ("branch_id", "branchId"),
267
+ ("table_id", "tableId"),
268
+ ):
269
+ value = payload.get(key)
270
+ if value is not None:
271
+ self._validate_id(name, value)
272
+
273
+ response = self.client.request(
274
+ "PATCH",
275
+ f"/api/v1/pos/{pos_path_id}/void",
276
+ json=payload,
277
+ )
278
+ return self._handle_response(response)
279
+
280
+ def update_procurement(
281
+ self,
282
+ procurement_id: int,
283
+ procurement_data: POSProcurementUpdate,
284
+ ) -> dict[str, Any]:
285
+ """Update the quantity of a POS procurement."""
286
+ procurement_path_id = self._validate_id(
287
+ "procurement_id",
288
+ procurement_id,
289
+ )
290
+ quantity = procurement_data.quantity
291
+ if isinstance(quantity, bool) or not isinstance(quantity, int):
292
+ raise TypeError("quantity must be an integer")
293
+ if quantity < 1:
294
+ raise ValueError("quantity must be greater than 0")
295
+
296
+ response = self.client.request(
297
+ "PATCH",
298
+ f"/api/v1/pos/procurement/{procurement_path_id}",
299
+ json=procurement_data.to_dict(),
300
+ )
301
+ return self._handle_response(response)
302
+
303
+ def toggle_kitchen(self, pos_id: int, procurement_id: int) -> dict[str, Any]:
304
+ """Toggle the kitchen-ready state for a POS procurement."""
305
+ pos_path_id = self._validate_id("pos_id", pos_id)
306
+ procurement_path_id = self._validate_id(
307
+ "procurement_id",
308
+ procurement_id,
309
+ )
310
+ response = self.client.request(
311
+ "PATCH",
312
+ f"/api/v1/pos/{pos_path_id}/procurement/{procurement_path_id}/kitchen/toggle",
313
+ )
314
+ return self._handle_response(response)
315
+
316
+ def delete_pos(self, pos_ids: list[int]) -> dict[str, Any]:
317
+ """Delete multiple POS orders."""
318
+ self._validate_ids("pos_ids", pos_ids)
319
+ response = self.client.request(
320
+ "DELETE",
321
+ "/api/v1/pos",
322
+ json={"posIds": pos_ids},
323
+ )
324
+ return self._handle_response(response)
325
+
326
+ def delete_procurements(self, procurement_ids: list[int]) -> dict[str, Any]:
327
+ """Delete multiple POS procurements."""
328
+ self._validate_ids("procurement_ids", procurement_ids)
329
+ response = self.client.request(
330
+ "DELETE",
331
+ "/api/v1/pos/procurement",
332
+ json={"procurementIds": procurement_ids},
333
+ )
334
+ return self._handle_response(response)
335
+
336
+ def delete_payment(self, pos_id: int, payment_id: int) -> dict[str, Any]:
337
+ """Delete a payment from a POS order."""
338
+ pos_path_id = self._validate_id("pos_id", pos_id)
339
+ payment_path_id = self._validate_id("payment_id", payment_id)
340
+ response = self.client.request(
341
+ "DELETE",
342
+ f"/api/v1/pos/{pos_path_id}/payment/{payment_path_id}",
343
+ )
344
+ return self._handle_response(response)
345
+
346
+ @classmethod
347
+ def _validate_ids(cls, name: str, values: list[int]) -> None:
348
+ if not isinstance(values, list):
349
+ raise TypeError(f"{name} must be a list")
350
+ if not values:
351
+ raise ValueError(f"{name} cannot be empty")
352
+ for value in values:
353
+ cls._validate_id(name[:-1], value)