lib/russianpost/client.rb in russianpost-0.3.0 vs lib/russianpost/client.rb in russianpost-0.3.1

- old
+ new

@@ -1,14 +1,19 @@ require "savon" module RussianPost class Client attr_reader :savon, :endpoint, :namespace + + ENDPOINT = "http://voh.russianpost.ru:8080/niips-operationhistory-web/OperationHistory" + NAMESPACE = "http://russianpost.org/operationhistory/data" - def initialize - @endpoint = "http://voh.russianpost.ru:8080/niips-operationhistory-web/OperationHistory" - @namespace = "http://russianpost.org/operationhistory/data" - @savon = Savon.client(endpoint: endpoint, namespace: namespace, log: false) + 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)