Sha256: f9d5c4fd8902a1bd90ebc0703b1e42eff9be77377165c9115d07c0909229fb62

Contents?: true

Size: 751 Bytes

Versions: 3

Compression:

Stored size: 751 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)

      response.to_hash[:operation_history_data][:history_record]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
russianpost-0.4.1 lib/russianpost/client.rb
russianpost-0.4.0 lib/russianpost/client.rb
russianpost-0.3.1 lib/russianpost/client.rb