spyreapi 0.0.4__tar.gz → 0.0.6__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.
- {spyreapi-0.0.4/src/spyreapi.egg-info → spyreapi-0.0.6}/PKG-INFO +1 -1
- {spyreapi-0.0.4 → spyreapi-0.0.6}/pyproject.toml +1 -1
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/client.py +11 -3
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/sales.py +20 -12
- {spyreapi-0.0.4 → spyreapi-0.0.6/src/spyreapi.egg-info}/PKG-INFO +1 -1
- {spyreapi-0.0.4 → spyreapi-0.0.6}/LICENSE +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/MANIFEST.in +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/README.md +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/setup.cfg +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/Exceptions.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/Models/__init__.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/Models/customers_models.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/Models/inventory_models.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/Models/sales_models.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/Models/shared_models.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/__init__.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/crm.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/customers.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/inventory.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/spire.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyre/utils.py +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyreapi.egg-info/SOURCES.txt +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyreapi.egg-info/dependency_links.txt +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyreapi.egg-info/requires.txt +0 -0
- {spyreapi-0.0.4 → spyreapi-0.0.6}/src/spyreapi.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spyreapi
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: A robust and extensible Python client for interacting with the [Spire Business Software API](https://developer.spiresystems.com/reference). This client provides an object-oriented interface to get, create, update, delete, query, filter, sort, and manage various Spire modules such as Sales Orders, Invoices, Inventory Items, and more.
|
|
5
5
|
Author-email: Sanjid Sharaf <sanjidsharaf1@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -2,7 +2,6 @@ import requests
|
|
|
2
2
|
from typing import TypeVar, Optional, Type, Generic, List, Union, Tuple, Dict, Any
|
|
3
3
|
from pydantic import BaseModel
|
|
4
4
|
import json
|
|
5
|
-
import urllib.parse
|
|
6
5
|
from requests.exceptions import HTTPError, ConnectionError, Timeout, RequestException
|
|
7
6
|
|
|
8
7
|
T = TypeVar('T', bound=BaseModel)
|
|
@@ -79,9 +78,14 @@ class SpireClient():
|
|
|
79
78
|
|
|
80
79
|
Returns:
|
|
81
80
|
dict: A dictionary containing the response status code, URL, content, and headers.
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
requests.exceptions.HTTPError: If the response contains an HTTP error status.
|
|
82
84
|
"""
|
|
85
|
+
|
|
83
86
|
url = f"{self.base_url}/{endpoint.lstrip('/')}"
|
|
84
87
|
response = self.session.post(url, data=data, json=json)
|
|
88
|
+
response.raise_for_status()
|
|
85
89
|
return self._handle_response(response)
|
|
86
90
|
|
|
87
91
|
def _put(self, endpoint, data=None, json=None):
|
|
@@ -94,11 +98,15 @@ class SpireClient():
|
|
|
94
98
|
json (dict, optional): JSON data to send in the body of the request.
|
|
95
99
|
|
|
96
100
|
Returns:
|
|
97
|
-
dict:
|
|
101
|
+
dict: The JSON-decoded response from the API.
|
|
102
|
+
|
|
103
|
+
Raises:
|
|
104
|
+
requests.exceptions.HTTPError: If the response contains an HTTP error status.
|
|
98
105
|
"""
|
|
99
106
|
url = f"{self.base_url}/{endpoint.lstrip('/')}"
|
|
100
107
|
response = self.session.put(url, data=data, json=json)
|
|
101
|
-
|
|
108
|
+
response.raise_for_status()
|
|
109
|
+
return response.json()
|
|
102
110
|
|
|
103
111
|
def _delete(self, endpoint):
|
|
104
112
|
"""
|
|
@@ -14,24 +14,32 @@ class OrdersClient():
|
|
|
14
14
|
self.client = client
|
|
15
15
|
self.endpoint = "sales/orders"
|
|
16
16
|
|
|
17
|
-
def get_sales_order(self,
|
|
17
|
+
def get_sales_order(self, id: int = None, order_number: str = None) -> "salesOrder":
|
|
18
18
|
"""
|
|
19
|
-
Retrieve a sales order by its ID.
|
|
20
|
-
|
|
21
|
-
Sends a GET request to the Spire API to fetch sales order data for the
|
|
22
|
-
specified ID. Wraps the result in a `salesOrder` instance, which
|
|
23
|
-
retains a reference to the client for further actions.
|
|
19
|
+
Retrieve a sales order by its ID or order number.
|
|
24
20
|
|
|
25
21
|
Args:
|
|
26
|
-
id (int): The ID of the sales order to retrieve.
|
|
22
|
+
id (int, optional): The ID of the sales order to retrieve.
|
|
23
|
+
order_number (str, optional): The order number of the sales order to retrieve.
|
|
27
24
|
|
|
28
25
|
Returns:
|
|
29
|
-
salesOrder: A `salesOrder` wrapper instance containing the retrieved
|
|
30
|
-
data and a reference to the client session.
|
|
31
|
-
"""
|
|
32
|
-
response = self.client._get(f"/{self.endpoint}/{str(id)}")
|
|
33
|
-
return salesOrder.from_json(response, self.client)
|
|
26
|
+
salesOrder: A `salesOrder` wrapper instance containing the retrieved data.
|
|
34
27
|
|
|
28
|
+
Raises:
|
|
29
|
+
ValueError: If neither id nor order_number is provided, or if no matching order is found.
|
|
30
|
+
"""
|
|
31
|
+
if id is not None:
|
|
32
|
+
response = self.client._get(f"/{self.endpoint}/{str(id)}")
|
|
33
|
+
return salesOrder.from_json(response, self.client)
|
|
34
|
+
elif order_number is not None:
|
|
35
|
+
orders = self.query_sales_orders(query=order_number)
|
|
36
|
+
for order in orders:
|
|
37
|
+
if getattr(order, "orderNo", None) == order_number:
|
|
38
|
+
return order
|
|
39
|
+
return None
|
|
40
|
+
else:
|
|
41
|
+
raise ValueError("Either 'id' or 'order_number' must be provided.")
|
|
42
|
+
|
|
35
43
|
def create_sales_order(self, sales_order : 'SalesOrder') -> 'salesOrder':
|
|
36
44
|
"""
|
|
37
45
|
Create a new sales order.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spyreapi
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: A robust and extensible Python client for interacting with the [Spire Business Software API](https://developer.spiresystems.com/reference). This client provides an object-oriented interface to get, create, update, delete, query, filter, sort, and manage various Spire modules such as Sales Orders, Invoices, Inventory Items, and more.
|
|
5
5
|
Author-email: Sanjid Sharaf <sanjidsharaf1@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|