russianpost 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/README.md +3 -1
- data/lib/russianpost/client.rb +2 -2
- data/lib/russianpost/operations_factory.rb +3 -3
- data/lib/russianpost/parcel.rb +2 -2
- data/lib/russianpost/version.rb +1 -1
- data/russianpost.gemspec +1 -0
- data/test/russianpost/client_test.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90c9d9530331f51349587f14084ab6b1c28aa140
|
4
|
+
data.tar.gz: 674b6c39bcd65a111a059e02f1a722bd7260d897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 970d71fef77c20e95749f1edd22e6b583d2beaa6708f868320500c918d7f915d47da8bb580d5aacb03e78ea22a781de3a78b9aa43e52b049d26c7b89b5389ece
|
7
|
+
data.tar.gz: 966878c1fd633dece8e1edf8287c1a3fc5cefb6757d4fa6cafceafddbf58e6f369927011d830e1ea519eff6a72934bfa4636b5a53e7ba9794a854ce541b29761
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Russian Post API Client
|
2
2
|
|
3
|
+
[](https://travis-ci.org/artemshitov/russianpost)
|
4
|
+
|
3
5
|
Thin wrapper around Russian Post package tracking SOAP API. Works on a per-package basis (contrary to the bulk ticket-based API). Use it at your own risk, since the API may appear unstable and require authorization in future.
|
4
6
|
|
5
7
|
## Installation
|
@@ -10,7 +12,7 @@ To install gem stand-alone:
|
|
10
12
|
|
11
13
|
To use gem in a Rails app, add the following to your `Gemfile`:
|
12
14
|
|
13
|
-
gem "russianpost", "~> 0.
|
15
|
+
gem "russianpost", "~> 0.3.0"
|
14
16
|
|
15
17
|
This gem uses [Savon](http://savonrb.com/), which in turn uses [HTTPI](https://github.com/savonrb/httpi) internally. HTTPI chooses the best HTTP library of those you have installed. For the fastest results, make sure you add [Curb](https://github.com/taf2/curb) to your `Gemfile`:
|
16
18
|
|
data/lib/russianpost/client.rb
CHANGED
@@ -10,8 +10,8 @@ module RussianPost
|
|
10
10
|
@savon = Savon.client(endpoint: endpoint, namespace: namespace, log: false)
|
11
11
|
end
|
12
12
|
|
13
|
-
def call(barcode: nil)
|
14
|
-
message = { "wsdl:Barcode" => barcode, "wsdl:MessageType" => "0" }
|
13
|
+
def call(opts = {barcode: nil})
|
14
|
+
message = { "wsdl:Barcode" => opts[:barcode], "wsdl:MessageType" => "0" }
|
15
15
|
response = savon.call("OperationHistoryRequest", message: message)
|
16
16
|
|
17
17
|
response.to_hash[:operation_history_data][:history_record]
|
@@ -39,13 +39,13 @@ module RussianPost
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def process_fixnum(key, value)
|
42
|
-
if
|
42
|
+
if [:payment, :value, :mass_rate, :insr_rate, :air_rate, :rate, :mass, :max_mass_ru, :max_mass_en].include? key
|
43
43
|
value.to_i
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def process_address(key, value)
|
48
|
-
if
|
48
|
+
if [:destination_address, :operation_address].include? key
|
49
49
|
RussianPost::Address.new(
|
50
50
|
value[:index],
|
51
51
|
value[:description])
|
@@ -53,7 +53,7 @@ module RussianPost
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def process_country(key, value)
|
56
|
-
if
|
56
|
+
if [:mail_direct, :country_from, :country_oper].include? key
|
57
57
|
RussianPost::Country.new(
|
58
58
|
value[:id] ? value[:id].to_i : nil,
|
59
59
|
value[:code_2a],
|
data/lib/russianpost/parcel.rb
CHANGED
@@ -5,9 +5,9 @@ module RussianPost
|
|
5
5
|
class Parcel
|
6
6
|
attr_reader :barcode, :client
|
7
7
|
|
8
|
-
def initialize(barcode,
|
8
|
+
def initialize(barcode, opts = {})
|
9
9
|
@barcode = barcode.upcase
|
10
|
-
@client = client.new
|
10
|
+
@client = (opts[:client] || Client).new
|
11
11
|
|
12
12
|
raise InvalidBarcode unless barcode_is_valid?
|
13
13
|
end
|
data/lib/russianpost/version.rb
CHANGED
data/russianpost.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "webmock"
|
23
24
|
spec.add_development_dependency "vcr", "~> 2.4.0"
|
24
25
|
spec.add_dependency "savon", "~> 2.1.0"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: russianpost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Shitov
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: vcr
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +90,7 @@ extensions: []
|
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
92
|
- .gitignore
|
93
|
+
- .travis.yml
|
79
94
|
- Gemfile
|
80
95
|
- LICENSE.txt
|
81
96
|
- README.md
|