Customers¶
CustomerClient
¶
Source code in src/spyre/customers.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
create_customer(customer)
¶
Create a new customer.
Sends a POST request to the customer endpoint with the customer data to create a new customer record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
customer
|
Customer
|
The Customer object containing the data to be created. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Customer |
customer
|
The newly created Customer object returned by the API. |
Source code in src/spyre/customers.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
delete_customer(id)
¶
Delete a customer by ID.
Sends a DELETE request to the customer endpoint. Returns True if deletion was successful (HTTP 200/204), otherwise returns False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the customer to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the customer was successfully deleted, False otherwise. |
Source code in src/spyre/customers.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
get_customer(id)
¶
Retrieve a customer by ID.
Sends a GET request to the customer endpoint to fetch details of a specific customer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the customer to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Customer |
customer
|
A Customer object populated with the retrieved data. |
Source code in src/spyre/customers.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
query_customers(*, query=None, sort=None, filter=None, all=False, limit=1000, start=0, **extra_params)
¶
Query customer with optional full-text search, filtering, multi-field sorting, and pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Full-text search string. |
None
|
sort
|
dict
|
Dictionary of sorting rules (e.g., {"orderDate": "desc", "orderNo": "asc"}). |
None
|
filter
|
dict
|
Dictionary of filters to apply (will be JSON-encoded and URL-safe). |
None
|
all
|
bool
|
If True, retrieves all pages of results. |
False
|
limit
|
int
|
Number of results per page (max 1000). |
1000
|
start
|
int
|
Starting offset for pagination. |
0
|
**extra_params
|
Any
|
Any additional parameters to include in the query. |
{}
|
Returns:
| Type | Description |
|---|---|
List[customer]
|
List[customer]: List of wrapped customer resources. |
Source code in src/spyre/customers.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
update_customer(id, customer)
¶
Update an existing customer by ID.
Sends a PUT request to update a customer record using the provided customer data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The ID of the customer to update. |
required |
customer
|
Customer
|
A Pydantic model representing the updated customer data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
customer |
customer
|
A new Customer instance built from the updated response data. |
Source code in src/spyre/customers.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
customer
¶
Bases: APIResource[Customer]
Source code in src/spyre/customers.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
delete()
¶
Deletes the Customer from Spire.
Sends a DELETE request to the API to remove the customer with the current ID.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the order was successfully deleted (HTTP 204 or 200), False otherwise. |
Source code in src/spyre/customers.py
130 131 132 133 134 135 136 137 138 139 | |
update(customer=None)
¶
Update the customer.
If no order object is provided, updates the current instance on the server. If an order object is provided, updates the customer using the given data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
customer
|
customer
|
An optional customer instance to use for the update. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
customer |
customer
|
The updated customer object reflecting the new status. |
Source code in src/spyre/customers.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |