cin7_core_api 0.2.1 → 0.3.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: 237cda18aeb79904a6fed79dc9deaa53240aff6d45f659d0163f14188af06126
4
- data.tar.gz: 3ba7316e959ec28916abb55e3036e0550d68ce626be3c0ac08fc80eda8a8bfb8
3
+ metadata.gz: f21c5a07972b89e6cd344f6db539ce6dee6cdd5734dc69bff3a9c1f410f0ec4a
4
+ data.tar.gz: 5ab77af8749ea07602cbe26bc0fee753f20e2f7145f83e9c6ff009399f9c79f3
5
5
  SHA512:
6
- metadata.gz: caff2995e25a658cd0aaf75513389850a0347a8aa4fc0f38ee3b99015a2e02a9bccd758edecedb4187f06fbd2360bb25ae6ce944a10b1a7fc6fc454f1c02910c
7
- data.tar.gz: 932d8ea1d610710377946799c1224e099b3e4d6b5cf6b99d5ac32b01e28d7a07cb7bdd563291246430126f01e07f295dd8a1d70d235708ea8a8ed2f527d0b563
6
+ metadata.gz: c7a38afa25859861feb348204718c98a8711a196461f73f9f7e9e14208dddac1a5b66f786b6bfdd8a1f77dd9b7e15bdc5c03a7d2a00f76ca03e74cc33c0951a7
7
+ data.tar.gz: ce282fe173d4d3c43e0be08ad1efd497d19b0115c9420a4f9289a12e0093566c0bb34209888335493b69b149f2e10b127840d77b7476de5301844a6f9fb07eab
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.1] - 2026-10-20
4
+
5
+ - Name the error Faraday wraps in transport failure messages, such as `Faraday::ConnectionFailed caused by Zlib::DataError` for a corrupt gzip response under faraday-net_http 3.5 and `Faraday::TimeoutError caused by Net::ReadTimeout` for a read timeout on any adapter version.
6
+
7
+ ## [0.3.0] - 2026-10-02
8
+
9
+ - Add explicit credit-note creation/undo and Advanced Sale fulfilment, pick, pack and shipment resources with readback and distinct POST/PUT semantics.
10
+ - Add sale-header creation plus product, stock availability and carrier reads so sandbox preparation uses resource methods throughout.
11
+ - Preserve caller-supplied task IDs, monetary values, restock and shipment collections; do not select eligibility, append lines or restore inventory implicitly.
12
+
3
13
  ## [0.2.1] - 2026-10-02
4
14
 
5
15
  - Keep decompression failures and malformed UTF-8 responses, including invalid decoded JSON strings, inside the sanitized error contract, preserving uncertain-write recovery without retries.
data/README.md CHANGED
@@ -9,7 +9,7 @@ Version `0.2.0` adds explicit payment, order, invoice, journal, and webhook oper
9
9
  Add the gem to your Gemfile:
10
10
 
11
11
  ```ruby
12
- gem "cin7_core_api", "0.2.1"
12
+ gem "cin7_core_api", "0.3.0"
13
13
  ```
14
14
 
15
15
  Then run:
@@ -22,6 +22,38 @@ Ruby 3.3 or newer is required.
22
22
 
23
23
  Version `0.2.1` adds response-decoding safety and callback-identity fixes. Published `0.2.0` remains unchanged. Check RubyGems for publication availability; to evaluate a reviewed source before publication, pin its full commit SHA from this repository.
24
24
 
25
+ Version `0.3.0` adds the explicit native correction and sandbox preparation resources below. It includes the `0.2.1` safety fixes.
26
+
27
+ ## Native correction and sandbox preparation
28
+
29
+ These methods use the same sanitized errors and never retry. Payloads use Cin7 String field names. `sale_id:` identifies the parent sale; `task_id:` identifies the particular credit-note or fulfilment task.
30
+
31
+ | Resource method | HTTP contract |
32
+ | --- | --- |
33
+ | `sales.create(payload:)` | POST `sale`; create a header with caller-selected customer, sale type and options |
34
+ | `credit_notes.create(payload:)` | POST `sale/creditnote`; explicit `SaleID` and `TaskID` |
35
+ | `credit_notes.undo(task_id:)` | DELETE `sale/creditnote` with `TaskID` and `Void=false` |
36
+ | `fulfilments.for_sale(sale_id:, include_product_info: false)` | GET `sale/fulfilment`; preserve its `Fulfilments` response collection |
37
+ | `fulfilments.create(payload:)` | POST `sale/fulfilment`; explicit `SaleID` |
38
+ | `fulfilments.undo(task_id:)` | DELETE `sale/fulfilment` with `TaskID` and `Void=false` |
39
+ | `picks.for_task(task_id:, include_product_info: false)` | GET `sale/fulfilment/pick` |
40
+ | `packs.for_task(task_id:, include_product_info: false)` | GET `sale/fulfilment/pack` |
41
+ | `shipments.for_task(task_id:)` | GET `sale/fulfilment/ship` |
42
+ | `picks.create/update(payload:)` | POST/PUT `sale/fulfilment/pick`; explicit `TaskID` |
43
+ | `packs.create/update(payload:)` | POST/PUT `sale/fulfilment/pack`; explicit `TaskID` |
44
+ | `shipments.create/update(payload:)` | POST/PUT `sale/fulfilment/ship`; explicit `TaskID` |
45
+ | `products.list(**filters)` | GET `product`; supports documented product discovery filters |
46
+ | `product_availability.list(**filters)` | GET `ref/productavailability`; `page`, `limit`, `id`, `name`, `sku`, `location`, `batch`, `category` |
47
+ | `carriers.list(**filters)` | GET `ref/carrier`; `page`, `limit`, `carrier_id`, `description` |
48
+
49
+ Cin7 documents credit-note **POST**, not PUT. Use `create` for an explicit new task or a draft/not-available task; it does not overwrite an authorised note by itself. For a new note, the caller may supply the documented empty GUID `TaskID`; the gem never chooses or inserts it. Forward complete `Lines`, `AdditionalCharges` and `Restock` collections deliberately.
50
+
51
+ The provider's credit-note DELETE eligibility is unusually narrow and duplicated in its Blueprint: Advanced Sale with credit-note `TaskID = SaleID`. Its applicability to connector-created secondary notes is unproven. Exposing `undo` does not establish that a particular paid, taxed or restocked note can be rebuilt safely. The caller must inspect state, preserve payouts and inventory ownership, check the actual rejection/readback and recover uncertain outcomes before proceeding.
52
+
53
+ Fulfilment `create` can convert a Simple Sale to Advanced Sale. Pack and shipment **POST may append lines**, while **PUT replaces** eligible draft/not-available documents. Shipment PUT must include all required packed boxes. The caller must preserve quantities, locations, batches, boxes and shipment identity and verify inventory after any restoration. The gem does not authorise a previously fulfilled sale correction or run pick/pack/ship automatically.
54
+
55
+ The `products` filters are `id`, `page`, `limit`, `name`, `sku`, `modified_since`, `include_deprecated`, `include_bom`, `include_suppliers`, `include_movements`, `include_attachments`, `include_reorder_levels`, and `include_custom_prices`. Nil filters are omitted, boolean false is retained, and unsupported filters fail before dispatch.
56
+
25
57
  ## Authentication
26
58
 
27
59
  Create a client using the Account ID and API Application Key from CIN7 Core's API setup page:
@@ -257,15 +289,15 @@ Stage intended new source/spec files before using the tracked-file lint command.
257
289
 
258
290
  ## Releasing
259
291
 
260
- Publishing a GitHub release triggers `.github/workflows/release.yml`. It requires the tagged commit to be part of `main`, verifies the tag matches `v<VERSION>`, runs tests and lint, builds the gem, and publishes that exact version to RubyGems. Draft releases and ordinary branch pushes do not publish gems.
292
+ Publishing a GitHub release triggers `.github/workflows/release.yml`. Its `test` job runs tests and lint without publishing rights. The `publish` job then requires the tagged commit to be part of `main`, verifies the tag matches `v<VERSION>`, builds the gem with plain `gem build`, and publishes that exact version to RubyGems. `publish` holds the RubyGems token, so it never installs gems or runs Bundler; keep it that way. It waits for a required reviewer to approve the `release` environment, which accepts only `v*` tags. Draft releases and ordinary branch pushes do not publish gems.
261
293
 
262
- One-time setup: in the `cin7_core_api` gem's RubyGems **Trusted publishers** settings, register repository owner `PostCo`, repository `cin7_core_api`, workflow filename `release.yml`, and environment `release`. Use the same `release` environment in GitHub. [RubyGems Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) uses GitHub OIDC, so no long-lived API key or interactive MFA code is needed in CI. Signing in locally does not configure this trust relationship.
294
+ One-time setup: in the `cin7_core_api` gem's RubyGems **Trusted publishers** settings, register repository owner `PostCo`, repository `cin7_core_api`, workflow filename `release.yml`, and environment `release`. Use the same `release` environment in GitHub, with a required reviewer and a `v*` tag deployment rule. [RubyGems Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) uses GitHub OIDC, so no long-lived API key or interactive MFA code is needed in CI. Signing in locally does not configure this trust relationship.
263
295
 
264
296
  For each new version:
265
297
 
266
298
  1. Update `lib/cin7_core_api/version.rb` and `CHANGELOG.md`, review the PR, and merge it into `main`.
267
299
  2. Create and publish a GitHub release at that merged commit, with a tag such as `v0.2.1` matching the gem version.
268
- 3. Check the **Publish gem** workflow and verify the version is available on RubyGems before updating application dependencies.
300
+ 3. Approve the **Publish gem** workflow's `release` deployment once `test` passes, then verify the version is available on RubyGems before updating application dependencies.
269
301
 
270
302
  The manually published `0.2.0` already exists. Do not republish it; this workflow is for subsequent versions. A failed attempt to publish an existing version does not replace that version. If a workflow is rerun after a partial success, check RubyGems first.
271
303
 
@@ -89,6 +89,34 @@ module Cin7CoreAPI
89
89
  @webhooks ||= Resources::Webhooks.new(connection)
90
90
  end
91
91
 
92
+ def fulfilments
93
+ @fulfilments ||= Resources::Fulfilments.new(connection)
94
+ end
95
+
96
+ def picks
97
+ @picks ||= Resources::Picks.new(connection)
98
+ end
99
+
100
+ def packs
101
+ @packs ||= Resources::Packs.new(connection)
102
+ end
103
+
104
+ def shipments
105
+ @shipments ||= Resources::Shipments.new(connection)
106
+ end
107
+
108
+ def products
109
+ @products ||= Resources::Products.new(connection)
110
+ end
111
+
112
+ def product_availability
113
+ @product_availability ||= Resources::ProductAvailability.new(connection)
114
+ end
115
+
116
+ def carriers
117
+ @carriers ||= Resources::Carriers.new(connection)
118
+ end
119
+
92
120
  def inspect
93
121
  "#<#{self.class}>"
94
122
  end
@@ -81,8 +81,10 @@ module Cin7CoreAPI
81
81
  request.params.update(params)
82
82
  end
83
83
  rescue Faraday::Error, Zlib::Error => error
84
+ wrapped = error.wrapped_exception if error.is_a?(Faraday::Error)
85
+ failure = [error.class, wrapped&.class].compact.join(" caused by ")
84
86
  # Faraday exceptions can retain the entire authenticated request in their cause.
85
- raise TransportError.new("CIN7 Core transport failed (#{error.class})", ambiguous: write, **context), cause: nil
87
+ raise TransportError.new("CIN7 Core transport failed (#{failure})", ambiguous: write, **context), cause: nil
86
88
  end
87
89
 
88
90
  def normalized_headers(headers)
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cin7CoreAPI
4
+ module Resources
5
+ class Carriers < Base
6
+ PARAMETERS = {page: "Page", limit: "Limit", carrier_id: "CarrierID", description: "Description"}.freeze
7
+
8
+ def list(**filters)
9
+ get("ref/carrier", params: filters, parameter_map: PARAMETERS)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -29,6 +29,16 @@ module Cin7CoreAPI
29
29
  require_parameter!(:sale_id, sale_id)
30
30
  get("sale/creditnote", params: options.merge(sale_id: sale_id), parameter_map: FOR_SALE_PARAMETERS)
31
31
  end
32
+
33
+ def create(payload:)
34
+ validate_payload!(payload, "SaleID", "TaskID")
35
+ connection.post("sale/creditnote", payload: payload)
36
+ end
37
+
38
+ def undo(task_id:)
39
+ require_parameter!(:task_id, task_id)
40
+ connection.delete("sale/creditnote", params: {"TaskID" => task_id, "Void" => false})
41
+ end
32
42
  end
33
43
  end
34
44
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cin7CoreAPI
4
+ module Resources
5
+ class Fulfilments < Base
6
+ PARAMETERS = {sale_id: "SaleID", include_product_info: "IncludeProductInfo"}.freeze
7
+
8
+ def for_sale(sale_id:, **options)
9
+ require_parameter!(:sale_id, sale_id)
10
+ get("sale/fulfilment", params: options.merge(sale_id: sale_id), parameter_map: PARAMETERS)
11
+ end
12
+
13
+ def create(payload:)
14
+ validate_payload!(payload, "SaleID")
15
+ connection.post("sale/fulfilment", payload: payload)
16
+ end
17
+
18
+ def undo(task_id:)
19
+ require_parameter!(:task_id, task_id)
20
+ connection.delete("sale/fulfilment", params: {"TaskID" => task_id, "Void" => false})
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cin7CoreAPI
4
+ module Resources
5
+ class Packs < Base
6
+ PARAMETERS = {task_id: "TaskID", include_product_info: "IncludeProductInfo"}.freeze
7
+
8
+ def for_task(task_id:, **options)
9
+ require_parameter!(:task_id, task_id)
10
+ get("sale/fulfilment/pack", params: options.merge(task_id: task_id), parameter_map: PARAMETERS)
11
+ end
12
+
13
+ def create(payload:)
14
+ validate_payload!(payload, "TaskID")
15
+ connection.post("sale/fulfilment/pack", payload: payload)
16
+ end
17
+
18
+ def update(payload:)
19
+ validate_payload!(payload, "TaskID")
20
+ connection.put("sale/fulfilment/pack", payload: payload)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cin7CoreAPI
4
+ module Resources
5
+ class Picks < Base
6
+ PARAMETERS = {task_id: "TaskID", include_product_info: "IncludeProductInfo"}.freeze
7
+
8
+ def for_task(task_id:, **options)
9
+ require_parameter!(:task_id, task_id)
10
+ get("sale/fulfilment/pick", params: options.merge(task_id: task_id), parameter_map: PARAMETERS)
11
+ end
12
+
13
+ def create(payload:)
14
+ validate_payload!(payload, "TaskID")
15
+ connection.post("sale/fulfilment/pick", payload: payload)
16
+ end
17
+
18
+ def update(payload:)
19
+ validate_payload!(payload, "TaskID")
20
+ connection.put("sale/fulfilment/pick", payload: payload)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cin7CoreAPI
4
+ module Resources
5
+ class ProductAvailability < Base
6
+ PARAMETERS = {
7
+ page: "Page", limit: "Limit", id: "ID", name: "Name", sku: "Sku",
8
+ location: "Location", batch: "Batch", category: "Category"
9
+ }.freeze
10
+
11
+ def list(**filters)
12
+ get("ref/productavailability", params: filters, parameter_map: PARAMETERS)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cin7CoreAPI
4
+ module Resources
5
+ class Products < Base
6
+ PARAMETERS = {
7
+ id: "ID", page: "Page", limit: "Limit", name: "Name", sku: "Sku", modified_since: "ModifiedSince",
8
+ include_deprecated: "IncludeDeprecated", include_bom: "IncludeBOM", include_suppliers: "IncludeSuppliers",
9
+ include_movements: "IncludeMovements", include_attachments: "IncludeAttachments",
10
+ include_reorder_levels: "IncludeReorderLevels", include_custom_prices: "IncludeCustomPrices"
11
+ }.freeze
12
+
13
+ def list(**filters)
14
+ get("product", params: filters, parameter_map: PARAMETERS)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -41,6 +41,11 @@ module Cin7CoreAPI
41
41
  get("sale", params: options.merge(id: id), parameter_map: RETRIEVE_PARAMETERS)
42
42
  end
43
43
 
44
+ def create(payload:)
45
+ validate_payload!(payload)
46
+ connection.post("sale", payload: payload)
47
+ end
48
+
44
49
  def update(payload:)
45
50
  validate_payload!(payload, "ID")
46
51
  connection.put("sale", payload: payload)
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cin7CoreAPI
4
+ module Resources
5
+ class Shipments < Base
6
+ def for_task(task_id:)
7
+ require_parameter!(:task_id, task_id)
8
+ get("sale/fulfilment/ship", params: {task_id: task_id}, parameter_map: {task_id: "TaskID"})
9
+ end
10
+
11
+ def create(payload:)
12
+ validate_payload!(payload, "TaskID")
13
+ connection.post("sale/fulfilment/ship", payload: payload)
14
+ end
15
+
16
+ def update(payload:)
17
+ validate_payload!(payload, "TaskID")
18
+ connection.put("sale/fulfilment/ship", payload: payload)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cin7CoreAPI
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/cin7_core_api.rb CHANGED
@@ -21,6 +21,13 @@ require_relative "cin7_core_api/resources/manual_journals"
21
21
  require_relative "cin7_core_api/resources/journals"
22
22
  require_relative "cin7_core_api/resources/tax_rules"
23
23
  require_relative "cin7_core_api/resources/webhooks"
24
+ require_relative "cin7_core_api/resources/fulfilments"
25
+ require_relative "cin7_core_api/resources/picks"
26
+ require_relative "cin7_core_api/resources/packs"
27
+ require_relative "cin7_core_api/resources/shipments"
28
+ require_relative "cin7_core_api/resources/products"
29
+ require_relative "cin7_core_api/resources/product_availability"
30
+ require_relative "cin7_core_api/resources/carriers"
24
31
  require_relative "cin7_core_api/client"
25
32
 
26
33
  module Cin7CoreAPI
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cin7_core_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostCo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-01 00:00:00.000000000 Z
11
+ date: 2026-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -123,17 +123,24 @@ files:
123
123
  - lib/cin7_core_api/resources/accounts.rb
124
124
  - lib/cin7_core_api/resources/bank_accounts.rb
125
125
  - lib/cin7_core_api/resources/base.rb
126
+ - lib/cin7_core_api/resources/carriers.rb
126
127
  - lib/cin7_core_api/resources/credit_notes.rb
127
128
  - lib/cin7_core_api/resources/customer_credits.rb
128
129
  - lib/cin7_core_api/resources/customers.rb
130
+ - lib/cin7_core_api/resources/fulfilments.rb
129
131
  - lib/cin7_core_api/resources/invoices.rb
130
132
  - lib/cin7_core_api/resources/journals.rb
131
133
  - lib/cin7_core_api/resources/locations.rb
132
134
  - lib/cin7_core_api/resources/manual_journals.rb
133
135
  - lib/cin7_core_api/resources/me.rb
134
136
  - lib/cin7_core_api/resources/orders.rb
137
+ - lib/cin7_core_api/resources/packs.rb
135
138
  - lib/cin7_core_api/resources/payments.rb
139
+ - lib/cin7_core_api/resources/picks.rb
140
+ - lib/cin7_core_api/resources/product_availability.rb
141
+ - lib/cin7_core_api/resources/products.rb
136
142
  - lib/cin7_core_api/resources/sales.rb
143
+ - lib/cin7_core_api/resources/shipments.rb
137
144
  - lib/cin7_core_api/resources/tax_rules.rb
138
145
  - lib/cin7_core_api/resources/webhooks.rb
139
146
  - lib/cin7_core_api/response.rb