lib/russianpost/client.rb in russianpost-0.6.0 vs lib/russianpost/client.rb in russianpost-0.7.0
- old
+ new
@@ -1,24 +1,27 @@
-require "savon"
+require 'savon'
+require 'singleton'
module RussianPost
class Client
+ include Singleton
+
attr_reader :savon, :endpoint, :namespace
- ENDPOINT = "http://voh.russianpost.ru:8080/niips-operationhistory-web/OperationHistory"
- NAMESPACE = "http://russianpost.org/operationhistory/data"
+ ENDPOINT = 'http://voh.russianpost.ru:8080/niips-operationhistory-web/OperationHistory'
+ NAMESPACE = 'http://russianpost.org/operationhistory/data'
def initialize(opts = {})
@savon = Savon.client(
endpoint: ENDPOINT,
namespace: NAMESPACE,
open_timeout: opts[:timeout] || 10, # in seconds
log: false)
end
def call(opts = {barcode: nil})
- message = { "wsdl:Barcode" => opts[:barcode], "wsdl:MessageType" => "0" }
- response = savon.call("OperationHistoryRequest", message: message)
+ message = { 'wsdl:Barcode' => opts[:barcode], 'wsdl:MessageType' => '0' }
+ response = savon.call('OperationHistoryRequest', message: message)
result = response.to_hash[:operation_history_data][:history_record]
result.kind_of?(Array) ? result : [result].compact
end
end