shipthisapi-python 3.0.3__tar.gz → 3.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shipthisapi-python
3
- Version: 3.0.3
3
+ Version: 3.0.5
4
4
  Summary: ShipthisAPI async utility package
5
5
  Home-page: https://github.com/shipthisco/shipthisapi-python
6
6
  Author: Mayur Rawte
@@ -1,5 +1,5 @@
1
1
  # __variables__ with double-quoted values will be available in setup.py
2
- __version__ = "3.0.3"
2
+ __version__ = "3.0.5"
3
3
 
4
4
  from .shipthisapi import (
5
5
  ShipthisAPI,
@@ -321,14 +321,18 @@ class ShipthisAPI:
321
321
  params = {}
322
322
  if only_fields:
323
323
  params["only"] = only_fields
324
- return await self._make_request("GET", path, query_params=params if params else None)
324
+ return await self._make_request(
325
+ "GET", path, query_params=params if params else None
326
+ )
325
327
  else:
326
328
  params = {}
327
329
  if filters:
328
330
  params["query_filter_v2"] = json.dumps(filters)
329
331
  if only_fields:
330
332
  params["only"] = only_fields
331
- resp = await self._make_request("GET", f"incollection/{collection_name}", params)
333
+ resp = await self._make_request(
334
+ "GET", f"incollection/{collection_name}", params
335
+ )
332
336
  if isinstance(resp, dict) and resp.get("items"):
333
337
  return resp.get("items")[0]
334
338
  return None
@@ -378,7 +382,9 @@ class ShipthisAPI:
378
382
  if not meta:
379
383
  params["meta"] = "false"
380
384
 
381
- response = await self._make_request("GET", f"incollection/{collection_name}", params)
385
+ response = await self._make_request(
386
+ "GET", f"incollection/{collection_name}", params
387
+ )
382
388
 
383
389
  if isinstance(response, dict):
384
390
  return response.get("items", [])
@@ -416,13 +422,25 @@ class ShipthisAPI:
416
422
  )
417
423
 
418
424
  async def create_item(
419
- self, collection_name: str, data: Dict[str, Any]
425
+ self,
426
+ collection_name: str,
427
+ data: Dict[str, Any],
428
+ ignore_new_required: bool = False,
429
+ skip_sequence_if_exists: bool = False,
430
+ replicate_count: int = 0,
431
+ input_filters: Optional[Dict[str, Any]] = None,
432
+ action_op_data: Optional[Dict[str, Any]] = None,
420
433
  ) -> Dict[str, Any]:
421
- """Create a new item in a collection.
434
+ """Create a new item in a collection with all advanced Shipthis features.
422
435
 
423
436
  Args:
424
437
  collection_name: Name of the collection.
425
438
  data: Document data.
439
+ ignore_new_required: Ignore new required fields (default: False).
440
+ skip_sequence_if_exists: Skip sequence if exists (default: False).
441
+ replicate_count: Number of times to replicate the item (default: 0).
442
+ input_filters: Input filters (optional).
443
+ action_op_data: Action operation data (optional).
426
444
 
427
445
  Returns:
428
446
  Created document data.
@@ -430,10 +448,26 @@ class ShipthisAPI:
430
448
  Raises:
431
449
  ShipthisAPIError: If the request fails.
432
450
  """
451
+ params = {}
452
+ if replicate_count > 0:
453
+ params["replicate_count"] = min(replicate_count, 100)
454
+ if input_filters:
455
+ params["input_filters"] = json.dumps(input_filters)
456
+
457
+ request_payload = {
458
+ "reqbody": data,
459
+ "ignore_new_required": ignore_new_required,
460
+ "skip_sequence_if_exists": skip_sequence_if_exists,
461
+ }
462
+
463
+ if action_op_data:
464
+ request_payload["action_op_data"] = action_op_data
465
+
433
466
  resp = await self._make_request(
434
467
  "POST",
435
468
  f"incollection/{collection_name}",
436
- request_data={"reqbody": data},
469
+ query_params=params,
470
+ request_data=request_payload,
437
471
  )
438
472
  if isinstance(resp, dict) and resp.get("data"):
439
473
  return resp.get("data")
@@ -646,6 +680,7 @@ class ShipthisAPI:
646
680
  ShipthisAPIError: If the request fails.
647
681
  """
648
682
  import time
683
+
649
684
  if date is None:
650
685
  date = int(time.time() * 1000)
651
686
 
@@ -6,7 +6,7 @@ with open("README.md", "r") as fh:
6
6
 
7
7
  setuptools.setup(
8
8
  name='shipthisapi-python',
9
- version='3.0.3',
9
+ version='3.0.5',
10
10
  author="Mayur Rawte",
11
11
  author_email="mayur@shipthis.co",
12
12
  description="ShipthisAPI async utility package",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shipthisapi-python
3
- Version: 3.0.3
3
+ Version: 3.0.5
4
4
  Summary: ShipthisAPI async utility package
5
5
  Home-page: https://github.com/shipthisco/shipthisapi-python
6
6
  Author: Mayur Rawte