erp_integration 1.2.0 → 1.4.0

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: 63c63386156abec358b4a911669ec462ccc287806f515a42748bee8adb5688e1
4
- data.tar.gz: 1a614a32dc1e84fb577355c823a1d5c3b8e02fa30a019d3a109e3a35cc2da23b
3
+ metadata.gz: e27a92ae0de43ed91d4194cc581766cbb646a0fb8da4786c61ec7537de3888bb
4
+ data.tar.gz: 729b2b3a413fddd6074ce95828d9db0d0070d563906dd455a6e8ca9d5b37d993
5
5
  SHA512:
6
- metadata.gz: 001ba2ddcc6a601823be103d98273ac88fd39a8ec39e971e44b12a951e312d3661cd8841ab822cc431fdcf30f63196239a04a2cab9a0229858ede8ffab569bc3
7
- data.tar.gz: d43b7377eaa12ef82ce1b7e5351dfd7d49333a1d5b9a6bec865de64b5f76f1e63f45df935c984b323f1bed80afd872395e1446de619fba4cfc17ad67342b2e22
6
+ metadata.gz: d83791e26dba6eb86b7eeb20f3845d0e44d8ea62cf2fbaa0ce2563510bb28ede1bc8b74b6ba6bfd4e4d65b8c072f9a741f355c30a8282755cb6fc50b95a02f04
7
+ data.tar.gz: abfc2d03026c926aecc9cc17853295a31d4ebea6ae86e4eb1fcae12404ee5cae479b10f38d4fe2d1911a1c42edfa814a00679966af3a6416ae7a2e4a3bca55c3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## [v.1.4.0](https://github.com/mejuri-inc/erp-integration/tree/v.1.4.0) (2026-05-18)
4
+
5
+ [Full Changelog](https://github.com/mejuri-inc/erp-integration/compare/v.1.3.0...v.1.4.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - \[BACK-2275\] Add bulk create endpoint [\#233](https://github.com/mejuri-inc/erp-integration/pull/233) ([ikzekly](https://github.com/ikzekly))
10
+
11
+ ## [v.1.3.0](https://github.com/mejuri-inc/erp-integration/tree/v.1.3.0) (2026-05-13)
12
+
13
+ [Full Changelog](https://github.com/mejuri-inc/erp-integration/compare/v.1.2.0...v.1.3.0)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - \[BACK-2271\] Add ProductOptionSet resource [\#231](https://github.com/mejuri-inc/erp-integration/pull/231) ([ikzekly](https://github.com/ikzekly))
18
+
19
+ ## [v.1.2.0](https://github.com/mejuri-inc/erp-integration/tree/v.1.2.0) (2026-05-07)
20
+
21
+ [Full Changelog](https://github.com/mejuri-inc/erp-integration/compare/v.1.1.0...v.1.2.0)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - \[BACK-2222\] Rename `salable` to `sellable` for Product [\#229](https://github.com/mejuri-inc/erp-integration/pull/229) ([ikzekly](https://github.com/ikzekly))
26
+
3
27
  ## [v.0.1.0](https://github.com/mejuri-inc/erp-integration/tree/v.0.1.0) (2021-07-28)
4
28
 
5
29
  [Full Changelog](https://github.com/mejuri-inc/erp-integration/compare/a411f1240265c1e67ed4f07275cb357ffbbdb681...v.0.1.0)
@@ -98,6 +98,11 @@ module ErpIntegration
98
98
  # @return [Symbol] The configured adapter for the product option.
99
99
  attr_writer :product_option_adapter
100
100
 
101
+ # Allows configuring an adapter for the `ProductOptionSet` resource. When
102
+ # none is configured, it will default to Fulfil.
103
+ # @return [Symbol] The configured adapter for the product option set.
104
+ attr_writer :product_option_set_adapter
105
+
101
106
  # Allows configuring an adapter for the `ProductTemplate` resource. When none is
102
107
  # configured, it will default to Fulfil.
103
108
  # @return [Symbol] The configured adapter for the product templates.
@@ -263,6 +268,10 @@ module ErpIntegration
263
268
  @product_option_adapter || :fulfil
264
269
  end
265
270
 
271
+ def product_option_set_adapter
272
+ @product_option_set_adapter || :fulfil
273
+ end
274
+
266
275
  def product_template_adapter
267
276
  @product_template_adapter || :fulfil
268
277
  end
@@ -16,6 +16,31 @@ module ErpIntegration
16
16
  [attributes, [extract_error_message(e)]]
17
17
  end
18
18
 
19
+ # Creates several resources in Fulfil with a single HTTP request.
20
+ #
21
+ # Fulfil's bulk endpoint is atomic: if any record fails validation, the
22
+ # whole batch is rejected with a single error message. There is no
23
+ # per-record error breakdown. Callers needing per-record errors should
24
+ # validate inputs client-side or fall back to per-record `#create`.
25
+ #
26
+ # @param attributes_list [Array<Hash>] One hash per resource to create.
27
+ # @return [Array(Array<Hash>, Array<String>?)] A tuple of the input
28
+ # attributes (with `:id` merged in on success) and an array of error
29
+ # messages (nil on success).
30
+ def bulk_create(attributes_list)
31
+ normalized = normalize_attributes(attributes_list)
32
+ ids = client.post("model/#{model_name}", normalized)
33
+
34
+ unless ids.size == normalized.size
35
+ raise ErpIntegration::Error, "Fulfil returned #{ids.size} ids for #{normalized.size} records"
36
+ end
37
+
38
+ ids.each_with_index { |id, i| normalized[i][:id] = id }
39
+ [normalized, nil]
40
+ rescue ErpIntegration::HttpError::BadRequest => e
41
+ [normalized, [extract_error_message(e)]]
42
+ end
43
+
19
44
  # Updates the resource with the given attributes.
20
45
  #
21
46
  # @param resource_id [Integer] The ID of the resource.
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../api_resource'
4
+
5
+ module ErpIntegration
6
+ module Fulfil
7
+ module Resources
8
+ # Maps `ErpIntegration::ProductOptionSet` to Fulfil's
9
+ # `product_option_set` model. Reachable at
10
+ # `/api/v2/model/product_option_set` on the merchant's Fulfil host.
11
+ #
12
+ # @see https://mejuri.fulfil.io/developer/api-reference/v2/product_option_set
13
+ class ProductOptionSet < ApiResource
14
+ self.model_name = 'product_option_set'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ErpIntegration
4
+ # Groups one or more `ProductOption` records into a named bundle that
5
+ # attaches to product templates. In Fulfil, the option set is what lives
6
+ # on a product template, and its `options` field carries the ids of the
7
+ # individual `ProductOption` records that surface to order lines.
8
+ #
9
+ # @see https://mejuri.fulfil.io/developer/api-reference/v2/product_option_set
10
+ class ProductOptionSet < Resource
11
+ attr_accessor :id, :name, :options
12
+ end
13
+ end
@@ -18,6 +18,25 @@ module ErpIntegration
18
18
  new_resource.validate_with(error_messages)
19
19
  new_resource
20
20
  end
21
+
22
+ # Creates many resources in the ERP with a single request.
23
+ #
24
+ # The underlying adapter call is atomic: a single validation failure
25
+ # rejects the whole batch. On failure, every returned resource is
26
+ # marked invalid with the same shared error message.
27
+ #
28
+ # @param attributes_array [Array<Hash>] Per-record attribute hashes.
29
+ # @return [Array<ErpIntegration::Resource>] The created (or errored)
30
+ # resources, in input order.
31
+ def bulk_create(attributes_array)
32
+ attrs_list, error_messages = adapter.bulk_create(attributes_array)
33
+
34
+ attrs_list.map do |attrs|
35
+ new_resource = new(attrs)
36
+ new_resource.validate_with(error_messages)
37
+ new_resource
38
+ end
39
+ end
21
40
  end
22
41
 
23
42
  # Determines whether a `ErpIntegration::Resource` is considered to be persisted.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ErpIntegration
4
- VERSION = '1.2.0'
4
+ VERSION = '1.4.0'
5
5
  end
@@ -46,6 +46,7 @@ module ErpIntegration
46
46
  autoload :Product, 'erp_integration/product'
47
47
  autoload :ProductCategory, 'erp_integration/product_category'
48
48
  autoload :ProductOption, 'erp_integration/product_option'
49
+ autoload :ProductOptionSet, 'erp_integration/product_option_set'
49
50
  autoload :ProductTemplate, 'erp_integration/product_template'
50
51
  autoload :ProductionOrder, 'erp_integration/production_order'
51
52
  autoload :PurchaseOrder, 'erp_integration/purchase_order'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erp_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Vermaas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-07 00:00:00.000000000 Z
11
+ date: 2026-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -272,6 +272,7 @@ files:
272
272
  - lib/erp_integration/fulfil/resources/product.rb
273
273
  - lib/erp_integration/fulfil/resources/product_category.rb
274
274
  - lib/erp_integration/fulfil/resources/product_option.rb
275
+ - lib/erp_integration/fulfil/resources/product_option_set.rb
275
276
  - lib/erp_integration/fulfil/resources/product_template.rb
276
277
  - lib/erp_integration/fulfil/resources/production_order.rb
277
278
  - lib/erp_integration/fulfil/resources/purchase_order.rb
@@ -303,6 +304,7 @@ files:
303
304
  - lib/erp_integration/product.rb
304
305
  - lib/erp_integration/product_category.rb
305
306
  - lib/erp_integration/product_option.rb
307
+ - lib/erp_integration/product_option_set.rb
306
308
  - lib/erp_integration/product_template.rb
307
309
  - lib/erp_integration/production_order.rb
308
310
  - lib/erp_integration/purchase_order.rb