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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6a6aca36dc760878fe11e9107416c7296ef5fa7835d1e223f3cab8248970fb7
4
- data.tar.gz: 96fb067d26a7cb40e0b429a8a9f502fa486bc5bc2efcded04bb136bcba4b99c1
3
+ metadata.gz: 0420f85e7559d22ad6d71556fde48379ebc1eb6bbc468613ccdc70cd8a5395fe
4
+ data.tar.gz: 42f8df11ccc3c81fb6157212cca9c8a8ff7f99dc873fd8f85f2ce58b66e6821b
5
5
  SHA512:
6
- metadata.gz: 4cdf8f6a063bb979aecd5d974dd1482329582359831bf0cbb20f46c50987dbbb677e675dd3507c3bbd69883277103760900dc12b55c3650f3215b1e3ab3dc408
7
- data.tar.gz: 6240dd9f19af70f835d4323a5fad194a77ef8be409f503013887095c1bd25ece1331507030443ae8a7ea571aa97c6a47eb6982e0142a2605f467afbd47977564
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
@@ -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, nil_values: %w[nodata])
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 == 'nodata'
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; returns
94
- # nil when the platform answers with nothing at all.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cetustek
4
- VERSION = "0.11.0"
4
+ VERSION = "0.11.1"
5
5
  end
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 one of the documented sentinel strings
45
- # (e.g. "nodata"); ResultError for a bare result code; otherwise the
46
- # parsed root element, ready for parse_fields.
47
- def parse_response(body, nil_values: [])
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? || nil_values.include?(text)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cetustek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac