Class: RussianPost::Client
- Inherits:
-
Object
- Object
- RussianPost::Client
- Defined in:
- lib/russianpost/client.rb
Constant Summary collapse
- ENDPOINT =
"http://voh.russianpost.ru:8080/niips-operationhistory-web/OperationHistory"- NAMESPACE =
"http://russianpost.org/operationhistory/data"
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#savon ⇒ Object
readonly
Returns the value of attribute savon.
Instance Method Summary collapse
- #call(opts = {barcode: nil}) ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 |
# File 'lib/russianpost/client.rb', line 10 def initialize(opts = {}) @savon = Savon.client( endpoint: ENDPOINT, namespace: NAMESPACE, open_timeout: opts[:timeout] || 10, # in seconds log: false) end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/russianpost/client.rb', line 5 def endpoint @endpoint end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/russianpost/client.rb', line 5 def namespace @namespace end |
#savon ⇒ Object (readonly)
Returns the value of attribute savon.
5 6 7 |
# File 'lib/russianpost/client.rb', line 5 def savon @savon end |
Instance Method Details
#call(opts = {barcode: nil}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/russianpost/client.rb', line 18 def call(opts = {barcode: nil}) = { "wsdl:Barcode" => opts[:barcode], "wsdl:MessageType" => "0" } response = savon.call("OperationHistoryRequest", message: ) result = response.to_hash[:operation_history_data][:history_record] result.kind_of?(Array) ? result : [result].compact end |