shipthisapi-python 1.2.0__py3-none-any.whl → 1.3.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.
@@ -1,62 +1,24 @@
1
- from typing import Dict, List
1
+ from typing import Dict
2
2
  import requests
3
3
  class ShipthisAPI:
4
4
  base_api_endpoint = 'https://api.shipthis.co/api/v3/'
5
5
 
6
- def __init__(self, organisation: str, x_api_key:str, user_type='employee', region_id: str=None, location_id: str=None) -> None:
6
+ def __init__(self, base_url: str, organisation: str, x_api_key:str, user_type='employee') -> None:
7
7
  self.x_api_key = x_api_key
8
8
  self.organisation_id = organisation
9
+ self.base_url = base_url
9
10
  self.user_type = user_type
10
- self.region_id = region_id
11
- self.location_id = location_id
12
-
13
-
14
- def set_region_location(self, region_id, location_id):
15
- self.region_id = region_id
16
- self.location_id = location_id
17
11
 
18
12
  def _make_request(self, method: str, path: str, query_params: str=None, request_data=None) -> None:
19
13
  headers = {
20
14
  "x-api-key": self.x_api_key,
21
- "organisation": self.organisation_id,
22
- "user_type": self.user_type,
23
- "location": 'new_york'
15
+ "organisation_id": self.organisation_id,
16
+ "user_type": self.user_type
24
17
  }
25
18
  resp = requests.request(method, self.base_api_endpoint + path, data=request_data or {}, headers=headers)
26
19
  if resp.status_code == 200:
27
- raw_response = resp.json()
28
- if raw_response.get("success"):
29
- return raw_response.get("data")
20
+ return resp.json
30
21
 
31
22
  def info(self) -> Dict:
32
23
  info_resp = self._make_request('GET', 'auth/info')
33
- return info_resp
34
-
35
-
36
-
37
- def get_one_item(self, collection_name: str, params=None) -> Dict:
38
- resp = self._make_request('GET', 'incollection/' + collection_name)
39
- if resp.get("items"):
40
- # return first elem
41
- return resp.get("items")[0]
42
-
43
- def get_list(self, collection_name: str, params=None) -> List[Dict]:
44
- resp = self._make_request('GET', 'incollection/' + collection_name)
45
- if resp.get("items"):
46
- return resp.get("items", [])
47
-
48
-
49
-
50
- def create_item(self, collection_name: str, data=None) -> Dict:
51
- resp = self._make_request('POST', 'incollection/' + collection_name, request_data={"reqbody": data})
52
- if resp.get("data"):
53
- return resp.get("data")
54
-
55
- def update_item(self, collection_name: str, object_id: str, updated_data=None) -> Dict:
56
- resp = self._make_request('PUT', 'incollection/' + collection_name + '/' + object_id, request_data={"reqbody": updated_data})
57
- if resp.get("data"):
58
- return resp.get("data")
59
-
60
- def delete_item(self, collection_name: str, object_id: str) -> Dict:
61
- resp = self._make_request('DELETE', 'incollection/' + collection_name + '/' + object_id)
62
- return resp
24
+ return info_resp
@@ -1,16 +1,21 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: shipthisapi-python
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: ShipthisAPI utility package
5
5
  Home-page: https://github.com/shipthisco/shipthisapi-python
6
6
  Author: Mayur Rawte
7
7
  Author-email: mayur@shipthis.co
8
- License: UNKNOWN
9
- Platform: UNKNOWN
10
8
  Classifier: Programming Language :: Python :: 3
11
9
  Classifier: License :: OSI Approved :: MIT License
12
10
  Classifier: Operating System :: OS Independent
13
11
  Description-Content-Type: text/markdown
12
+ Dynamic: author
13
+ Dynamic: author-email
14
+ Dynamic: classifier
15
+ Dynamic: description
16
+ Dynamic: description-content-type
17
+ Dynamic: home-page
18
+ Dynamic: summary
14
19
 
15
20
  # ShipthisAPI Python
16
21
 
@@ -60,6 +65,10 @@ print(shipthisapi.info())
60
65
 
61
66
  print(shipthisapi.get_list(collection_name='invoice'))
62
67
 
68
+ # Get all Sea list
69
+
70
+ print(shipthisapi.get_list(collection_name="sea_shipment", params={"count": 2}))
71
+
63
72
 
64
73
  ```
65
74
 
@@ -88,5 +97,3 @@ If you have any queries related to usage of the api please raise a issue [here](
88
97
 
89
98
 
90
99
 
91
-
92
-
@@ -0,0 +1,6 @@
1
+ ShipthisAPI/__init__.py,sha256=eEx4pJ9QtrqOUJqCNtp_u5GEehhUFSG_QpRCJNHOl2Q,93
2
+ ShipthisAPI/shipthisapi.py,sha256=pUQRZSEJph3eSQCf_UGqy3vv34pjNznRrBIckDi0NiI,933
3
+ shipthisapi_python-1.3.0.dist-info/METADATA,sha256=8ZRJ--KArPBQbW-XC1ItHOyJ-xb0qgvaZGtY1ekkix4,2155
4
+ shipthisapi_python-1.3.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
5
+ shipthisapi_python-1.3.0.dist-info/top_level.txt,sha256=35r4y5buufpRwYKMsKPB59GoDeEprokRcBpgf-PVEFg,12
6
+ shipthisapi_python-1.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,7 +0,0 @@
1
- ShipthisAPI/__init__.py,sha256=eEx4pJ9QtrqOUJqCNtp_u5GEehhUFSG_QpRCJNHOl2Q,93
2
- ShipthisAPI/shipthisapi.py,sha256=2sSUljAIxTrjhgqqs3BIXYbhk0gflQ7cy7sTxwfzctI,2503
3
- shipthisapi_python-1.2.0.dist-info/METADATA,sha256=WP5GaurQaGF3nSEx33bGGpuHXVM5gG-Iw_CvW2cHwJQ,1941
4
- shipthisapi_python-1.2.0.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
5
- shipthisapi_python-1.2.0.dist-info/entry_points.txt,sha256=eqGnTHtEVMYwfXVk1Z9MhC8O2N8wuqAbr0lisLmrkxs,20
6
- shipthisapi_python-1.2.0.dist-info/top_level.txt,sha256=35r4y5buufpRwYKMsKPB59GoDeEprokRcBpgf-PVEFg,12
7
- shipthisapi_python-1.2.0.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
-
3
-