viewrium 2.1.0__tar.gz → 2.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: viewrium
3
- Version: 2.1.0
3
+ Version: 2.2.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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "viewrium"
3
- version = "2.1.0"
3
+ version = "2.2.0"
4
4
  description = "Official Python client for the Viewrium API: AR and 3D product visualization for furniture retailers."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -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,
@@ -118,7 +127,7 @@ from ._models import (
118
127
  WidthAxis,
119
128
  )
120
129
 
121
- __version__ = "2.1.0"
130
+ __version__ = "2.2.0"
122
131
 
123
132
  __all__ = [
124
133
  "__version__",
@@ -159,6 +168,9 @@ __all__ = [
159
168
  "WebhookEventType",
160
169
  "WidthAxis",
161
170
  "DimensionUnit",
171
+ "PaintingEdge",
172
+ "PaintingDimensionsOf",
173
+ "PaintingRebuildStatus",
162
174
  # requests
163
175
  "ProductCreateRequest",
164
176
  "ProductDraft",
@@ -174,6 +186,8 @@ __all__ = [
174
186
  "ProductModelPatch",
175
187
  "ProductFilters",
176
188
  "ModelDimensions",
189
+ "PaintingOptions",
190
+ "PaintingUpdate",
177
191
  "ShadowOverride",
178
192
  "ShadowSilhouette",
179
193
  "ShadowContact",
@@ -202,6 +216,10 @@ __all__ = [
202
216
  "PlannedView",
203
217
  "ModelPlan",
204
218
  "ProductCost",
219
+ "PaintingInspection",
220
+ "PaintingSettings",
221
+ "PaintingRebuild",
222
+ "PaintingRequestedSettings",
205
223
  "ApiKey",
206
224
  "ApiKeyListResponse",
207
225
  "ApiKeyCreateResponse",
@@ -257,7 +257,9 @@ class ProductsResource:
257
257
 
258
258
  def update(self, product_id: str, request: ProductUpdateRequest) -> Product:
259
259
  """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."""
260
+ publish toggle. 409 on a ``custom_id`` another product in the org already holds. On a
261
+ painting, ``painting`` and ``dimensions`` rebuild its model in the background
262
+ (``painting.rebuild``) while the delivered model stays served."""
261
263
  return self._client.request(
262
264
  "PATCH", f"/v1/products/{product_id}", Product, json=_body(request)
263
265
  )
@@ -163,6 +163,32 @@ 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 PaintingDimensionsOf(StrEnum):
177
+ """Which rectangle a painting's width x height describe: the ``canvas`` (default) or the
178
+ frame's outer edge (``frame``, only with the ``frame`` edge)."""
179
+
180
+ CANVAS = "canvas"
181
+ FRAME = "frame"
182
+
183
+
184
+ class PaintingRebuildStatus(StrEnum):
185
+ """An edit's rebuild: ``running`` or ``failed``. The delivered model stays served during
186
+ and after it."""
187
+
188
+ RUNNING = "running"
189
+ FAILED = "failed"
190
+
191
+
166
192
  # --- Requests --------------------------------------------------------------------------------
167
193
 
168
194
 
@@ -174,6 +200,34 @@ class ModelDimensions(_Base):
174
200
  depth: float | None = None
175
201
 
176
202
 
203
+ class PaintingOptions(_Base):
204
+ """``ProductDraft.painting`` - its PRESENCE selects the painting path: one inspection of
205
+ the photographs, a model-only order at the normal model price, no product images, and a
206
+ product of form ``painting`` that is always wall-mounted.
207
+
208
+ Sizes ride in the draft's ``dimensions`` + ``unit``: ``width`` x ``height`` describe the
209
+ canvas, or the frame's outer edge when ``dimensions_of`` is ``frame``; ``depth`` is the
210
+ slab's and only applies to a ``solid`` or ``stretch`` edge. Every size is optional: with
211
+ none, the canvas's long side is 50 cm and a slab is 2 cm deep. ``edge`` left unset is
212
+ ``frame`` when the analysis finds a frame and ``solid`` otherwise.
213
+ """
214
+
215
+ edge: PaintingEdge | None = None
216
+ edge_color: str = "#FFFFFF"
217
+ dimensions_of: PaintingDimensionsOf = PaintingDimensionsOf.CANVAS
218
+
219
+
220
+ class PaintingUpdate(_Base):
221
+ """``ProductUpdateRequest.painting`` - a painting's settings edit, field by field (an
222
+ omitted field keeps its value). ``frame`` only for a painting ordered with a frame; one
223
+ ordered without can never get one. New sizes go in the request's ``dimensions`` + ``unit``.
224
+ """
225
+
226
+ edge: PaintingEdge | None = None
227
+ edge_color: str | None = None
228
+ dimensions_of: PaintingDimensionsOf | None = None
229
+
230
+
177
231
  class ProductDraft(_Base):
178
232
  """The customer-editable half of a product, sent at park and again at resume.
179
233
 
@@ -195,6 +249,7 @@ class ProductDraft(_Base):
195
249
  dimensions: ModelDimensions | None = None
196
250
  unit: DimensionUnit | None = None
197
251
  wall_mounted: bool | None = None
252
+ painting: PaintingOptions | None = None
198
253
 
199
254
 
200
255
  class ProductOrder(_Base):
@@ -247,7 +302,12 @@ class ProductCreateRequest(_Base):
247
302
  class ProductUpdateRequest(_Base):
248
303
  """PATCH /v1/products/{id} - the customer's fields, the user-set status (never back to
249
304
  ``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``."""
305
+ ``products.rescale`` re-applies them to the GLB. 409 on a duplicate ``custom_id``.
306
+
307
+ A PAINTING is different: ``painting`` and ``dimensions`` (with ``unit``) are its settings,
308
+ and changing either rebuilds its model in the background (``Product.painting.rebuild``).
309
+ The delivered model stays ready and served meanwhile.
310
+ """
251
311
 
252
312
  title: str | None = None
253
313
  description: str | None = None
@@ -262,6 +322,7 @@ class ProductUpdateRequest(_Base):
262
322
  wall_mounted: bool | None = None
263
323
  status: ProductStatus | None = None
264
324
  published: bool | None = None
325
+ painting: PaintingUpdate | None = None
265
326
 
266
327
 
267
328
  class ProductPublishRequest(_Base):
@@ -510,6 +571,18 @@ class ModelPlan(_Base):
510
571
  unseen_views: list[str] = Field(default_factory=list)
511
572
 
512
573
 
574
+ class PaintingInspection(_Base):
575
+ """What the painting analysis found: whether a photograph shows the whole artwork front-on
576
+ and unobscured (``usable``), whether it is framed, and why. ``suggested_dimensions_of`` is
577
+ ``frame`` only when the piece is framed and its product page's stated size reads as the
578
+ framed size."""
579
+
580
+ usable: bool
581
+ framed: bool
582
+ reason: str
583
+ suggested_dimensions_of: PaintingDimensionsOf = PaintingDimensionsOf.CANVAS
584
+
585
+
513
586
  class ProductCost(_Base):
514
587
  """The priced bundle, in CREDITS (1 credit = $0.50): 1 per deliverable image, a flat 10 for
515
588
  a model. Internal 3D gap-fills never enter the maths."""
@@ -545,6 +618,10 @@ class ProductParked(_Base):
545
618
  cost: ProductCost
546
619
  generate_unseen: bool = False
547
620
  force_model: bool = False
621
+ #: The painting path only: what the inspection found. A painting with no usable
622
+ #: photograph parks with ``model.allowed`` false and ``model.blocked_by``
623
+ #: ``["painting_unusable"]``, and its token cannot be committed.
624
+ painting: PaintingInspection | None = None
548
625
 
549
626
 
550
627
  class ProductOrderParked(_Base):
@@ -626,6 +703,48 @@ class ProductModel(_Base):
626
703
  completed_at: datetime | None = None
627
704
 
628
705
 
706
+ class PaintingRequestedSettings(_Base):
707
+ """The settings an edit asked for. Sizes are cm. ``frame_width_cm`` / ``frame_height_cm``
708
+ are set only when the edit was sized by the frame."""
709
+
710
+ edge: PaintingEdge
711
+ edge_color: str
712
+ dimensions_of: PaintingDimensionsOf
713
+ canvas_width_cm: float | None = None
714
+ canvas_height_cm: float | None = None
715
+ depth_cm: float | None = None
716
+ frame_width_cm: float | None = None
717
+ frame_height_cm: float | None = None
718
+
719
+
720
+ class PaintingRebuild(_Base):
721
+ """An edit's rebuild. The model the product shows - and its dimensions and settings - stay
722
+ the delivered ones while it runs and after it fails; a rebuild that succeeds replaces them
723
+ and is then gone. ``error`` is set when it failed (re-apply the edit to retry)."""
724
+
725
+ status: PaintingRebuildStatus
726
+ requested: PaintingRequestedSettings
727
+ requested_at: datetime | None = None
728
+ error: str | None = None
729
+
730
+
731
+ class PaintingSettings(_Base):
732
+ """A painting product's settings, the ones the model being SHOWN was built with. Sizes are
733
+ cm. ``canvas_width_cm`` / ``canvas_height_cm`` are null only while a canvas is still to be
734
+ derived from a size stated for the frame; ``depth_cm`` is the slab's and null for a framed
735
+ painting. ``has_frame`` is true when the painting was ordered with a frame, the only way it
736
+ ever has one. ``rebuild`` is an edit's rebuild in progress or failed (null when none)."""
737
+
738
+ edge: PaintingEdge
739
+ edge_color: str
740
+ dimensions_of: PaintingDimensionsOf
741
+ canvas_width_cm: float | None = None
742
+ canvas_height_cm: float | None = None
743
+ depth_cm: float | None = None
744
+ has_frame: bool = False
745
+ rebuild: PaintingRebuild | None = None
746
+
747
+
629
748
  class ProductSource(_Base):
630
749
  """One photograph or video the product was analyzed from."""
631
750
 
@@ -701,6 +820,8 @@ class Product(ProductSummary):
701
820
  model: ProductModel | None = None
702
821
  warnings: list[ProductWarning] = Field(default_factory=list)
703
822
  open_request_count: int = 0
823
+ #: A painting's settings (form ``painting``); null for every other product.
824
+ painting: PaintingSettings | None = None
704
825
 
705
826
 
706
827
  class PublicProduct(_Base):
@@ -713,6 +834,7 @@ class PublicProduct(_Base):
713
834
  thumbnail_url: str | None = None
714
835
  model_status: AssetStatus | None = None
715
836
  wall_mounted: bool = False
837
+ painting: PaintingSettings | None = None
716
838
 
717
839
 
718
840
  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,6 +35,8 @@ 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,
@@ -150,6 +158,121 @@ def test_force_model_rides_in_the_overrides() -> None:
150
158
  }
151
159
 
152
160
 
161
+ PAINTING_SETTINGS_JSON = {
162
+ "edge": "solid",
163
+ "edge_color": "#FFFFFF",
164
+ "dimensions_of": "canvas",
165
+ "canvas_width_cm": 50.0,
166
+ "canvas_height_cm": 40.0,
167
+ "depth_cm": 2.0,
168
+ "has_frame": True,
169
+ }
170
+
171
+
172
+ def test_a_painting_create_sends_its_options_and_parks_an_unusable_photo() -> None:
173
+ parked = {
174
+ **PARKED_JSON,
175
+ "form": "painting",
176
+ "wall_mounted": True,
177
+ "model": {"ordered": True, "allowed": False, "blocked_by": ["painting_unusable"]},
178
+ "cost": {"images": 0, "image_credits": 0, "model_credits": 0, "total_credits": 0},
179
+ "painting": {
180
+ "usable": False,
181
+ "framed": True,
182
+ "reason": "a hand covers the lower left corner",
183
+ "suggested_dimensions_of": "frame",
184
+ },
185
+ }
186
+ client, rec = make_client(httpx.Response(200, json=parked))
187
+ result = client.products.create(
188
+ ProductCreateRequest(
189
+ image_urls=["https://cdn/art.jpg"],
190
+ draft=ProductDraft(
191
+ title="Harbour at dusk",
192
+ dimensions=ModelDimensions(width=60, height=45),
193
+ painting=PaintingOptions(edge=PaintingEdge.FRAME),
194
+ ),
195
+ )
196
+ )
197
+
198
+ assert isinstance(result, ProductParked)
199
+ assert result.form == "painting" and result.wall_mounted is True
200
+ assert result.model.blocked_by == ["painting_unusable"]
201
+ assert result.painting is not None
202
+ assert result.painting.usable is False
203
+ assert result.painting.suggested_dimensions_of is PaintingDimensionsOf.FRAME
204
+ assert rec.request is not None
205
+ # Only what was set goes on the wire: the API defaults edge_color and dimensions_of.
206
+ assert json.loads(rec.request.content) == {
207
+ "image_urls": ["https://cdn/art.jpg"],
208
+ "draft": {
209
+ "title": "Harbour at dusk",
210
+ "dimensions": {"width": 60.0, "height": 45.0},
211
+ "painting": {"edge": "frame"},
212
+ },
213
+ }
214
+
215
+
216
+ def test_a_painting_edit_patches_its_settings_and_reads_the_rebuild() -> None:
217
+ body = {
218
+ **PRODUCT_JSON,
219
+ "form": "painting",
220
+ "wall_mounted": True,
221
+ "painting": {
222
+ **PAINTING_SETTINGS_JSON,
223
+ "rebuild": {
224
+ "status": "running",
225
+ "requested": {
226
+ **PAINTING_SETTINGS_JSON,
227
+ "edge": "stretch",
228
+ "canvas_width_cm": 70.0,
229
+ "canvas_height_cm": 56.0,
230
+ },
231
+ "requested_at": "2026-10-23T10:00:00Z",
232
+ },
233
+ },
234
+ }
235
+ client, rec = make_client(httpx.Response(200, json=body))
236
+ product = client.products.update(
237
+ "p1",
238
+ ProductUpdateRequest(
239
+ painting=PaintingUpdate(edge=PaintingEdge.STRETCH),
240
+ dimensions=ModelDimensions(width=70),
241
+ ),
242
+ )
243
+
244
+ assert rec.request is not None
245
+ assert rec.request.method == "PATCH"
246
+ assert json.loads(rec.request.content) == {
247
+ "painting": {"edge": "stretch"},
248
+ "dimensions": {"width": 70.0},
249
+ }
250
+ assert product.painting is not None
251
+ # The shown settings stay the delivered ones while the rebuild runs.
252
+ assert product.painting.edge is PaintingEdge.SOLID
253
+ assert product.painting.rebuild is not None
254
+ assert product.painting.rebuild.status is PaintingRebuildStatus.RUNNING
255
+ assert product.painting.rebuild.requested.edge is PaintingEdge.STRETCH
256
+ assert product.painting.rebuild.requested.frame_width_cm is None # sized by the canvas
257
+ assert product.painting.rebuild.error is None
258
+
259
+
260
+ def test_the_public_projection_carries_a_paintings_settings() -> None:
261
+ product = PublicProduct.model_validate(
262
+ {
263
+ "id": "p1",
264
+ "title": "Harbour at dusk",
265
+ "model_status": "ready",
266
+ "wall_mounted": True,
267
+ "painting": PAINTING_SETTINGS_JSON,
268
+ }
269
+ )
270
+
271
+ assert product.painting is not None
272
+ assert product.painting.depth_cm == 2.0
273
+ assert product.painting.rebuild is None
274
+
275
+
153
276
  def test_rescale_posts_to_the_products_own_model_and_parses_the_achieved_size() -> None:
154
277
  body = {**PRODUCT_JSON, "height": 50.8, "display_unit": "in"}
155
278
  client, rec = make_client(httpx.Response(200, json=body))
@@ -2,4 +2,4 @@ import viewrium
2
2
 
3
3
 
4
4
  def test_import() -> None:
5
- assert viewrium.__version__ == "2.1.0"
5
+ assert viewrium.__version__ == "2.2.0"
@@ -448,7 +448,7 @@ wheels = [
448
448
 
449
449
  [[package]]
450
450
  name = "viewrium"
451
- version = "2.1.0"
451
+ version = "2.2.0"
452
452
  source = { editable = "." }
453
453
  dependencies = [
454
454
  { name = "httpx" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes