Module: Cetustek::Soap
- Included in:
- CancelAllowance, CancelInvoice, CreateAllowance, CreateInvoice, QueryAllowance, QueryInvoice, QueryInvoiceByOrderId, QueryInvoiceNumberByOrderId
- Defined in:
- lib/cetustek/soap.rb
Overview
Shared SOAP plumbing: every operation hits the same WSDL and authenticates with 網站代碼+APIPassword (source) and the 租賃者統編 (rentid).
Constant Summary collapse
- TIMEOUT =
300
Instance Method Summary collapse
-
#faraday_client ⇒ Object
savon 2.17 的 FaradayMigrationHint::OPTIONS 會讓 open_timeout/read_timeout 在 transport: :faraday 下直接 raise,逾時改由 faraday 連線自己設。.
- #httpi_client ⇒ Object
- #rentid ⇒ Object
- #soap_call(operation, message) ⇒ Object
- #soap_client ⇒ Object
- #soap_return(response, operation) ⇒ Object
- #source ⇒ Object
Instance Method Details
#faraday_client ⇒ Object
savon 2.17 的 FaradayMigrationHint::OPTIONS 會讓 open_timeout/read_timeout 在 transport: :faraday 下直接 raise,逾時改由 faraday 連線自己設。
23 24 25 26 27 28 29 |
# File 'lib/cetustek/soap.rb', line 23 def faraday_client require 'faraday' Savon.client(wsdl: Cetustek.config.url, transport: :faraday).tap do |client| client.faraday..open_timeout = TIMEOUT client.faraday..read_timeout = TIMEOUT end end |
#httpi_client ⇒ Object
17 18 19 |
# File 'lib/cetustek/soap.rb', line 17 def httpi_client Savon.client(wsdl: Cetustek.config.url, open_timeout: TIMEOUT, read_timeout: TIMEOUT) end |
#rentid ⇒ Object
35 36 37 |
# File 'lib/cetustek/soap.rb', line 35 def rentid Cetustek.config.username end |
#soap_call(operation, message) ⇒ Object
39 40 41 |
# File 'lib/cetustek/soap.rb', line 39 def soap_call(operation, ) soap_client.call(operation, message: .merge(source: source, rentid: rentid)) end |
#soap_client ⇒ Object
11 12 13 14 15 |
# File 'lib/cetustek/soap.rb', line 11 def soap_client return httpi_client unless Cetustek.config.transport == :faraday faraday_client end |
#soap_return(response, operation) ⇒ Object
43 44 45 |
# File 'lib/cetustek/soap.rb', line 43 def soap_return(response, operation) response.body[:"#{operation}_response"][:return] end |