Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .spec-sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
41311cb64247613fcc1634a63a1804e344c71873d665fc58af33e053a5f919f1
d95f1962bb73a3e9792c2de01bd086edce7d3c1371ece42f7c4f12032cd29e17
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ for item in client.items.iter(sold=False):
print(item.name)
for order in client.orders.iter(bucket="to_send"): # needs the orders:read scope; also orders.get(id), orders.labels(id)
print(order.id)
for brand in client.catalogs.iter_brands(q="nik"): # the identifiers an item is written with (items:read): categories, category, category_fields, brands, sizes, colors, conditions, package_sizes, materials
print(brand.id, brand.name)

for favorite in client.favorites.iter(item_id=42): # the buyers who favorited a listing (items:read); also favorites.iter_item(42), list, list_item
print(favorite.buyer_id)
client.conversations.list(buyer_id="<buyer id>", offer_status="PENDING") # buyer_id, item_id and offer_status filter the conversations

# Writes (API key with `items:write` / `conversations:write`); `idempotency_key=` chooses the key.
from controlresell.generated.models import ItemCreateRequest, ItemUpdateRequest, PublishRequest, SendMessageRequest
Expand All @@ -19,6 +25,15 @@ client.items.create(ItemCreateRequest(name="Jacket")) # client.items.update(42,

client.items.publish(42, PublishRequest(account_ids=["<account id>"]))
client.conversations.send_message("<conversation id>", SendMessageRequest(text="Hello!"))

# Webhooks (`webhooks:read` / `webhooks:write`): endpoints, endpoint, create_endpoint, update_endpoint, delete_endpoint,
# secret, rotate_secret, test, deliveries, retry_delivery, recover, event_types; iter_events catches up the last 7 days.
from controlresell.generated.models import WebhookEndpointCreateRequest

created = client.webhooks.create_endpoint(WebhookEndpointCreateRequest(url="https://example.com/hooks", event_types=["item.sold"]))
print(created.endpoint.id, created.secret) # the signing secret, shown once (client.webhooks.secret(id) reads it again)
for event in client.webhooks.iter_events(types=["item.sold"]):
print(event.type_, event.data["itemId"])
```

Retries (rate limits, 502/503/504, network errors), `Idempotency-Key` on every `POST`, cursor pagination with plain iterators and typed errors (`NotFoundError`, `RateLimitError`...) are built in. The client is generated from the API's OpenAPI document (`scripts/generate.sh`, code in `src/controlresell/generated`).
Expand Down
Loading
Loading