Sha256: cb8d340641f47178bc9c8e02c50e0dac8ef8744ea902a957d5d268af0f767c14

Contents?: true

Size: 817 Bytes

Versions: 7

Compression:

Stored size: 817 Bytes

Contents

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(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)
      result = response.to_hash[:operation_history_data][:history_record]

      result.kind_of?(Array) ? result : [result].compact
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
russianpost-0.6.0 lib/russianpost/client.rb
russianpost-0.5.1 lib/russianpost/client.rb
russianpost-0.5.0 lib/russianpost/client.rb
russianpost-0.4.5 lib/russianpost/client.rb
russianpost-0.4.4 lib/russianpost/client.rb
russianpost-0.4.3 lib/russianpost/client.rb
russianpost-0.4.2 lib/russianpost/client.rb