omnicommerce 0.1.1__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.
- omnicommerce-0.1.1/.gitignore +73 -0
- omnicommerce-0.1.1/LICENSE +21 -0
- omnicommerce-0.1.1/PKG-INFO +116 -0
- omnicommerce-0.1.1/README.md +103 -0
- omnicommerce-0.1.1/pyproject.toml +24 -0
- omnicommerce-0.1.1/scripts/generate.ts +550 -0
- omnicommerce-0.1.1/src/omnicommerce/__init__.py +60 -0
- omnicommerce-0.1.1/src/omnicommerce/_generated/__init__.py +1 -0
- omnicommerce-0.1.1/src/omnicommerce/_generated/manifest.json +1149 -0
- omnicommerce-0.1.1/src/omnicommerce/_generated/resources.py +5177 -0
- omnicommerce-0.1.1/src/omnicommerce/client.py +140 -0
- omnicommerce-0.1.1/src/omnicommerce/core/__init__.py +1 -0
- omnicommerce-0.1.1/src/omnicommerce/core/deadline.py +24 -0
- omnicommerce-0.1.1/src/omnicommerce/core/http.py +402 -0
- omnicommerce-0.1.1/src/omnicommerce/core/path.py +10 -0
- omnicommerce-0.1.1/src/omnicommerce/core/query.py +46 -0
- omnicommerce-0.1.1/src/omnicommerce/core/types.py +25 -0
- omnicommerce-0.1.1/src/omnicommerce/core/values.py +27 -0
- omnicommerce-0.1.1/src/omnicommerce/environment.py +5 -0
- omnicommerce-0.1.1/src/omnicommerce/errors.py +173 -0
- omnicommerce-0.1.1/src/omnicommerce/jobs.py +119 -0
- omnicommerce-0.1.1/src/omnicommerce/py.typed +0 -0
- omnicommerce-0.1.1/src/omnicommerce/version.py +2 -0
- omnicommerce-0.1.1/src/omnicommerce/webhooks.py +119 -0
- omnicommerce-0.1.1/tests/conftest.py +4 -0
- omnicommerce-0.1.1/tests/test_client.py +277 -0
- omnicommerce-0.1.1/tests/test_generated_requests.py +98 -0
- omnicommerce-0.1.1/tests/test_jobs.py +72 -0
- omnicommerce-0.1.1/tests/test_transport.py +154 -0
- omnicommerce-0.1.1/tests/test_webhooks.py +73 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
node_modules/
|
|
5
|
+
/infrastructure/document-worker/.venv
|
|
6
|
+
scripts/sagemaker/.venv/
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
/.pnp
|
|
10
|
+
.pnp.*
|
|
11
|
+
.yarn/*
|
|
12
|
+
!.yarn/patches
|
|
13
|
+
!.yarn/plugins
|
|
14
|
+
!.yarn/releases
|
|
15
|
+
!.yarn/versions
|
|
16
|
+
|
|
17
|
+
# testing
|
|
18
|
+
/coverage
|
|
19
|
+
/tmp/
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
|
|
23
|
+
# next.js
|
|
24
|
+
/.next/
|
|
25
|
+
/out/
|
|
26
|
+
|
|
27
|
+
# production
|
|
28
|
+
/build
|
|
29
|
+
/.artifacts
|
|
30
|
+
|
|
31
|
+
# misc
|
|
32
|
+
.DS_Store
|
|
33
|
+
*.pem
|
|
34
|
+
.claude/
|
|
35
|
+
.vscode/
|
|
36
|
+
|
|
37
|
+
# debug
|
|
38
|
+
npm-debug.log*
|
|
39
|
+
yarn-debug.log*
|
|
40
|
+
yarn-error.log*
|
|
41
|
+
.pnpm-debug.log*
|
|
42
|
+
|
|
43
|
+
# env files (can opt-in for committing if needed)
|
|
44
|
+
.env*
|
|
45
|
+
!infrastructure/document-worker/.env.example
|
|
46
|
+
|
|
47
|
+
# vercel
|
|
48
|
+
.vercel
|
|
49
|
+
|
|
50
|
+
# typescript
|
|
51
|
+
*.tsbuildinfo
|
|
52
|
+
next-env.d.ts
|
|
53
|
+
|
|
54
|
+
# generated OpenAPI/SDK artifacts
|
|
55
|
+
docs/openapi.generated.json
|
|
56
|
+
lib/sdk/generated/openapi.d.ts
|
|
57
|
+
packages/js-sdk/dist/
|
|
58
|
+
packages/cli/dist/
|
|
59
|
+
|
|
60
|
+
# Large taxonomy data files
|
|
61
|
+
taxonomy/
|
|
62
|
+
libs/eval/runs
|
|
63
|
+
|
|
64
|
+
# Sentry Config File
|
|
65
|
+
.env.sentry-build-plugin
|
|
66
|
+
|
|
67
|
+
# Next build output (app workspace)
|
|
68
|
+
apps/omni/.next/
|
|
69
|
+
**/.next/
|
|
70
|
+
|
|
71
|
+
# Shopify extension build output and local CLI state
|
|
72
|
+
/extensions/*/dist/
|
|
73
|
+
/.shopify/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) OmniCommerce
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: omnicommerce
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Python SDK for the OmniCommerce API. Generated from the public OpenAPI spec.
|
|
5
|
+
Project-URL: Homepage, https://docs.omnicommerce.sg/sdk/python
|
|
6
|
+
Project-URL: Repository, https://github.com/rmdort/omnicommerce
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: api,omni,omnicommerce,sdk
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Requires-Dist: httpx>=0.27
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# omnicommerce
|
|
15
|
+
|
|
16
|
+
Python client for the [OmniCommerce API](https://docs.omnicommerce.sg/api-reference).
|
|
17
|
+
|
|
18
|
+
The client is generated from the public OpenAPI spec, the same operation map as `@omni-commerce/sdk`. Sync and async clients take snake_case keyword arguments. Responses are parsed JSON.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
Install from PyPI:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
python3 -m pip install omnicommerce
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Python 3.10+.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import os
|
|
34
|
+
from omnicommerce import Omni
|
|
35
|
+
|
|
36
|
+
with Omni(api_key=os.environ["OMNI_API_KEY"]) as client:
|
|
37
|
+
products = client.products.list(q="lamp")
|
|
38
|
+
job = client.products.create(
|
|
39
|
+
product={
|
|
40
|
+
"sku": "SKU-100",
|
|
41
|
+
"title": "Sample product",
|
|
42
|
+
"price": 29.9,
|
|
43
|
+
"currency": "SGD",
|
|
44
|
+
"images": ["https://cdn.example.com/product.jpg"],
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
created = client.jobs.wait(job_id=job["jobId"])
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
API keys are organization-scoped. Do not send `organization_id` on API-key requests.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from omnicommerce import AsyncOmni, Omni, OmniEnvironment
|
|
54
|
+
|
|
55
|
+
client = Omni(
|
|
56
|
+
api_key="omni_sk_...",
|
|
57
|
+
environment=OmniEnvironment.LOCAL, # http://localhost:3000
|
|
58
|
+
timeout_in_seconds=60,
|
|
59
|
+
max_retries=2,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
async with AsyncOmni(api_key=os.environ["OMNI_API_KEY"]) as client:
|
|
63
|
+
products = await client.products.list(q="lamp")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`client.with_raw_response.products.get(product_id="prod_123")` returns `data`, `status_code`, `headers`, and `url`.
|
|
67
|
+
|
|
68
|
+
## Resources
|
|
69
|
+
|
|
70
|
+
| Client | Examples |
|
|
71
|
+
| ------------------------------ | ------------------------------------------------------------------------------- |
|
|
72
|
+
| `client.products` | `list`, `create`, `get`, `update`, `delete`, `publish`, `bulk_import`, `enrich` |
|
|
73
|
+
| `client.orders` | `list`, `create`, `get`, `update` |
|
|
74
|
+
| `client.promotions` | `list`, `create`, `get`, `update`, `delete`, `sync` |
|
|
75
|
+
| `client.price_books` | `list`, `create`, `get`, `update`, `delete`, `preview` |
|
|
76
|
+
| `client.aop` | `create`, `execute`, `get_config`, `update_config`, `retry` |
|
|
77
|
+
| `client.jobs` | `get`, `cancel`, `wait` |
|
|
78
|
+
| `client.webhooks` | `list`, `create` |
|
|
79
|
+
| `client.checkout_sessions` | `create`, `get`, `update`, `complete`, `cancel` |
|
|
80
|
+
| `client.ucp.checkout_sessions` | Universal Commerce Protocol checkout |
|
|
81
|
+
| `client.oauth` | `token`, `revoke` |
|
|
82
|
+
|
|
83
|
+
Every other documented tag is exposed the same way.
|
|
84
|
+
|
|
85
|
+
## Errors
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from omnicommerce import NotFoundError, Omni, OmniError
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
client.products.get(product_id="missing")
|
|
92
|
+
except NotFoundError:
|
|
93
|
+
pass
|
|
94
|
+
except OmniError as error:
|
|
95
|
+
print(error.status_code, error.body)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Webhooks
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from omnicommerce import construct_event
|
|
102
|
+
|
|
103
|
+
event = construct_event(raw_body, headers, os.environ["OMNI_WEBHOOK_SECRET"])
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Signature: HMAC-SHA256 over `{timestamp}.{raw_body}` compared to `X-Omni-Signature`.
|
|
107
|
+
|
|
108
|
+
## Regenerate from OpenAPI
|
|
109
|
+
|
|
110
|
+
From the monorepo root:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
yarn sdk:generate
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
That refreshes `src/omnicommerce/_generated/resources.py` from `docs/openapi.json`.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# omnicommerce
|
|
2
|
+
|
|
3
|
+
Python client for the [OmniCommerce API](https://docs.omnicommerce.sg/api-reference).
|
|
4
|
+
|
|
5
|
+
The client is generated from the public OpenAPI spec, the same operation map as `@omni-commerce/sdk`. Sync and async clients take snake_case keyword arguments. Responses are parsed JSON.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Install from PyPI:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
python3 -m pip install omnicommerce
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Python 3.10+.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import os
|
|
21
|
+
from omnicommerce import Omni
|
|
22
|
+
|
|
23
|
+
with Omni(api_key=os.environ["OMNI_API_KEY"]) as client:
|
|
24
|
+
products = client.products.list(q="lamp")
|
|
25
|
+
job = client.products.create(
|
|
26
|
+
product={
|
|
27
|
+
"sku": "SKU-100",
|
|
28
|
+
"title": "Sample product",
|
|
29
|
+
"price": 29.9,
|
|
30
|
+
"currency": "SGD",
|
|
31
|
+
"images": ["https://cdn.example.com/product.jpg"],
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
created = client.jobs.wait(job_id=job["jobId"])
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
API keys are organization-scoped. Do not send `organization_id` on API-key requests.
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from omnicommerce import AsyncOmni, Omni, OmniEnvironment
|
|
41
|
+
|
|
42
|
+
client = Omni(
|
|
43
|
+
api_key="omni_sk_...",
|
|
44
|
+
environment=OmniEnvironment.LOCAL, # http://localhost:3000
|
|
45
|
+
timeout_in_seconds=60,
|
|
46
|
+
max_retries=2,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
async with AsyncOmni(api_key=os.environ["OMNI_API_KEY"]) as client:
|
|
50
|
+
products = await client.products.list(q="lamp")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`client.with_raw_response.products.get(product_id="prod_123")` returns `data`, `status_code`, `headers`, and `url`.
|
|
54
|
+
|
|
55
|
+
## Resources
|
|
56
|
+
|
|
57
|
+
| Client | Examples |
|
|
58
|
+
| ------------------------------ | ------------------------------------------------------------------------------- |
|
|
59
|
+
| `client.products` | `list`, `create`, `get`, `update`, `delete`, `publish`, `bulk_import`, `enrich` |
|
|
60
|
+
| `client.orders` | `list`, `create`, `get`, `update` |
|
|
61
|
+
| `client.promotions` | `list`, `create`, `get`, `update`, `delete`, `sync` |
|
|
62
|
+
| `client.price_books` | `list`, `create`, `get`, `update`, `delete`, `preview` |
|
|
63
|
+
| `client.aop` | `create`, `execute`, `get_config`, `update_config`, `retry` |
|
|
64
|
+
| `client.jobs` | `get`, `cancel`, `wait` |
|
|
65
|
+
| `client.webhooks` | `list`, `create` |
|
|
66
|
+
| `client.checkout_sessions` | `create`, `get`, `update`, `complete`, `cancel` |
|
|
67
|
+
| `client.ucp.checkout_sessions` | Universal Commerce Protocol checkout |
|
|
68
|
+
| `client.oauth` | `token`, `revoke` |
|
|
69
|
+
|
|
70
|
+
Every other documented tag is exposed the same way.
|
|
71
|
+
|
|
72
|
+
## Errors
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from omnicommerce import NotFoundError, Omni, OmniError
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
client.products.get(product_id="missing")
|
|
79
|
+
except NotFoundError:
|
|
80
|
+
pass
|
|
81
|
+
except OmniError as error:
|
|
82
|
+
print(error.status_code, error.body)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Webhooks
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from omnicommerce import construct_event
|
|
89
|
+
|
|
90
|
+
event = construct_event(raw_body, headers, os.environ["OMNI_WEBHOOK_SECRET"])
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Signature: HMAC-SHA256 over `{timestamp}.{raw_body}` compared to `X-Omni-Signature`.
|
|
94
|
+
|
|
95
|
+
## Regenerate from OpenAPI
|
|
96
|
+
|
|
97
|
+
From the monorepo root:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
yarn sdk:generate
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
That refreshes `src/omnicommerce/_generated/resources.py` from `docs/openapi.json`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "omnicommerce"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Python SDK for the OmniCommerce API. Generated from the public OpenAPI spec."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
dependencies = ["httpx>=0.27"]
|
|
13
|
+
keywords = ["omnicommerce", "omni", "api", "sdk"]
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://docs.omnicommerce.sg/sdk/python"
|
|
17
|
+
Repository = "https://github.com/rmdort/omnicommerce"
|
|
18
|
+
|
|
19
|
+
[tool.hatch.build.targets.wheel]
|
|
20
|
+
packages = ["src/omnicommerce"]
|
|
21
|
+
|
|
22
|
+
[tool.pytest.ini_options]
|
|
23
|
+
testpaths = ["tests"]
|
|
24
|
+
pythonpath = ["src"]
|