Skip to content

Commit 16760c2

Browse files
authored
Merge branch 'main' into u/xiaoxuan/fix-ucp-request-optional
2 parents 5cad72a + 6f9141c commit 16760c2

6 files changed

Lines changed: 121 additions & 27 deletions

File tree

.github/CODEOWNERS

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/governance.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: PR Governance
3+
4+
on:
5+
pull_request_target:
6+
types: [
7+
opened,
8+
synchronize,
9+
reopened,
10+
ready_for_review,
11+
review_requested,
12+
review_request_removed,
13+
assigned,
14+
unassigned
15+
]
16+
pull_request_review:
17+
types: [submitted, dismissed]
18+
19+
jobs:
20+
governance:
21+
name: Reviews
22+
# skip for draft PRs
23+
if: github.event.pull_request.draft == false
24+
permissions:
25+
statuses: write
26+
contents: read
27+
pull-requests: read
28+
# Use the reusable workflow defined in the central governance repository
29+
# zizmor: ignore[ref-confusion]
30+
uses: Universal-Commerce-Protocol/.github/.github/workflows/reusable-governance.yml@main
31+
secrets:
32+
# Required: An org-level Read token to read team memberships
33+
ORG_READ_TOKEN: ${{ secrets.ORG_READ_TOKEN }}

.github/workflows/linter.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ jobs:
2424
pre-commit:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@v4
28-
- uses: actions/setup-python@v5
27+
- uses: actions/checkout@v5
28+
- uses: actions/setup-python@v6
2929
with:
3030
python-version: '3.x'
3131
- uses: pre-commit/action@v3.0.1
32+
env:
33+
# workaround for pre-commit/action not being updated to node24
34+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
contents: read
1919
steps:
2020
- name: Checkout code
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2222

2323
# Installs uv (and manages Python automatically)
2424
- name: Install uv
25-
uses: astral-sh/setup-uv@v5
25+
uses: astral-sh/setup-uv@v8.2.0
2626
with:
2727
enable-cache: true
2828

README.md

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
<b>Official Python library for the Universal Commerce Protocol (UCP).</b>
2323
</p>
2424

25+
<p align="center">
26+
<a href="https://pypi.org/project/ucp-sdk/"><img src="https://img.shields.io/pypi/v/ucp-sdk" alt="PyPI version"></a>
27+
<a href="https://pypi.org/project/ucp-sdk/"><img src="https://img.shields.io/pypi/pyversions/ucp-sdk" alt="Python versions"></a>
28+
<a href="https://github.com/Universal-Commerce-Protocol/python-sdk/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Universal-Commerce-Protocol/python-sdk" alt="License"></a>
29+
</p>
30+
2531
## Overview
2632

2733
This repository contains the Python SDK for the
@@ -31,24 +37,77 @@ Python.
3137

3238
## Installation
3339

34-
For now, you can install the SDK using the following commands:
40+
To use this SDK in your own project, install it from PyPI:
3541

3642
```bash
37-
# Clone the repository
38-
git clone https://github.com/Universal-Commerce-Protocol/python-sdk.git
43+
pip install ucp-sdk
44+
```
3945

40-
# Navigate to the directory
41-
cd python-sdk
46+
Or, if you are managing your project with [uv](https://docs.astral.sh/uv/):
4247

43-
# Install dependencies
44-
uv sync
48+
```bash
49+
uv add ucp-sdk
50+
```
51+
52+
## Usage
53+
54+
The example below parses a UCP checkout response and reads typed fields:
55+
56+
```python
57+
from ucp_sdk.models.schemas.shopping.checkout import Checkout
58+
59+
# Parse a UCP checkout response
60+
checkout = Checkout.model_validate(checkout_data)
61+
62+
# Access typed fields
63+
print(checkout.status) # "incomplete" | "ready_for_complete" | ...
64+
print(checkout.currency) # ISO 4217 currency code
65+
for item in checkout.line_items:
66+
print(f"{item.item.title}: {item.quantity}")
67+
```
68+
69+
### Available model packages
70+
71+
| Package | Description |
72+
| --------------------------------------- | --------------------------------------------------- |
73+
| `ucp_sdk.models.schemas.shopping` | Checkout, cart, order, payment models |
74+
| `ucp_sdk.models.schemas.shopping.types` | Line items, totals, buyer, fulfillment, etc. |
75+
| `ucp_sdk.models.schemas.transports` | REST, MCP, and embedded protocol bindings |
76+
| `ucp_sdk.models.schemas` | Service definitions, capabilities, payment handlers |
77+
78+
### Validation
79+
80+
All models support Pydantic validation and serialization:
81+
82+
```python
83+
from pydantic import ValidationError
84+
from ucp_sdk.models.schemas.shopping.checkout import Checkout
85+
86+
# Validate data against UCP schemas
87+
try:
88+
checkout = Checkout.model_validate(checkout_data)
89+
# Serialize to JSON-compatible dict
90+
checkout_dict = checkout.model_dump(exclude_none=True)
91+
except ValidationError as e:
92+
print(e.errors())
4593
```
4694

4795
## Development
4896

4997
### Prerequisites
5098

51-
This project uses `uv` for dependency management.
99+
This project uses [`uv`](https://docs.astral.sh/uv/) for dependency management.
100+
101+
### Setup
102+
103+
```bash
104+
# Clone the repository
105+
git clone https://github.com/Universal-Commerce-Protocol/python-sdk.git
106+
cd python-sdk
107+
108+
# Install dependencies
109+
uv sync
110+
```
52111

53112
### Generating Pydantic Models
54113

generate_models.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
#!/bin/bash
2+
# Copyright 2026 UCP Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
216
# Generate Pydantic models from UCP JSON Schemas
317

418
# Ensure we are in the script's directory

0 commit comments

Comments
 (0)