viewrium 2.1.0__tar.gz → 2.3.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.
- {viewrium-2.1.0 → viewrium-2.3.0}/PKG-INFO +2 -2
- {viewrium-2.1.0 → viewrium-2.3.0}/README.md +1 -1
- {viewrium-2.1.0 → viewrium-2.3.0}/pyproject.toml +1 -1
- {viewrium-2.1.0 → viewrium-2.3.0}/src/viewrium/__init__.py +23 -1
- {viewrium-2.1.0 → viewrium-2.3.0}/src/viewrium/_client.py +15 -5
- {viewrium-2.1.0 → viewrium-2.3.0}/src/viewrium/_models.py +152 -2
- {viewrium-2.1.0 → viewrium-2.3.0}/tests/test_client.py +157 -0
- {viewrium-2.1.0 → viewrium-2.3.0}/tests/test_import.py +1 -1
- {viewrium-2.1.0 → viewrium-2.3.0}/uv.lock +1 -1
- {viewrium-2.1.0 → viewrium-2.3.0}/.gitignore +0 -0
- {viewrium-2.1.0 → viewrium-2.3.0}/.python-version +0 -0
- {viewrium-2.1.0 → viewrium-2.3.0}/LICENSE +0 -0
- {viewrium-2.1.0 → viewrium-2.3.0}/package.json +0 -0
- {viewrium-2.1.0 → viewrium-2.3.0}/src/viewrium/_errors.py +0 -0
- {viewrium-2.1.0 → viewrium-2.3.0}/src/viewrium/py.typed +0 -0
- {viewrium-2.1.0 → viewrium-2.3.0}/turbo.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: viewrium
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Official Python client for the Viewrium API: AR and 3D product visualization for furniture retailers.
|
|
5
5
|
Project-URL: Homepage, https://www.viewrium.com
|
|
6
6
|
Project-URL: Documentation, https://www.viewrium.com/docs/sdks/python
|
|
@@ -167,7 +167,7 @@ See [How generation works](https://www.viewrium.com/docs/generation) and
|
|
|
167
167
|
|
|
168
168
|
| Resource | Methods |
|
|
169
169
|
|---|---|
|
|
170
|
-
| `client.products` | `create`, `list`, `retrieve`, `update`, `delete`, `batch_delete`, `publish`, `tags`, `review`, `update_image`, `update_model`, `rescale`, `create_ticket`, `order`, `export` |
|
|
170
|
+
| `client.products` | `create`, `list`, `retrieve`, `retrieve_by_custom_id`, `update`, `delete`, `batch_delete`, `publish`, `tags`, `review`, `update_image`, `update_model`, `rescale`, `create_ticket`, `order`, `export` |
|
|
171
171
|
| `client.api_keys` | `list`, `create`, `revoke` |
|
|
172
172
|
| `client.usage` | `get` |
|
|
173
173
|
| `client.webhooks` | `list`, `create`, `retrieve`, `update`, `delete`, `list_deliveries` |
|
|
@@ -141,7 +141,7 @@ See [How generation works](https://www.viewrium.com/docs/generation) and
|
|
|
141
141
|
|
|
142
142
|
| Resource | Methods |
|
|
143
143
|
|---|---|
|
|
144
|
-
| `client.products` | `create`, `list`, `retrieve`, `update`, `delete`, `batch_delete`, `publish`, `tags`, `review`, `update_image`, `update_model`, `rescale`, `create_ticket`, `order`, `export` |
|
|
144
|
+
| `client.products` | `create`, `list`, `retrieve`, `retrieve_by_custom_id`, `update`, `delete`, `batch_delete`, `publish`, `tags`, `review`, `update_image`, `update_model`, `rescale`, `create_ticket`, `order`, `export` |
|
|
145
145
|
| `client.api_keys` | `list`, `create`, `revoke` |
|
|
146
146
|
| `client.usage` | `get` |
|
|
147
147
|
| `client.webhooks` | `list`, `create`, `retrieve`, `update`, `delete`, `list_deliveries` |
|
|
@@ -55,6 +55,15 @@ from ._models import (
|
|
|
55
55
|
ListScope,
|
|
56
56
|
ModelDimensions,
|
|
57
57
|
ModelPlan,
|
|
58
|
+
PaintingDimensionsOf,
|
|
59
|
+
PaintingEdge,
|
|
60
|
+
PaintingInspection,
|
|
61
|
+
PaintingOptions,
|
|
62
|
+
PaintingRebuild,
|
|
63
|
+
PaintingRebuildStatus,
|
|
64
|
+
PaintingRequestedSettings,
|
|
65
|
+
PaintingSettings,
|
|
66
|
+
PaintingUpdate,
|
|
58
67
|
PlannedView,
|
|
59
68
|
Product,
|
|
60
69
|
ProductBatchResponse,
|
|
@@ -106,6 +115,8 @@ from ._models import (
|
|
|
106
115
|
UsageEventType,
|
|
107
116
|
UsageProductTotals,
|
|
108
117
|
UsageResponse,
|
|
118
|
+
ViewerDesktopMode,
|
|
119
|
+
ViewerMobileMode,
|
|
109
120
|
WarningKind,
|
|
110
121
|
WebhookDelivery,
|
|
111
122
|
WebhookDeliveryListResponse,
|
|
@@ -118,7 +129,7 @@ from ._models import (
|
|
|
118
129
|
WidthAxis,
|
|
119
130
|
)
|
|
120
131
|
|
|
121
|
-
__version__ = "2.
|
|
132
|
+
__version__ = "2.3.0"
|
|
122
133
|
|
|
123
134
|
__all__ = [
|
|
124
135
|
"__version__",
|
|
@@ -159,6 +170,11 @@ __all__ = [
|
|
|
159
170
|
"WebhookEventType",
|
|
160
171
|
"WidthAxis",
|
|
161
172
|
"DimensionUnit",
|
|
173
|
+
"PaintingEdge",
|
|
174
|
+
"PaintingDimensionsOf",
|
|
175
|
+
"PaintingRebuildStatus",
|
|
176
|
+
"ViewerDesktopMode",
|
|
177
|
+
"ViewerMobileMode",
|
|
162
178
|
# requests
|
|
163
179
|
"ProductCreateRequest",
|
|
164
180
|
"ProductDraft",
|
|
@@ -174,6 +190,8 @@ __all__ = [
|
|
|
174
190
|
"ProductModelPatch",
|
|
175
191
|
"ProductFilters",
|
|
176
192
|
"ModelDimensions",
|
|
193
|
+
"PaintingOptions",
|
|
194
|
+
"PaintingUpdate",
|
|
177
195
|
"ShadowOverride",
|
|
178
196
|
"ShadowSilhouette",
|
|
179
197
|
"ShadowContact",
|
|
@@ -202,6 +220,10 @@ __all__ = [
|
|
|
202
220
|
"PlannedView",
|
|
203
221
|
"ModelPlan",
|
|
204
222
|
"ProductCost",
|
|
223
|
+
"PaintingInspection",
|
|
224
|
+
"PaintingSettings",
|
|
225
|
+
"PaintingRebuild",
|
|
226
|
+
"PaintingRequestedSettings",
|
|
205
227
|
"ApiKey",
|
|
206
228
|
"ApiKeyListResponse",
|
|
207
229
|
"ApiKeyCreateResponse",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"""The synchronous Viewrium client and its resource namespaces.
|
|
2
2
|
|
|
3
3
|
Method shapes mirror ``@viewrium/sdk`` (one ``products.create`` entrypoint, ``products.list`` /
|
|
4
|
-
``retrieve`` / ``
|
|
5
|
-
``
|
|
6
|
-
``usage``, ``webhooks``, ``projects``, ``beacon``).
|
|
7
|
-
publishable key) sent as ``Authorization: Bearer``.
|
|
4
|
+
``retrieve`` / ``retrieve_by_custom_id`` / ``update`` / ``delete`` / ``batch_delete`` /
|
|
5
|
+
``publish`` / ``tags`` / ``review`` / ``update_image`` / ``update_model`` / ``rescale`` /
|
|
6
|
+
``order`` / ``export``, plus ``api_keys``, ``usage``, ``webhooks``, ``projects``, ``beacon``).
|
|
7
|
+
Auth is an ``sk_`` secret key (or ``pk_`` publishable key) sent as ``Authorization: Bearer``.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
@@ -255,9 +255,19 @@ class ProductsResource:
|
|
|
255
255
|
allow-listed public projection instead, and only for a published product."""
|
|
256
256
|
return self._client.request("GET", f"/v1/products/{product_id}", Product)
|
|
257
257
|
|
|
258
|
+
def retrieve_by_custom_id(self, custom_id: str, *, org_id: str | None = None) -> Product:
|
|
259
|
+
"""GET /v1/products/lookup?custom_id=... - one product by your own ``custom_id``
|
|
260
|
+
(unique per org), within the key's org; a session passes ``org_id`` unless it has one
|
|
261
|
+
org. Answers what ``retrieve`` answers - a ``pk_`` key gets the public projection, and
|
|
262
|
+
only for a published product - so mint its tickets with the returned ``id``."""
|
|
263
|
+
params: Params = {"custom_id": custom_id, "org_id": org_id}
|
|
264
|
+
return self._client.request("GET", "/v1/products/lookup", Product, params=params)
|
|
265
|
+
|
|
258
266
|
def update(self, product_id: str, request: ProductUpdateRequest) -> Product:
|
|
259
267
|
"""PATCH /v1/products/{id} - the customer's fields, the user-set status and the
|
|
260
|
-
publish toggle. 409 on a ``custom_id`` another product in the org already holds.
|
|
268
|
+
publish toggle. 409 on a ``custom_id`` another product in the org already holds. On a
|
|
269
|
+
painting, ``painting`` and ``dimensions`` rebuild its model in the background
|
|
270
|
+
(``painting.rebuild``) while the delivered model stays served."""
|
|
261
271
|
return self._client.request(
|
|
262
272
|
"PATCH", f"/v1/products/{product_id}", Product, json=_body(request)
|
|
263
273
|
)
|
|
@@ -163,6 +163,52 @@ class WidthAxis(StrEnum):
|
|
|
163
163
|
Z = "z"
|
|
164
164
|
|
|
165
165
|
|
|
166
|
+
class PaintingEdge(StrEnum):
|
|
167
|
+
"""A painting's edge: ``frame`` (only when the analysis found a frame in the photographs),
|
|
168
|
+
``solid`` (a solid-colour edge, ``edge_color``) or ``stretch`` (the artwork's border pixels
|
|
169
|
+
stretched over the sides)."""
|
|
170
|
+
|
|
171
|
+
FRAME = "frame"
|
|
172
|
+
SOLID = "solid"
|
|
173
|
+
STRETCH = "stretch"
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class ViewerDesktopMode(StrEnum):
|
|
177
|
+
"""How the embed shows a product on a desktop (``viewer_desktop``): the inline ``viewer``,
|
|
178
|
+
a ``qr`` code that opens it on a phone, a ``button``, or ``hidden``. The element's
|
|
179
|
+
``desktop`` attribute overrides it."""
|
|
180
|
+
|
|
181
|
+
VIEWER = "viewer"
|
|
182
|
+
QR = "qr"
|
|
183
|
+
BUTTON = "button"
|
|
184
|
+
HIDDEN = "hidden"
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class ViewerMobileMode(StrEnum):
|
|
188
|
+
"""The same on a phone (``viewer_mobile``): ``viewer``, ``button`` or ``hidden`` - no
|
|
189
|
+
``qr``. The element's ``mobile`` attribute overrides it."""
|
|
190
|
+
|
|
191
|
+
VIEWER = "viewer"
|
|
192
|
+
BUTTON = "button"
|
|
193
|
+
HIDDEN = "hidden"
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class PaintingDimensionsOf(StrEnum):
|
|
197
|
+
"""Which rectangle a painting's width x height describe: the ``canvas`` (default) or the
|
|
198
|
+
frame's outer edge (``frame``, only with the ``frame`` edge)."""
|
|
199
|
+
|
|
200
|
+
CANVAS = "canvas"
|
|
201
|
+
FRAME = "frame"
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class PaintingRebuildStatus(StrEnum):
|
|
205
|
+
"""An edit's rebuild: ``running`` or ``failed``. The delivered model stays served during
|
|
206
|
+
and after it."""
|
|
207
|
+
|
|
208
|
+
RUNNING = "running"
|
|
209
|
+
FAILED = "failed"
|
|
210
|
+
|
|
211
|
+
|
|
166
212
|
# --- Requests --------------------------------------------------------------------------------
|
|
167
213
|
|
|
168
214
|
|
|
@@ -174,6 +220,34 @@ class ModelDimensions(_Base):
|
|
|
174
220
|
depth: float | None = None
|
|
175
221
|
|
|
176
222
|
|
|
223
|
+
class PaintingOptions(_Base):
|
|
224
|
+
"""``ProductDraft.painting`` - its PRESENCE selects the painting path: one inspection of
|
|
225
|
+
the photographs, a model-only order at the normal model price, no product images, and a
|
|
226
|
+
product of form ``painting`` that is always wall-mounted.
|
|
227
|
+
|
|
228
|
+
Sizes ride in the draft's ``dimensions`` + ``unit``: ``width`` x ``height`` describe the
|
|
229
|
+
canvas, or the frame's outer edge when ``dimensions_of`` is ``frame``; ``depth`` is the
|
|
230
|
+
slab's and only applies to a ``solid`` or ``stretch`` edge. Every size is optional: with
|
|
231
|
+
none, the canvas's long side is 50 cm and a slab is 2 cm deep. ``edge`` left unset is
|
|
232
|
+
``frame`` when the analysis finds a frame and ``solid`` otherwise.
|
|
233
|
+
"""
|
|
234
|
+
|
|
235
|
+
edge: PaintingEdge | None = None
|
|
236
|
+
edge_color: str = "#FFFFFF"
|
|
237
|
+
dimensions_of: PaintingDimensionsOf = PaintingDimensionsOf.CANVAS
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class PaintingUpdate(_Base):
|
|
241
|
+
"""``ProductUpdateRequest.painting`` - a painting's settings edit, field by field (an
|
|
242
|
+
omitted field keeps its value). ``frame`` only for a painting ordered with a frame; one
|
|
243
|
+
ordered without can never get one. New sizes go in the request's ``dimensions`` + ``unit``.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
edge: PaintingEdge | None = None
|
|
247
|
+
edge_color: str | None = None
|
|
248
|
+
dimensions_of: PaintingDimensionsOf | None = None
|
|
249
|
+
|
|
250
|
+
|
|
177
251
|
class ProductDraft(_Base):
|
|
178
252
|
"""The customer-editable half of a product, sent at park and again at resume.
|
|
179
253
|
|
|
@@ -195,6 +269,7 @@ class ProductDraft(_Base):
|
|
|
195
269
|
dimensions: ModelDimensions | None = None
|
|
196
270
|
unit: DimensionUnit | None = None
|
|
197
271
|
wall_mounted: bool | None = None
|
|
272
|
+
painting: PaintingOptions | None = None
|
|
198
273
|
|
|
199
274
|
|
|
200
275
|
class ProductOrder(_Base):
|
|
@@ -247,7 +322,12 @@ class ProductCreateRequest(_Base):
|
|
|
247
322
|
class ProductUpdateRequest(_Base):
|
|
248
323
|
"""PATCH /v1/products/{id} - the customer's fields, the user-set status (never back to
|
|
249
324
|
``awaiting_review``) and the publish toggle. Dimensions are stored WITHOUT a rescale;
|
|
250
|
-
``products.rescale`` re-applies them to the GLB. 409 on a duplicate ``custom_id``.
|
|
325
|
+
``products.rescale`` re-applies them to the GLB. 409 on a duplicate ``custom_id``.
|
|
326
|
+
|
|
327
|
+
A PAINTING is different: ``painting`` and ``dimensions`` (with ``unit``) are its settings,
|
|
328
|
+
and changing either rebuilds its model in the background (``Product.painting.rebuild``).
|
|
329
|
+
The delivered model stays ready and served meanwhile.
|
|
330
|
+
"""
|
|
251
331
|
|
|
252
332
|
title: str | None = None
|
|
253
333
|
description: str | None = None
|
|
@@ -262,6 +342,10 @@ class ProductUpdateRequest(_Base):
|
|
|
262
342
|
wall_mounted: bool | None = None
|
|
263
343
|
status: ProductStatus | None = None
|
|
264
344
|
published: bool | None = None
|
|
345
|
+
painting: PaintingUpdate | None = None
|
|
346
|
+
#: How the embed shows the product (the element's ``desktop`` / ``mobile`` attributes win).
|
|
347
|
+
viewer_desktop: ViewerDesktopMode | None = None
|
|
348
|
+
viewer_mobile: ViewerMobileMode | None = None
|
|
265
349
|
|
|
266
350
|
|
|
267
351
|
class ProductPublishRequest(_Base):
|
|
@@ -510,8 +594,20 @@ class ModelPlan(_Base):
|
|
|
510
594
|
unseen_views: list[str] = Field(default_factory=list)
|
|
511
595
|
|
|
512
596
|
|
|
597
|
+
class PaintingInspection(_Base):
|
|
598
|
+
"""What the painting analysis found: whether a photograph shows the whole artwork front-on
|
|
599
|
+
and unobscured (``usable``), whether it is framed, and why. ``suggested_dimensions_of`` is
|
|
600
|
+
``frame`` only when the piece is framed and its product page's stated size reads as the
|
|
601
|
+
framed size."""
|
|
602
|
+
|
|
603
|
+
usable: bool
|
|
604
|
+
framed: bool
|
|
605
|
+
reason: str
|
|
606
|
+
suggested_dimensions_of: PaintingDimensionsOf = PaintingDimensionsOf.CANVAS
|
|
607
|
+
|
|
608
|
+
|
|
513
609
|
class ProductCost(_Base):
|
|
514
|
-
"""The priced bundle, in CREDITS (1 credit = $
|
|
610
|
+
"""The priced bundle, in CREDITS (1 credit = $1.00): 1 per deliverable image, a flat 10 for
|
|
515
611
|
a model. Internal 3D gap-fills never enter the maths."""
|
|
516
612
|
|
|
517
613
|
images: int
|
|
@@ -545,6 +641,10 @@ class ProductParked(_Base):
|
|
|
545
641
|
cost: ProductCost
|
|
546
642
|
generate_unseen: bool = False
|
|
547
643
|
force_model: bool = False
|
|
644
|
+
#: The painting path only: what the inspection found. A painting with no usable
|
|
645
|
+
#: photograph parks with ``model.allowed`` false and ``model.blocked_by``
|
|
646
|
+
#: ``["painting_unusable"]``, and its token cannot be committed.
|
|
647
|
+
painting: PaintingInspection | None = None
|
|
548
648
|
|
|
549
649
|
|
|
550
650
|
class ProductOrderParked(_Base):
|
|
@@ -626,6 +726,48 @@ class ProductModel(_Base):
|
|
|
626
726
|
completed_at: datetime | None = None
|
|
627
727
|
|
|
628
728
|
|
|
729
|
+
class PaintingRequestedSettings(_Base):
|
|
730
|
+
"""The settings an edit asked for. Sizes are cm. ``frame_width_cm`` / ``frame_height_cm``
|
|
731
|
+
are set only when the edit was sized by the frame."""
|
|
732
|
+
|
|
733
|
+
edge: PaintingEdge
|
|
734
|
+
edge_color: str
|
|
735
|
+
dimensions_of: PaintingDimensionsOf
|
|
736
|
+
canvas_width_cm: float | None = None
|
|
737
|
+
canvas_height_cm: float | None = None
|
|
738
|
+
depth_cm: float | None = None
|
|
739
|
+
frame_width_cm: float | None = None
|
|
740
|
+
frame_height_cm: float | None = None
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
class PaintingRebuild(_Base):
|
|
744
|
+
"""An edit's rebuild. The model the product shows - and its dimensions and settings - stay
|
|
745
|
+
the delivered ones while it runs and after it fails; a rebuild that succeeds replaces them
|
|
746
|
+
and is then gone. ``error`` is set when it failed (re-apply the edit to retry)."""
|
|
747
|
+
|
|
748
|
+
status: PaintingRebuildStatus
|
|
749
|
+
requested: PaintingRequestedSettings
|
|
750
|
+
requested_at: datetime | None = None
|
|
751
|
+
error: str | None = None
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
class PaintingSettings(_Base):
|
|
755
|
+
"""A painting product's settings, the ones the model being SHOWN was built with. Sizes are
|
|
756
|
+
cm. ``canvas_width_cm`` / ``canvas_height_cm`` are null only while a canvas is still to be
|
|
757
|
+
derived from a size stated for the frame; ``depth_cm`` is the slab's and null for a framed
|
|
758
|
+
painting. ``has_frame`` is true when the painting was ordered with a frame, the only way it
|
|
759
|
+
ever has one. ``rebuild`` is an edit's rebuild in progress or failed (null when none)."""
|
|
760
|
+
|
|
761
|
+
edge: PaintingEdge
|
|
762
|
+
edge_color: str
|
|
763
|
+
dimensions_of: PaintingDimensionsOf
|
|
764
|
+
canvas_width_cm: float | None = None
|
|
765
|
+
canvas_height_cm: float | None = None
|
|
766
|
+
depth_cm: float | None = None
|
|
767
|
+
has_frame: bool = False
|
|
768
|
+
rebuild: PaintingRebuild | None = None
|
|
769
|
+
|
|
770
|
+
|
|
629
771
|
class ProductSource(_Base):
|
|
630
772
|
"""One photograph or video the product was analyzed from."""
|
|
631
773
|
|
|
@@ -701,6 +843,10 @@ class Product(ProductSummary):
|
|
|
701
843
|
model: ProductModel | None = None
|
|
702
844
|
warnings: list[ProductWarning] = Field(default_factory=list)
|
|
703
845
|
open_request_count: int = 0
|
|
846
|
+
#: A painting's settings (form ``painting``); null for every other product.
|
|
847
|
+
painting: PaintingSettings | None = None
|
|
848
|
+
viewer_desktop: ViewerDesktopMode = ViewerDesktopMode.VIEWER
|
|
849
|
+
viewer_mobile: ViewerMobileMode = ViewerMobileMode.VIEWER
|
|
704
850
|
|
|
705
851
|
|
|
706
852
|
class PublicProduct(_Base):
|
|
@@ -713,6 +859,10 @@ class PublicProduct(_Base):
|
|
|
713
859
|
thumbnail_url: str | None = None
|
|
714
860
|
model_status: AssetStatus | None = None
|
|
715
861
|
wall_mounted: bool = False
|
|
862
|
+
painting: PaintingSettings | None = None
|
|
863
|
+
#: How the embed shows it; the element's ``desktop`` / ``mobile`` attributes override these.
|
|
864
|
+
viewer_desktop: ViewerDesktopMode = ViewerDesktopMode.VIEWER
|
|
865
|
+
viewer_mobile: ViewerMobileMode = ViewerMobileMode.VIEWER
|
|
716
866
|
|
|
717
867
|
|
|
718
868
|
class Ticket(_Base):
|
|
@@ -16,7 +16,13 @@ from viewrium import (
|
|
|
16
16
|
DimensionUnit,
|
|
17
17
|
DisplayStatus,
|
|
18
18
|
ListScope,
|
|
19
|
+
ModelDimensions,
|
|
19
20
|
NotFoundError,
|
|
21
|
+
PaintingDimensionsOf,
|
|
22
|
+
PaintingEdge,
|
|
23
|
+
PaintingOptions,
|
|
24
|
+
PaintingRebuildStatus,
|
|
25
|
+
PaintingUpdate,
|
|
20
26
|
PaymentRequiredError,
|
|
21
27
|
Product,
|
|
22
28
|
ProductCreateRequest,
|
|
@@ -29,10 +35,14 @@ from viewrium import (
|
|
|
29
35
|
ProductParked,
|
|
30
36
|
ProductRescaleRequest,
|
|
31
37
|
ProductStatus,
|
|
38
|
+
ProductUpdateRequest,
|
|
39
|
+
PublicProduct,
|
|
32
40
|
ReviewStatus,
|
|
33
41
|
TicketKind,
|
|
34
42
|
TicketRequest,
|
|
35
43
|
UnprocessableEntityError,
|
|
44
|
+
ViewerDesktopMode,
|
|
45
|
+
ViewerMobileMode,
|
|
36
46
|
Viewrium,
|
|
37
47
|
ViewriumError,
|
|
38
48
|
WidthAxis,
|
|
@@ -150,6 +160,140 @@ def test_force_model_rides_in_the_overrides() -> None:
|
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
|
|
163
|
+
PAINTING_SETTINGS_JSON = {
|
|
164
|
+
"edge": "solid",
|
|
165
|
+
"edge_color": "#FFFFFF",
|
|
166
|
+
"dimensions_of": "canvas",
|
|
167
|
+
"canvas_width_cm": 50.0,
|
|
168
|
+
"canvas_height_cm": 40.0,
|
|
169
|
+
"depth_cm": 2.0,
|
|
170
|
+
"has_frame": True,
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def test_a_painting_create_sends_its_options_and_parks_an_unusable_photo() -> None:
|
|
175
|
+
parked = {
|
|
176
|
+
**PARKED_JSON,
|
|
177
|
+
"form": "painting",
|
|
178
|
+
"wall_mounted": True,
|
|
179
|
+
"model": {"ordered": True, "allowed": False, "blocked_by": ["painting_unusable"]},
|
|
180
|
+
"cost": {"images": 0, "image_credits": 0, "model_credits": 0, "total_credits": 0},
|
|
181
|
+
"painting": {
|
|
182
|
+
"usable": False,
|
|
183
|
+
"framed": True,
|
|
184
|
+
"reason": "a hand covers the lower left corner",
|
|
185
|
+
"suggested_dimensions_of": "frame",
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
client, rec = make_client(httpx.Response(200, json=parked))
|
|
189
|
+
result = client.products.create(
|
|
190
|
+
ProductCreateRequest(
|
|
191
|
+
image_urls=["https://cdn/art.jpg"],
|
|
192
|
+
draft=ProductDraft(
|
|
193
|
+
title="Harbour at dusk",
|
|
194
|
+
dimensions=ModelDimensions(width=60, height=45),
|
|
195
|
+
painting=PaintingOptions(edge=PaintingEdge.FRAME),
|
|
196
|
+
),
|
|
197
|
+
)
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
assert isinstance(result, ProductParked)
|
|
201
|
+
assert result.form == "painting" and result.wall_mounted is True
|
|
202
|
+
assert result.model.blocked_by == ["painting_unusable"]
|
|
203
|
+
assert result.painting is not None
|
|
204
|
+
assert result.painting.usable is False
|
|
205
|
+
assert result.painting.suggested_dimensions_of is PaintingDimensionsOf.FRAME
|
|
206
|
+
assert rec.request is not None
|
|
207
|
+
# Only what was set goes on the wire: the API defaults edge_color and dimensions_of.
|
|
208
|
+
assert json.loads(rec.request.content) == {
|
|
209
|
+
"image_urls": ["https://cdn/art.jpg"],
|
|
210
|
+
"draft": {
|
|
211
|
+
"title": "Harbour at dusk",
|
|
212
|
+
"dimensions": {"width": 60.0, "height": 45.0},
|
|
213
|
+
"painting": {"edge": "frame"},
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def test_a_painting_edit_patches_its_settings_and_reads_the_rebuild() -> None:
|
|
219
|
+
body = {
|
|
220
|
+
**PRODUCT_JSON,
|
|
221
|
+
"form": "painting",
|
|
222
|
+
"wall_mounted": True,
|
|
223
|
+
"painting": {
|
|
224
|
+
**PAINTING_SETTINGS_JSON,
|
|
225
|
+
"rebuild": {
|
|
226
|
+
"status": "running",
|
|
227
|
+
"requested": {
|
|
228
|
+
**PAINTING_SETTINGS_JSON,
|
|
229
|
+
"edge": "stretch",
|
|
230
|
+
"canvas_width_cm": 70.0,
|
|
231
|
+
"canvas_height_cm": 56.0,
|
|
232
|
+
},
|
|
233
|
+
"requested_at": "2026-10-23T10:00:00Z",
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
}
|
|
237
|
+
client, rec = make_client(httpx.Response(200, json=body))
|
|
238
|
+
product = client.products.update(
|
|
239
|
+
"p1",
|
|
240
|
+
ProductUpdateRequest(
|
|
241
|
+
painting=PaintingUpdate(edge=PaintingEdge.STRETCH),
|
|
242
|
+
dimensions=ModelDimensions(width=70),
|
|
243
|
+
),
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
assert rec.request is not None
|
|
247
|
+
assert rec.request.method == "PATCH"
|
|
248
|
+
assert json.loads(rec.request.content) == {
|
|
249
|
+
"painting": {"edge": "stretch"},
|
|
250
|
+
"dimensions": {"width": 70.0},
|
|
251
|
+
}
|
|
252
|
+
assert product.painting is not None
|
|
253
|
+
# The shown settings stay the delivered ones while the rebuild runs.
|
|
254
|
+
assert product.painting.edge is PaintingEdge.SOLID
|
|
255
|
+
assert product.painting.rebuild is not None
|
|
256
|
+
assert product.painting.rebuild.status is PaintingRebuildStatus.RUNNING
|
|
257
|
+
assert product.painting.rebuild.requested.edge is PaintingEdge.STRETCH
|
|
258
|
+
assert product.painting.rebuild.requested.frame_width_cm is None # sized by the canvas
|
|
259
|
+
assert product.painting.rebuild.error is None
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def test_the_public_projection_carries_a_paintings_settings() -> None:
|
|
263
|
+
product = PublicProduct.model_validate(
|
|
264
|
+
{
|
|
265
|
+
"id": "p1",
|
|
266
|
+
"title": "Harbour at dusk",
|
|
267
|
+
"model_status": "ready",
|
|
268
|
+
"wall_mounted": True,
|
|
269
|
+
"painting": PAINTING_SETTINGS_JSON,
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
assert product.painting is not None
|
|
274
|
+
assert product.painting.depth_cm == 2.0
|
|
275
|
+
assert product.painting.rebuild is None
|
|
276
|
+
# Absent from an older API's response: the default the embed always had.
|
|
277
|
+
assert product.viewer_desktop is ViewerDesktopMode.VIEWER
|
|
278
|
+
assert product.viewer_mobile is ViewerMobileMode.VIEWER
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def test_update_sends_the_embed_display_modes_and_reads_them_back() -> None:
|
|
282
|
+
body = {**PRODUCT_JSON, "viewer_desktop": "qr", "viewer_mobile": "button"}
|
|
283
|
+
client, rec = make_client(httpx.Response(200, json=body))
|
|
284
|
+
product = client.products.update(
|
|
285
|
+
"p1",
|
|
286
|
+
ProductUpdateRequest(
|
|
287
|
+
viewer_desktop=ViewerDesktopMode.QR, viewer_mobile=ViewerMobileMode.BUTTON
|
|
288
|
+
),
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
assert rec.request is not None
|
|
292
|
+
assert json.loads(rec.request.content) == {"viewer_desktop": "qr", "viewer_mobile": "button"}
|
|
293
|
+
assert product.viewer_desktop is ViewerDesktopMode.QR
|
|
294
|
+
assert product.viewer_mobile is ViewerMobileMode.BUTTON
|
|
295
|
+
|
|
296
|
+
|
|
153
297
|
def test_rescale_posts_to_the_products_own_model_and_parses_the_achieved_size() -> None:
|
|
154
298
|
body = {**PRODUCT_JSON, "height": 50.8, "display_unit": "in"}
|
|
155
299
|
client, rec = make_client(httpx.Response(200, json=body))
|
|
@@ -309,6 +453,19 @@ def test_tags_reads_the_catalogs_own_tag_route() -> None:
|
|
|
309
453
|
assert rec.request.url.params.get("scope") == "all"
|
|
310
454
|
|
|
311
455
|
|
|
456
|
+
def test_retrieve_by_custom_id_sends_the_custom_id_as_a_query_param() -> None:
|
|
457
|
+
client, rec = make_client(httpx.Response(200, json=PRODUCT_JSON))
|
|
458
|
+
product = client.products.retrieve_by_custom_id("SKU/12 a&b")
|
|
459
|
+
|
|
460
|
+
assert product.id == PRODUCT_JSON["id"]
|
|
461
|
+
|
|
462
|
+
assert rec.request is not None
|
|
463
|
+
assert rec.request.method == "GET"
|
|
464
|
+
assert rec.request.url.path == "/v1/products/lookup"
|
|
465
|
+
assert rec.request.url.params.get("custom_id") == "SKU/12 a&b"
|
|
466
|
+
assert "org_id" not in rec.request.url.params
|
|
467
|
+
|
|
468
|
+
|
|
312
469
|
def test_beacon_send_uses_pk_key() -> None:
|
|
313
470
|
client, rec = make_client(httpx.Response(204), api_key="pk_live_1")
|
|
314
471
|
client.beacon.send(BeaconRequest(model_id="p1", event_type=BeaconEventType.VIEW))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|