cin7_core_api 0.2.1 → 0.3.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: 237cda18aeb79904a6fed79dc9deaa53240aff6d45f659d0163f14188af06126
4
- data.tar.gz: 3ba7316e959ec28916abb55e3036e0550d68ce626be3c0ac08fc80eda8a8bfb8
3
+ metadata.gz: bebb9103f8de0eff128f3225cb97eeacca8137b6501f09051858053e79443cf6
4
+ data.tar.gz: 27a765beb403a6279b6d74d25952688b304252e3308b22b47ada21f46c920401
5
5
  SHA512:
6
- metadata.gz: caff2995e25a658cd0aaf75513389850a0347a8aa4fc0f38ee3b99015a2e02a9bccd758edecedb4187f06fbd2360bb25ae6ce944a10b1a7fc6fc454f1c02910c
7
- data.tar.gz: 932d8ea1d610710377946799c1224e099b3e4d6b5cf6b99d5ac32b01e28d7a07cb7bdd563291246430126f01e07f295dd8a1d70d235708ea8a8ed2f527d0b563
6
+ metadata.gz: d007332b45d5a02e5810eabd256b24c77156e34fd737c3d68cf671608a9a149978380b21c9398be56d72430fa0ad3beaf28d56015c404b564a3bb838d98f1cb1
7
+ data.tar.gz: 3be8c44fc59d964e1fea08eede44326e6a38eff0885f7426c11986f23a383901c6215181b1fcca04f17306c667e2ce300336661e24e72e4d3a55d3f93529d5aa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0] - 2026-10-02
4
+
5
+ - Add explicit credit-note creation/undo and Advanced Sale fulfilment, pick, pack and shipment resources with readback and distinct POST/PUT semantics.
6
+ - Add sale-header creation plus product, stock availability and carrier reads so sandbox preparation uses resource methods throughout.
7
+ - Preserve caller-supplied task IDs, monetary values, restock and shipment collections; do not select eligibility, append lines or restore inventory implicitly.
8
+
3
9
  ## [0.2.1] - 2026-10-02
4
10
 
5
11
  - 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:
@@ -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
@@ -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.0"
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,7 +1,7 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PostCo
@@ -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