viewrium 2.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: viewrium
3
- Version: 2.2.0
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` |
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "viewrium"
3
- version = "2.2.0"
3
+ version = "2.3.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"
@@ -115,6 +115,8 @@ from ._models import (
115
115
  UsageEventType,
116
116
  UsageProductTotals,
117
117
  UsageResponse,
118
+ ViewerDesktopMode,
119
+ ViewerMobileMode,
118
120
  WarningKind,
119
121
  WebhookDelivery,
120
122
  WebhookDeliveryListResponse,
@@ -127,7 +129,7 @@ from ._models import (
127
129
  WidthAxis,
128
130
  )
129
131
 
130
- __version__ = "2.2.0"
132
+ __version__ = "2.3.0"
131
133
 
132
134
  __all__ = [
133
135
  "__version__",
@@ -171,6 +173,8 @@ __all__ = [
171
173
  "PaintingEdge",
172
174
  "PaintingDimensionsOf",
173
175
  "PaintingRebuildStatus",
176
+ "ViewerDesktopMode",
177
+ "ViewerMobileMode",
174
178
  # requests
175
179
  "ProductCreateRequest",
176
180
  "ProductDraft",
@@ -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`` / ``update`` / ``delete`` / ``batch_delete`` / ``publish`` / ``tags`` / ``review`` /
5
- ``update_image`` / ``update_model`` / ``rescale`` / ``order`` / ``export``, plus ``api_keys``,
6
- ``usage``, ``webhooks``, ``projects``, ``beacon``). Auth is an ``sk_`` secret key (or ``pk_``
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,6 +255,14 @@ 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
268
  publish toggle. 409 on a ``custom_id`` another product in the org already holds. On a
@@ -173,6 +173,26 @@ class PaintingEdge(StrEnum):
173
173
  STRETCH = "stretch"
174
174
 
175
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
+
176
196
  class PaintingDimensionsOf(StrEnum):
177
197
  """Which rectangle a painting's width x height describe: the ``canvas`` (default) or the
178
198
  frame's outer edge (``frame``, only with the ``frame`` edge)."""
@@ -323,6 +343,9 @@ class ProductUpdateRequest(_Base):
323
343
  status: ProductStatus | None = None
324
344
  published: bool | None = None
325
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
326
349
 
327
350
 
328
351
  class ProductPublishRequest(_Base):
@@ -584,7 +607,7 @@ class PaintingInspection(_Base):
584
607
 
585
608
 
586
609
  class ProductCost(_Base):
587
- """The priced bundle, in CREDITS (1 credit = $0.50): 1 per deliverable image, a flat 10 for
610
+ """The priced bundle, in CREDITS (1 credit = $1.00): 1 per deliverable image, a flat 10 for
588
611
  a model. Internal 3D gap-fills never enter the maths."""
589
612
 
590
613
  images: int
@@ -822,6 +845,8 @@ class Product(ProductSummary):
822
845
  open_request_count: int = 0
823
846
  #: A painting's settings (form ``painting``); null for every other product.
824
847
  painting: PaintingSettings | None = None
848
+ viewer_desktop: ViewerDesktopMode = ViewerDesktopMode.VIEWER
849
+ viewer_mobile: ViewerMobileMode = ViewerMobileMode.VIEWER
825
850
 
826
851
 
827
852
  class PublicProduct(_Base):
@@ -835,6 +860,9 @@ class PublicProduct(_Base):
835
860
  model_status: AssetStatus | None = None
836
861
  wall_mounted: bool = False
837
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
838
866
 
839
867
 
840
868
  class Ticket(_Base):
@@ -41,6 +41,8 @@ from viewrium import (
41
41
  TicketKind,
42
42
  TicketRequest,
43
43
  UnprocessableEntityError,
44
+ ViewerDesktopMode,
45
+ ViewerMobileMode,
44
46
  Viewrium,
45
47
  ViewriumError,
46
48
  WidthAxis,
@@ -271,6 +273,25 @@ def test_the_public_projection_carries_a_paintings_settings() -> None:
271
273
  assert product.painting is not None
272
274
  assert product.painting.depth_cm == 2.0
273
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
274
295
 
275
296
 
276
297
  def test_rescale_posts_to_the_products_own_model_and_parses_the_achieved_size() -> None:
@@ -432,6 +453,19 @@ def test_tags_reads_the_catalogs_own_tag_route() -> None:
432
453
  assert rec.request.url.params.get("scope") == "all"
433
454
 
434
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
+
435
469
  def test_beacon_send_uses_pk_key() -> None:
436
470
  client, rec = make_client(httpx.Response(204), api_key="pk_live_1")
437
471
  client.beacon.send(BeaconRequest(model_id="p1", event_type=BeaconEventType.VIEW))
@@ -2,4 +2,4 @@ import viewrium
2
2
 
3
3
 
4
4
  def test_import() -> None:
5
- assert viewrium.__version__ == "2.2.0"
5
+ assert viewrium.__version__ == "2.3.0"
@@ -448,7 +448,7 @@ wheels = [
448
448
 
449
449
  [[package]]
450
450
  name = "viewrium"
451
- version = "2.2.0"
451
+ version = "2.3.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