portage-ucp-magento 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85fd968524956be2175b09568a42d4ebd9613f2004c9dd3e4497b36c14f60eb9
4
- data.tar.gz: f97c08659973cc75e6569cce14166af3e665dc41427442acd8c5fdb08bd42d0c
3
+ metadata.gz: b3973587031e0ee140d788a955da64179f6ee21698f6526dd8bb12cdfe7033d8
4
+ data.tar.gz: b5a5dc8a2c03b3abf21863915011449e86f316d040125e02b82663fdb90298c5
5
5
  SHA512:
6
- metadata.gz: 6ace0250eb9bb47f8efe87fa9e8195ce043c3ff6ec58c7da409070572d8e61358dd54b7916e21f35fcec3873fd45ad1c59e0b5c5b2a35b822631763e856f4a5b
7
- data.tar.gz: a028622437eaf233e7e786419151c9421ed68885c8dab4b569252ce5c5ca66a6352fff7aeea7a3f4add23d453e3246272ea22be72eeb6e340a0e7c954d1246f5
6
+ metadata.gz: a26d7b71335f4c3397483a328a4f6e8d120b9e06f73e9df27e0ea44ae15e4f051bd8af6b4b53fab77e0c717e0757c74457678567c9d7676d20c5fcfc62a0bd9e
7
+ data.tar.gz: 161c64573db509de44bd9922bedebfcf4a1eeeab38a1d210a9e8148bf82dfca061db96b41b72e0f883179e7048b08e062e38087b6f5fc3cafae879efe4c63f11
data/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project are documented here. Format loosely follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.0.0/); this project is
5
5
  pre-1.0, so APIs may still shift between minor versions.
6
6
 
7
+ ## [0.1.1] - 2026-09-15
8
+
9
+ - **Fix:** `Mapper.product`/`.variants` built `Portage::Ucp::Product`/`Variant`
10
+ with the pre-schema `price:`/`available:` keywords core dropped when
11
+ `dev.ucp.shopping.catalog` became schema-conformant — every real
12
+ `search_catalog`/`get_product` call raised `ArgumentError: missing keyword:
13
+ :price_range`. Now builds `Description`/`Price`/`PriceRange` objects and a
14
+ real `Variant` array, matching `Shopify`/`Wix`'s mappers.
15
+ - **Fix:** `Adapter#search_catalog` returned a bare `Array<Product>` instead
16
+ of the `CatalogSearchResult` the `Adapter` contract documents — its wire
17
+ form has no `products` wrapper, so it never validated against UCP's
18
+ `catalog_search.json` response schema.
19
+ - **Fix:** `Adapter#get_product` returned a bare `Product` instead of
20
+ `ProductDetail`, so its wire form had no `product` wrapper either, for the
21
+ same reason as `search_catalog` above.
22
+
7
23
  ## [0.1.0] - Unreleased
8
24
 
9
25
  - Initial pre-release. Magento/Adobe Commerce adapter against the REST v1 API
@@ -63,13 +63,17 @@ module Portage
63
63
  "searchCriteria[filterGroups][0][filters][0][conditionType]" => "like",
64
64
  "searchCriteria[pageSize]" => limit }
65
65
  data = @client.admin_get("/products?#{URI.encode_www_form(params)}")
66
- (data["items"] || []).map { |node| Mapper.product(node, currency: @currency, site_url: @site_url) }
66
+ products = (data["items"] || []).map { |node| Mapper.product(node, currency: @currency, site_url: @site_url) }
67
+ Portage::Ucp::CatalogSearchResult.new(products: products)
67
68
  end
68
69
 
69
70
  def get_product(product_id:)
70
71
  nil_on_not_found do
71
72
  node = @client.admin_get("/products/#{URI.encode_www_form_component(product_id)}")
72
- node["sku"] ? Mapper.product(with_children(node), currency: @currency, site_url: @site_url) : nil
73
+ if node["sku"]
74
+ Portage::Ucp::ProductDetail.new(product: Mapper.product(with_children(node),
75
+ currency: @currency, site_url: @site_url))
76
+ end
73
77
  end
74
78
  end
75
79
 
@@ -33,6 +33,19 @@ module Portage
33
33
  node.dig("extension_attributes", "stock_item", "is_in_stock") != false
34
34
  end
35
35
 
36
+ def description(node)
37
+ Portage::Ucp::Description.new(plain: custom_attribute(node, "description"))
38
+ end
39
+
40
+ def price(amount, currency)
41
+ Portage::Ucp::Price.new(amount: minor_units(amount), currency: currency)
42
+ end
43
+
44
+ def price_range(amount, currency)
45
+ p = price(amount, currency)
46
+ Portage::Ucp::PriceRange.new(min: p, max: p)
47
+ end
48
+
36
49
  # `node["children_detail"]` is adapter-populated, not a real Magento
37
50
  # field: a configurable product's own resource only lists child skus
38
51
  # under `extension_attributes.configurable_product_links` (bare ids)
@@ -44,9 +57,8 @@ module Portage
44
57
  Portage::Ucp::Product.new(
45
58
  id: node["sku"],
46
59
  title: node["name"],
47
- description: custom_attribute(node, "description"),
48
- price: money(node["price"], currency),
49
- available: node["status"] == 1 && in_stock?(node),
60
+ description: description(node),
61
+ price_range: price_range(node["price"], currency),
50
62
  variants: variants(node, currency),
51
63
  url: product_url(node, site_url)
52
64
  )
@@ -65,13 +77,15 @@ module Portage
65
77
  def variants(node, currency)
66
78
  children = node["children_detail"]
67
79
  unless children
68
- return [{ id: node["sku"], title: node["name"], available: node["status"] == 1 && in_stock?(node),
69
- price: money(node["price"], currency) }]
80
+ return [Portage::Ucp::Variant.new(id: node["sku"], title: node["name"], description: description(node),
81
+ price: price(node["price"], currency),
82
+ availability: { "available" => node["status"] == 1 && in_stock?(node) })]
70
83
  end
71
84
 
72
85
  children.map do |c|
73
- { id: c["sku"], title: c["name"], available: c["status"] == 1 && in_stock?(c),
74
- price: money(c["price"], currency) }
86
+ Portage::Ucp::Variant.new(id: c["sku"], title: c["name"], description: description(c),
87
+ price: price(c["price"], currency),
88
+ availability: { "available" => c["status"] == 1 && in_stock?(c) })
75
89
  end
76
90
  end
77
91
 
@@ -1,7 +1,7 @@
1
1
  module Portage
2
2
  module Ucp
3
3
  module Magento
4
- VERSION = "0.1.0".freeze
4
+ VERSION = "0.1.1".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portage-ucp-magento
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Whitbread
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-14 00:00:00.000000000 Z
11
+ date: 2026-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: portage-ucp
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement