cetustek 0.11.0 → 0.11.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/cetustek/queries.rb +4 -4
- data/lib/cetustek/version.rb +1 -1
- data/lib/cetustek/xml.rb +8 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0420f85e7559d22ad6d71556fde48379ebc1eb6bbc468613ccdc70cd8a5395fe
|
|
4
|
+
data.tar.gz: 42f8df11ccc3c81fb6157212cca9c8a8ff7f99dc873fd8f85f2ce58b66e6821b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24d02adabed95531ab98e07470dad9192781a0e8b2ad293fc73962e8dbeb4e06b7bcab193cc9d2697620820f0b6e2f8ff569105e32b6fde400440b7b0d86920d
|
|
7
|
+
data.tar.gz: 5deefced44974194851bd8c628fb35a21c1a3435e6cced143bab22a195f4b478d4db02701cd893caec4aba005ba4b70664830c523af954363b2e365aea4a79cb
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.11.1] - 2026-09-04
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- `QueryAllowance.find` 查無折讓單時會 raise `ResultError: nodata`,而不是回 nil。
|
|
13
|
+
`nodata` 的判斷原本是 `Xml.parse_response` 的 `nil_values:` 參數,只有
|
|
14
|
+
`QueryInvoice` 有傳。改成 `Xml::NIL_VALUES` 常數,所有查詢共用同一個判斷。
|
|
15
|
+
|
|
8
16
|
## [0.11.0] - 2026-08-24
|
|
9
17
|
|
|
10
18
|
### Added
|
data/lib/cetustek/queries.rb
CHANGED
|
@@ -30,7 +30,7 @@ module Cetustek
|
|
|
30
30
|
# §2.5 QueryInvoicebyOrderid shares this exact XML shape (Table 13), so
|
|
31
31
|
# QueryInvoiceByOrderId#find reuses this instead of duplicating it.
|
|
32
32
|
def self.parse(xml)
|
|
33
|
-
root = Xml.parse_response(xml
|
|
33
|
+
root = Xml.parse_response(xml)
|
|
34
34
|
return nil unless root
|
|
35
35
|
|
|
36
36
|
data = Xml.parse_fields(root, FIELDS)
|
|
@@ -66,7 +66,7 @@ module Cetustek
|
|
|
66
66
|
# Query* classes — it used to be returned as if it were the number.
|
|
67
67
|
def self.find(order_id)
|
|
68
68
|
body = soap_return(query(order_id), :query_invoice_number_by_orderid).to_s.strip
|
|
69
|
-
return nil if body.empty? || body
|
|
69
|
+
return nil if body.empty? || Xml::NIL_VALUES.include?(body)
|
|
70
70
|
return body if body.match?(FORMAT)
|
|
71
71
|
|
|
72
72
|
ResultCode.raise!(body, ResultCode::COMMON)
|
|
@@ -90,8 +90,8 @@ module Cetustek
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
# Same query, with the returned XML parsed into a Hash of snake_case keys
|
|
93
|
-
# plus a :details array. Values are the raw strings from the XML;
|
|
94
|
-
#
|
|
93
|
+
# plus a :details array. Values are the raw strings from the XML; nil when
|
|
94
|
+
# the platform answers with nothing at all, or the documented "nodata".
|
|
95
95
|
def self.find(allowance_number)
|
|
96
96
|
parse(soap_return(query(allowance_number), :query_allowance))
|
|
97
97
|
end
|
data/lib/cetustek/version.rb
CHANGED
data/lib/cetustek/xml.rb
CHANGED
|
@@ -8,6 +8,8 @@ module Cetustek
|
|
|
8
8
|
# and a single <Invoice>/<Allowance> root carrying XSDVersion.
|
|
9
9
|
module Xml
|
|
10
10
|
XSD_VERSION = '2.8'
|
|
11
|
+
# 查無資料時平台回的字串,不是結果代碼。
|
|
12
|
+
NIL_VALUES = %w[nodata].freeze
|
|
11
13
|
|
|
12
14
|
module_function
|
|
13
15
|
|
|
@@ -41,12 +43,13 @@ module Cetustek
|
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
# Shared guard every Query* class needs before it can parse a response
|
|
44
|
-
# body: nil for an empty answer or
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
|
|
46
|
+
# body: nil for an empty answer or the documented "nodata" sentinel;
|
|
47
|
+
# ResultError for a bare result code; otherwise the parsed root element,
|
|
48
|
+
# ready for parse_fields. "nodata" is not per-query — every 查詢 answers
|
|
49
|
+
# with it when the number simply isn't there, so it lives here.
|
|
50
|
+
def parse_response(body)
|
|
48
51
|
text = body.to_s.strip
|
|
49
|
-
return nil if text.empty? ||
|
|
52
|
+
return nil if text.empty? || NIL_VALUES.include?(text)
|
|
50
53
|
|
|
51
54
|
ResultCode.raise!(text, ResultCode::COMMON) unless text.start_with?('<')
|
|
52
55
|
|