digiwin_dsp 0.2.3 → 0.2.4
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 +4 -4
- data/CHANGELOG.md +15 -1
- data/lib/digiwin_dsp/resources/base.rb +29 -0
- data/lib/digiwin_dsp/resources/cancellation.rb +2 -17
- data/lib/digiwin_dsp/resources/invoice.rb +2 -17
- data/lib/digiwin_dsp/resources/order.rb +2 -17
- data/lib/digiwin_dsp/resources/return.rb +2 -17
- data/lib/digiwin_dsp/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: feebd7c9c5d89e9d6306b00ecccb402151c9e299201ecf3b98cfbf7c9a1590a1
|
|
4
|
+
data.tar.gz: 7c9fbb5aa913649c417a4f23caf6bf9f3b10bc92b6c2efb34e9cc1cdce8808ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 292e2d148f9af342959a826cbed33999cbd81b169719fa79882b309bfdfb6b1800e88ed18dfcd3d0210784d85f7df9dea1e02e63b0a0f9e67e276e235c7c403d
|
|
7
|
+
data.tar.gz: 437cd4412d96aa9914b99cea75ca5ce06274870aada7a2462b53d64e18eb5ebb03b9dbee07bd78cadab08880652aabe49e7ce88ff987c043be7530ff031c3712
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.2.4] - 2026-05-22
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`Resources::Base`** — shared parent for the 4 resource classes. Each subclass now declares two constants (`PATH`, `SERIALIZER`); the `.create` class shortcut, `#create` instance flow, and the `response_detail` safety check live in one place.
|
|
14
|
+
- **VCR replay coverage.** New `spec/digiwin_dsp/live_replay_spec.rb` + cassettes under `spec/fixtures/cassettes/` verify the gem parses real DSP UAT responses correctly. Credentials filtered via `spec/support/vcr.rb`. Re-record with `RECORD_CASSETTES=1` + real env vars.
|
|
15
|
+
- **`dotenv` auto-loaded in `bin/console`.** Drops a `.env.local` into the IRB session so manual UAT testing is plug-and-play (`bin/console` → `DigiwinDsp::Resources::Order.create(...)`).
|
|
16
|
+
- **GitHub Release auto-created by `release.yml`.** Workflow now extracts the version's CHANGELOG section and posts it with the built `.gem` artifact — no more manual `gh release create` after each version bump.
|
|
17
|
+
|
|
18
|
+
### Docs
|
|
19
|
+
|
|
20
|
+
- Idempotency section in README clarified: DSP UAT ignores `X-Idempotency-Key` (live-verified). Dedup is natural-key only (`form_no + platform_id`). The kwarg is still useful as a trace ID.
|
|
21
|
+
|
|
9
22
|
## [0.2.3] - 2026-05-22
|
|
10
23
|
|
|
11
24
|
### Docs
|
|
@@ -166,7 +179,8 @@ Initial release. Covers the four Self-hosted Website Module (自有官網模組)
|
|
|
166
179
|
- The gem is **synchronous on purpose**. Callers wrap requests in their own background job runner (e.g. ActiveJob) when needed.
|
|
167
180
|
- Idempotency: clients can send `X-Idempotency-Key` via the `idempotency_key:` kwarg. DSP also dedupes server-side by `form_no + platform_id`.
|
|
168
181
|
|
|
169
|
-
[Unreleased]: https://github.com/7a6163/digiwin_dsp/compare/v0.2.
|
|
182
|
+
[Unreleased]: https://github.com/7a6163/digiwin_dsp/compare/v0.2.4...HEAD
|
|
183
|
+
[0.2.4]: https://github.com/7a6163/digiwin_dsp/compare/v0.2.3...v0.2.4
|
|
170
184
|
[0.2.3]: https://github.com/7a6163/digiwin_dsp/compare/v0.2.2...v0.2.3
|
|
171
185
|
[0.2.2]: https://github.com/7a6163/digiwin_dsp/compare/v0.2.1...v0.2.2
|
|
172
186
|
[0.2.1]: https://github.com/7a6163/digiwin_dsp/compare/v0.2.0...v0.2.1
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module DigiwinDsp
|
|
4
|
+
module Resources
|
|
5
|
+
# Subclasses declare two constants:
|
|
6
|
+
# PATH — endpoint path (e.g. "/v1/SalesOrder/add")
|
|
7
|
+
# SERIALIZER — a module/class responding to `.serialize(records, digi_header:)`
|
|
8
|
+
#
|
|
9
|
+
# Base then handles the .create class shortcut, the instance #create flow,
|
|
10
|
+
# and the response_detail safety check.
|
|
11
|
+
class Base
|
|
12
|
+
def self.create(records, idempotency_key: nil, digi_header: nil)
|
|
13
|
+
new.create(records, idempotency_key: idempotency_key, digi_header: digi_header)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize(client = Client.new)
|
|
17
|
+
@client = client
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create(records, idempotency_key: nil, digi_header: nil)
|
|
21
|
+
body = self.class::SERIALIZER.serialize(records, digi_header: digi_header)
|
|
22
|
+
response = @client.post(self.class::PATH, body, idempotency_key: idempotency_key)
|
|
23
|
+
response.fetch("response_detail") do
|
|
24
|
+
raise DigiwinDsp::ServerError, "DSP returned Status=Success without response_detail"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -2,24 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module DigiwinDsp
|
|
4
4
|
module Resources
|
|
5
|
-
class Cancellation
|
|
5
|
+
class Cancellation < Base
|
|
6
6
|
PATH = "/v1/SalesOrder/cancel"
|
|
7
|
-
|
|
8
|
-
def self.create(records, idempotency_key: nil, digi_header: nil)
|
|
9
|
-
new.create(records, idempotency_key: idempotency_key, digi_header: digi_header)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize(client = Client.new)
|
|
13
|
-
@client = client
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def create(records, idempotency_key: nil, digi_header: nil)
|
|
17
|
-
body = Serializers::CancellationSerializer.serialize(records, digi_header: digi_header)
|
|
18
|
-
response = @client.post(PATH, body, idempotency_key: idempotency_key)
|
|
19
|
-
response.fetch("response_detail") do
|
|
20
|
-
raise DigiwinDsp::ServerError, "DSP returned Status=Success without response_detail"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
7
|
+
SERIALIZER = Serializers::CancellationSerializer
|
|
23
8
|
end
|
|
24
9
|
end
|
|
25
10
|
end
|
|
@@ -2,24 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module DigiwinDsp
|
|
4
4
|
module Resources
|
|
5
|
-
class Invoice
|
|
5
|
+
class Invoice < Base
|
|
6
6
|
PATH = "/v1/SalesOrder/invoice"
|
|
7
|
-
|
|
8
|
-
def self.create(records, idempotency_key: nil, digi_header: nil)
|
|
9
|
-
new.create(records, idempotency_key: idempotency_key, digi_header: digi_header)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize(client = Client.new)
|
|
13
|
-
@client = client
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def create(records, idempotency_key: nil, digi_header: nil)
|
|
17
|
-
body = Serializers::InvoiceSerializer.serialize(records, digi_header: digi_header)
|
|
18
|
-
response = @client.post(PATH, body, idempotency_key: idempotency_key)
|
|
19
|
-
response.fetch("response_detail") do
|
|
20
|
-
raise DigiwinDsp::ServerError, "DSP returned Status=Success without response_detail"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
7
|
+
SERIALIZER = Serializers::InvoiceSerializer
|
|
23
8
|
end
|
|
24
9
|
end
|
|
25
10
|
end
|
|
@@ -2,24 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module DigiwinDsp
|
|
4
4
|
module Resources
|
|
5
|
-
class Order
|
|
5
|
+
class Order < Base
|
|
6
6
|
PATH = "/v1/SalesOrder/add"
|
|
7
|
-
|
|
8
|
-
def self.create(records, idempotency_key: nil, digi_header: nil)
|
|
9
|
-
new.create(records, idempotency_key: idempotency_key, digi_header: digi_header)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize(client = Client.new)
|
|
13
|
-
@client = client
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def create(records, idempotency_key: nil, digi_header: nil)
|
|
17
|
-
body = Serializers::SalesOrderSerializer.serialize(records, digi_header: digi_header)
|
|
18
|
-
response = @client.post(PATH, body, idempotency_key: idempotency_key)
|
|
19
|
-
response.fetch("response_detail") do
|
|
20
|
-
raise DigiwinDsp::ServerError, "DSP returned Status=Success without response_detail"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
7
|
+
SERIALIZER = Serializers::SalesOrderSerializer
|
|
23
8
|
end
|
|
24
9
|
end
|
|
25
10
|
end
|
|
@@ -2,24 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module DigiwinDsp
|
|
4
4
|
module Resources
|
|
5
|
-
class Return
|
|
5
|
+
class Return < Base
|
|
6
6
|
PATH = "/v1/SalesOrder/return"
|
|
7
|
-
|
|
8
|
-
def self.create(records, idempotency_key: nil, digi_header: nil)
|
|
9
|
-
new.create(records, idempotency_key: idempotency_key, digi_header: digi_header)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize(client = Client.new)
|
|
13
|
-
@client = client
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def create(records, idempotency_key: nil, digi_header: nil)
|
|
17
|
-
body = Serializers::ReturnSerializer.serialize(records, digi_header: digi_header)
|
|
18
|
-
response = @client.post(PATH, body, idempotency_key: idempotency_key)
|
|
19
|
-
response.fetch("response_detail") do
|
|
20
|
-
raise DigiwinDsp::ServerError, "DSP returned Status=Success without response_detail"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
7
|
+
SERIALIZER = Serializers::ReturnSerializer
|
|
23
8
|
end
|
|
24
9
|
end
|
|
25
10
|
end
|
data/lib/digiwin_dsp/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: digiwin_dsp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zac
|
|
@@ -68,6 +68,7 @@ files:
|
|
|
68
68
|
- lib/digiwin_dsp/authenticator.rb
|
|
69
69
|
- lib/digiwin_dsp/client.rb
|
|
70
70
|
- lib/digiwin_dsp/configuration.rb
|
|
71
|
+
- lib/digiwin_dsp/resources/base.rb
|
|
71
72
|
- lib/digiwin_dsp/resources/cancellation.rb
|
|
72
73
|
- lib/digiwin_dsp/resources/invoice.rb
|
|
73
74
|
- lib/digiwin_dsp/resources/order.rb
|