shopwaive 1.0.0__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.
- shopwaive-1.0.0/LICENSE +8 -0
- shopwaive-1.0.0/MANIFEST.in +3 -0
- shopwaive-1.0.0/PKG-INFO +146 -0
- shopwaive-1.0.0/README.md +126 -0
- shopwaive-1.0.0/pyproject.toml +32 -0
- shopwaive-1.0.0/setup.cfg +4 -0
- shopwaive-1.0.0/shopwaive/__init__.py +12 -0
- shopwaive-1.0.0/shopwaive/_client.py +545 -0
- shopwaive-1.0.0/shopwaive/_errors.py +123 -0
- shopwaive-1.0.0/shopwaive/_generated.py +183 -0
- shopwaive-1.0.0/shopwaive/py.typed +0 -0
- shopwaive-1.0.0/shopwaive/types.py +572 -0
- shopwaive-1.0.0/shopwaive.egg-info/PKG-INFO +146 -0
- shopwaive-1.0.0/shopwaive.egg-info/SOURCES.txt +14 -0
- shopwaive-1.0.0/shopwaive.egg-info/dependency_links.txt +1 -0
- shopwaive-1.0.0/shopwaive.egg-info/top_level.txt +1 -0
shopwaive-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright Shopwaive Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Use permitted under the Shopwaive API Terms: https://www.shopwaive.com/terms-conditions
|
|
4
|
+
|
|
5
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN NO EVENT SHALL SHOPWAIVE INC. BE
|
|
6
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR ITS USE.
|
|
7
|
+
|
|
8
|
+
Shopwaive does not accept outside contributions to this software. Questions and reports: support@shopwaive.com
|
shopwaive-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shopwaive
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The official Python SDK for the Shopwaive API 2026-11: Shopwaive balances, their ledger, units, programs and Shopify store credit reads, with exact amounts and idempotent balance changes.
|
|
5
|
+
Author-email: Shopwaive <support@shopwaive.com>
|
|
6
|
+
License-Expression: LicenseRef-Shopwaive-Proprietary
|
|
7
|
+
Project-URL: Homepage, https://api.shopwaive.com/api-2026-11/sdks/python
|
|
8
|
+
Project-URL: Documentation, https://api.shopwaive.com/api-2026-11/sdks/python
|
|
9
|
+
Project-URL: Changelog, https://api.shopwaive.com/api-2026-11/sdks
|
|
10
|
+
Keywords: shopwaive,shopify,wallet,balance,loyalty,api,sdk
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# shopwaive
|
|
22
|
+
|
|
23
|
+
The official Python SDK for the Shopwaive API 2026-11: read Shopwaive balances, wallets, ledger entries and customers, with short-lived access tokens handled for you.
|
|
24
|
+
|
|
25
|
+
| SDK version | API version | Python |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| 1.x | 2026-11 | 3.8 or later |
|
|
28
|
+
|
|
29
|
+
No dependencies beyond the standard library.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pip install "shopwaive>=1,<2"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`shopwaive>=1,<2` (write the same in requirements.txt) is SDK 1.x, which speaks API 2026-11, so an update stays on SDK 1.x.
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
Make a key in the Shopwaive app under **Settings** > **Developers**, keep it on your server, and pass it to the client. The client trades the key for a one-hour access token on its first call and renews the token by itself before it ends. You never handle a token.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import os
|
|
45
|
+
import shopwaive
|
|
46
|
+
|
|
47
|
+
client = shopwaive.Shopwaive(api_key=os.environ["SHOPWAIVE_API_KEY"])
|
|
48
|
+
|
|
49
|
+
# The first call exchanges the key for an access token; every call after sends only the token.
|
|
50
|
+
units = client.list_units()["data"]
|
|
51
|
+
print([u["code"] for u in units])
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Common uses
|
|
55
|
+
|
|
56
|
+
Read a customer's balance and wallets, by their Shopify customer id:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
for w in client.list_customer_wallets(customer_id)["data"]:
|
|
60
|
+
print(w["id"], w["type"], w["balance"]["amount"], w["balance"]["unit"]) # ids first; amounts are exact text such as '12.50'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Look up a customer by email (the email is sent in the request body, never in a URL):
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
holders = client.search_holders(email=customer_email)["data"]
|
|
67
|
+
if holders:
|
|
68
|
+
print(holders[0]["id"], holders[0]["shopify_customer_id"])
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
List a customer's wallets by their Shopwaive id, and read one wallet:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
wallets = client.list_wallets(holder_id)["data"]
|
|
75
|
+
wallet = client.get_wallet(wallets[0]["id"])
|
|
76
|
+
print(wallet["name"], wallet["balance"]["amount"])
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Read a wallet's history (its ledger entries), one page or every page:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
page = client.list_entries(wallet_id, limit=10)
|
|
83
|
+
for e in page["data"]:
|
|
84
|
+
print(e["kind"], e["amount"]["amount"], e["balance_after"]["amount"])
|
|
85
|
+
for entry in client.list_entries_all(wallet_id, limit=100):
|
|
86
|
+
print(entry["id"], entry["kind"])
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Handle errors. Every error is a `shopwaive.ShopwaiveError` with `status`, `code`, `message`, `hint` and `request_id`:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
try:
|
|
93
|
+
client.get_wallet(wallet_id)
|
|
94
|
+
except shopwaive.RateLimitError as err:
|
|
95
|
+
print("retry after", err.retry_after, "seconds")
|
|
96
|
+
except shopwaive.ShopwaiveError as err:
|
|
97
|
+
if err.code == "key_exchange_required":
|
|
98
|
+
pass # The store takes only access tokens. The SDK exchanges by itself; you see this only with tokens="off".
|
|
99
|
+
elif err.code == "invalid_grant":
|
|
100
|
+
pass # A refresh token was refused (used twice, revoked or ended). The SDK exchanges the key again by itself;
|
|
101
|
+
# you see this only when that exchange fails too, for example after the key was revoked.
|
|
102
|
+
else:
|
|
103
|
+
print(err.status, err.code, err.message, "request id:", err.request_id) # quote the request id to support
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Rate limits and retries. The client retries by itself (up to `max_retries`, default 2) on `rate_limited`, `shopify_throttled`, `temporary_error`, a 5xx without a code, or no answer, and honours `Retry-After`. Every answer's rate-limit headers are on `shopwaive.response_of(result).rate_limit`:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
patient = shopwaive.Shopwaive(api_key=os.environ["SHOPWAIVE_API_KEY"], max_retries=4)
|
|
110
|
+
result = patient.list_units()
|
|
111
|
+
print(shopwaive.response_of(result).rate_limit) # {'limit': ..., 'remaining': ..., 'reset': ...}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Use the developer sandbox. A test key (`swak_test_...`) is answered by your store's sandbox: its own test data, never a live wallet, and every object says `livemode: False`:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
sandbox = shopwaive.Shopwaive(api_key=os.environ["SHOPWAIVE_TEST_KEY"])
|
|
118
|
+
holder = sandbox.create_test_customer(email="ada@example.test", balance="25.00", idempotency_key=shopwaive.new_idempotency_key())
|
|
119
|
+
test_wallet = sandbox.list_wallets(holder["id"])["data"][0]
|
|
120
|
+
print(test_wallet["balance"]["amount"], test_wallet["livemode"]) # 25.00 False
|
|
121
|
+
sandbox.reset_sandbox(idempotency_key=shopwaive.new_idempotency_key())
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Authentication notes
|
|
125
|
+
|
|
126
|
+
- **Keys stay on your server.** A live key is `swak_` and 40 hex characters. The client sends the key only over https, never follows a redirect, and never prints the key.
|
|
127
|
+
- **Access tokens are short-lived.** The key is exchanged for an access token that lasts one hour and a refresh token. The client renews a minute before the hour ends, one renewal at a time, also across threads.
|
|
128
|
+
- **Each refresh rotates both tokens.** A refresh token works once. If the same one is used twice, the API ends that whole chain and the client exchanges its key again.
|
|
129
|
+
- **Never log tokens.** Treat access and refresh tokens like the key. The client never puts one in an error or a log line.
|
|
130
|
+
- **Sign out apps.** An access token stops at once when its key is revoked or ends, or when you press **Sign out apps** for the key in the Shopwaive app.
|
|
131
|
+
- `client.revoke_tokens()` ends this client's tokens now. A test key (`swak_test_`) is always sent as itself.
|
|
132
|
+
|
|
133
|
+
## Links
|
|
134
|
+
|
|
135
|
+
- Help Center: https://docs.shopwaive.com
|
|
136
|
+
- API keys and access tokens: https://docs.shopwaive.com/shopify/settings/api-keys-and-access-tokens
|
|
137
|
+
- Authentication: https://api.shopwaive.com/authentication
|
|
138
|
+
- API reference (2026-11): https://api.shopwaive.com/api-2026-11/reference
|
|
139
|
+
- Errors: https://api.shopwaive.com/reference/errors
|
|
140
|
+
- Rate limits: https://api.shopwaive.com/reference/shopwaive-api-rate-limits
|
|
141
|
+
- Changelog: https://api.shopwaive.com/changelog
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
Copyright Shopwaive Inc. All rights reserved. Use permitted under the [Shopwaive API Terms](https://www.shopwaive.com/terms-conditions).
|
|
146
|
+
Shopwaive does not accept outside contributions; write to support@shopwaive.com with questions or reports.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# shopwaive
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the Shopwaive API 2026-11: read Shopwaive balances, wallets, ledger entries and customers, with short-lived access tokens handled for you.
|
|
4
|
+
|
|
5
|
+
| SDK version | API version | Python |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| 1.x | 2026-11 | 3.8 or later |
|
|
8
|
+
|
|
9
|
+
No dependencies beyond the standard library.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pip install "shopwaive>=1,<2"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`shopwaive>=1,<2` (write the same in requirements.txt) is SDK 1.x, which speaks API 2026-11, so an update stays on SDK 1.x.
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
Make a key in the Shopwaive app under **Settings** > **Developers**, keep it on your server, and pass it to the client. The client trades the key for a one-hour access token on its first call and renews the token by itself before it ends. You never handle a token.
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import os
|
|
25
|
+
import shopwaive
|
|
26
|
+
|
|
27
|
+
client = shopwaive.Shopwaive(api_key=os.environ["SHOPWAIVE_API_KEY"])
|
|
28
|
+
|
|
29
|
+
# The first call exchanges the key for an access token; every call after sends only the token.
|
|
30
|
+
units = client.list_units()["data"]
|
|
31
|
+
print([u["code"] for u in units])
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Common uses
|
|
35
|
+
|
|
36
|
+
Read a customer's balance and wallets, by their Shopify customer id:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
for w in client.list_customer_wallets(customer_id)["data"]:
|
|
40
|
+
print(w["id"], w["type"], w["balance"]["amount"], w["balance"]["unit"]) # ids first; amounts are exact text such as '12.50'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Look up a customer by email (the email is sent in the request body, never in a URL):
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
holders = client.search_holders(email=customer_email)["data"]
|
|
47
|
+
if holders:
|
|
48
|
+
print(holders[0]["id"], holders[0]["shopify_customer_id"])
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
List a customer's wallets by their Shopwaive id, and read one wallet:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
wallets = client.list_wallets(holder_id)["data"]
|
|
55
|
+
wallet = client.get_wallet(wallets[0]["id"])
|
|
56
|
+
print(wallet["name"], wallet["balance"]["amount"])
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Read a wallet's history (its ledger entries), one page or every page:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
page = client.list_entries(wallet_id, limit=10)
|
|
63
|
+
for e in page["data"]:
|
|
64
|
+
print(e["kind"], e["amount"]["amount"], e["balance_after"]["amount"])
|
|
65
|
+
for entry in client.list_entries_all(wallet_id, limit=100):
|
|
66
|
+
print(entry["id"], entry["kind"])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Handle errors. Every error is a `shopwaive.ShopwaiveError` with `status`, `code`, `message`, `hint` and `request_id`:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
try:
|
|
73
|
+
client.get_wallet(wallet_id)
|
|
74
|
+
except shopwaive.RateLimitError as err:
|
|
75
|
+
print("retry after", err.retry_after, "seconds")
|
|
76
|
+
except shopwaive.ShopwaiveError as err:
|
|
77
|
+
if err.code == "key_exchange_required":
|
|
78
|
+
pass # The store takes only access tokens. The SDK exchanges by itself; you see this only with tokens="off".
|
|
79
|
+
elif err.code == "invalid_grant":
|
|
80
|
+
pass # A refresh token was refused (used twice, revoked or ended). The SDK exchanges the key again by itself;
|
|
81
|
+
# you see this only when that exchange fails too, for example after the key was revoked.
|
|
82
|
+
else:
|
|
83
|
+
print(err.status, err.code, err.message, "request id:", err.request_id) # quote the request id to support
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Rate limits and retries. The client retries by itself (up to `max_retries`, default 2) on `rate_limited`, `shopify_throttled`, `temporary_error`, a 5xx without a code, or no answer, and honours `Retry-After`. Every answer's rate-limit headers are on `shopwaive.response_of(result).rate_limit`:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
patient = shopwaive.Shopwaive(api_key=os.environ["SHOPWAIVE_API_KEY"], max_retries=4)
|
|
90
|
+
result = patient.list_units()
|
|
91
|
+
print(shopwaive.response_of(result).rate_limit) # {'limit': ..., 'remaining': ..., 'reset': ...}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use the developer sandbox. A test key (`swak_test_...`) is answered by your store's sandbox: its own test data, never a live wallet, and every object says `livemode: False`:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
sandbox = shopwaive.Shopwaive(api_key=os.environ["SHOPWAIVE_TEST_KEY"])
|
|
98
|
+
holder = sandbox.create_test_customer(email="ada@example.test", balance="25.00", idempotency_key=shopwaive.new_idempotency_key())
|
|
99
|
+
test_wallet = sandbox.list_wallets(holder["id"])["data"][0]
|
|
100
|
+
print(test_wallet["balance"]["amount"], test_wallet["livemode"]) # 25.00 False
|
|
101
|
+
sandbox.reset_sandbox(idempotency_key=shopwaive.new_idempotency_key())
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Authentication notes
|
|
105
|
+
|
|
106
|
+
- **Keys stay on your server.** A live key is `swak_` and 40 hex characters. The client sends the key only over https, never follows a redirect, and never prints the key.
|
|
107
|
+
- **Access tokens are short-lived.** The key is exchanged for an access token that lasts one hour and a refresh token. The client renews a minute before the hour ends, one renewal at a time, also across threads.
|
|
108
|
+
- **Each refresh rotates both tokens.** A refresh token works once. If the same one is used twice, the API ends that whole chain and the client exchanges its key again.
|
|
109
|
+
- **Never log tokens.** Treat access and refresh tokens like the key. The client never puts one in an error or a log line.
|
|
110
|
+
- **Sign out apps.** An access token stops at once when its key is revoked or ends, or when you press **Sign out apps** for the key in the Shopwaive app.
|
|
111
|
+
- `client.revoke_tokens()` ends this client's tokens now. A test key (`swak_test_`) is always sent as itself.
|
|
112
|
+
|
|
113
|
+
## Links
|
|
114
|
+
|
|
115
|
+
- Help Center: https://docs.shopwaive.com
|
|
116
|
+
- API keys and access tokens: https://docs.shopwaive.com/shopify/settings/api-keys-and-access-tokens
|
|
117
|
+
- Authentication: https://api.shopwaive.com/authentication
|
|
118
|
+
- API reference (2026-11): https://api.shopwaive.com/api-2026-11/reference
|
|
119
|
+
- Errors: https://api.shopwaive.com/reference/errors
|
|
120
|
+
- Rate limits: https://api.shopwaive.com/reference/shopwaive-api-rate-limits
|
|
121
|
+
- Changelog: https://api.shopwaive.com/changelog
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
Copyright Shopwaive Inc. All rights reserved. Use permitted under the [Shopwaive API Terms](https://www.shopwaive.com/terms-conditions).
|
|
126
|
+
Shopwaive does not accept outside contributions; write to support@shopwaive.com with questions or reports.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "shopwaive"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "The official Python SDK for the Shopwaive API 2026-11: Shopwaive balances, their ledger, units, programs and Shopify store credit reads, with exact amounts and idempotent balance changes."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "LicenseRef-Shopwaive-Proprietary"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Shopwaive", email = "support@shopwaive.com" }]
|
|
14
|
+
keywords = ["shopwaive", "shopify", "wallet", "balance", "loyalty", "api", "sdk"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Typing :: Typed",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://api.shopwaive.com/api-2026-11/sdks/python"
|
|
25
|
+
Documentation = "https://api.shopwaive.com/api-2026-11/sdks/python"
|
|
26
|
+
Changelog = "https://api.shopwaive.com/api-2026-11/sdks"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools]
|
|
29
|
+
packages = ["shopwaive"]
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.package-data]
|
|
32
|
+
shopwaive = ["py.typed"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""shopwaive: the official Python SDK for the Shopwaive API 2026-11 (Shopwaive balances, their ledger, units, programs, and Shopify store credit reads)."""
|
|
2
|
+
from ._client import ResponseInfo, Shopwaive, ShopwaiveDeprecationWarning, new_idempotency_key, response_of
|
|
3
|
+
from ._errors import (APIConnectionError, AuthenticationError, ConflictError, InvalidRequestError, NotFoundError, PermissionDeniedError,
|
|
4
|
+
PlanRequiredError, RateLimitError, ServiceUnavailableError, ShopwaiveError, WriteNotConfirmedError)
|
|
5
|
+
from ._generated import API_VERSION, DEFAULT_BASE_URL, ERROR_CODES, SPEC_SHA256, VERSION
|
|
6
|
+
from . import types
|
|
7
|
+
|
|
8
|
+
__version__ = VERSION
|
|
9
|
+
|
|
10
|
+
__all__ = ["Shopwaive", "ResponseInfo", "ShopwaiveDeprecationWarning", "response_of", "new_idempotency_key", "API_VERSION", "VERSION", "DEFAULT_BASE_URL", "SPEC_SHA256", "ERROR_CODES", "types",
|
|
11
|
+
"ShopwaiveError", "AuthenticationError", "PlanRequiredError", "PermissionDeniedError", "NotFoundError", "ConflictError", "InvalidRequestError",
|
|
12
|
+
"RateLimitError", "WriteNotConfirmedError", "ServiceUnavailableError", "APIConnectionError"]
|