Class: Cetustek::CancelAllowance
- Inherits:
-
Object
- Object
- Cetustek::CancelAllowance
- Includes:
- Soap
- Defined in:
- lib/cetustek/cancel_allowance.rb
Overview
2.10 CancelAllowance 作廢折讓單. Returns "C0" on success, raises ResultError otherwise.
Constant Summary collapse
- SUCCESS_CODE =
'C0'- MAX_REASON_LENGTH =
20- RESULT_MESSAGES =
Spec AVM-26-03 Table 19.
ResultCode::COMMON.merge( 'C1' => '上傳失敗', 'C2' => '折讓單已申報,無法作廢', 'C3' => '折讓單號不存在或須為已確認後的折讓單', 'C4' => '該作廢折讓單已經上傳', 'C5' => '折讓單已過作廢期限,無法作廢' ).freeze
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(allowance_number, reason) ⇒ CancelAllowance
constructor
Table 18 has only these two fields, both 必填.
Methods included from Soap
#rentid, #soap_call, #soap_client, #soap_return, #source
Constructor Details
#initialize(allowance_number, reason) ⇒ CancelAllowance
Table 18 has only these two fields, both 必填.
21 22 23 24 25 26 27 28 |
# File 'lib/cetustek/cancel_allowance.rb', line 21 def initialize(allowance_number, reason) raise ArgumentError, 'allowance_number is required' if allowance_number.to_s.strip.empty? raise ArgumentError, 'reason (作廢原因) is required' if reason.to_s.strip.empty? raise ArgumentError, "reason must not exceed #{MAX_REASON_LENGTH} characters" if reason.length > MAX_REASON_LENGTH @allowance_number = allowance_number @reason = reason end |
Instance Method Details
#execute ⇒ Object
30 31 32 33 |
# File 'lib/cetustek/cancel_allowance.rb', line 30 def execute response = soap_call(:cancel_allowance, allowancexml: generate_xml) ResultCode.check!(soap_return(response, :cancel_allowance), RESULT_MESSAGES, success: SUCCESS_CODE) end |