russianpost 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36667c0e3344db51141e9b75594052169f2bd28d
4
- data.tar.gz: d474dc749bb9f06a4ed396b138cc14c6bdc2f409
3
+ metadata.gz: 90c9d9530331f51349587f14084ab6b1c28aa140
4
+ data.tar.gz: 674b6c39bcd65a111a059e02f1a722bd7260d897
5
5
  SHA512:
6
- metadata.gz: 42c6a0cc3d4053ca4340248161149f91340ce3c344034d82591dfd9f8f24841c9ad586ca8ceb64bcff7d59131fb3a5792d3bb8d24b116c7da629008932fd3c2e
7
- data.tar.gz: beac89dcf5020d0873a136e505502e922cc097e256e5bc3e4a6df92fc614bd1e24b3d487d86a5066e30ddf08efa74102bdd1c879fa921f976757a9c2b84b4cfa
6
+ metadata.gz: 970d71fef77c20e95749f1edd22e6b583d2beaa6708f868320500c918d7f915d47da8bb580d5aacb03e78ea22a781de3a78b9aa43e52b049d26c7b89b5389ece
7
+ data.tar.gz: 966878c1fd633dece8e1edf8287c1a3fc5cefb6757d4fa6cafceafddbf58e6f369927011d830e1ea519eff6a72934bfa4636b5a53e7ba9794a854ce541b29761
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Russian Post API Client
2
2
 
3
+ [![Build Status](https://travis-ci.org/artemshitov/russianpost.png?branch=master)](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.2.1"
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
 
@@ -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 %i(payment value mass_rate insr_rate air_rate rate mass max_mass_ru max_mass_en).include? key
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 %i(destination_address operation_address).include? key
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 %i(mail_direct country_from country_oper).include? key
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],
@@ -5,9 +5,9 @@ module RussianPost
5
5
  class Parcel
6
6
  attr_reader :barcode, :client
7
7
 
8
- def initialize(barcode, client: Client)
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
@@ -1,3 +1,3 @@
1
1
  module Russianpost
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
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
@@ -1,7 +1,7 @@
1
1
  require "test_helper"
2
2
  require "russianpost/client"
3
3
 
4
- class TestClient < Minitest::Unit::TestCase
4
+ class TestClient < MiniTest::Unit::TestCase
5
5
  def setup
6
6
  @client = RussianPost::Client.new
7
7
  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.2.1
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