iloxx_shipping 0.1.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.
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +82 -0
- data/Rakefile +10 -0
- data/iloxx_shipping.gemspec +24 -0
- data/lib/iloxx_shipping.rb +17 -0
- data/lib/iloxx_shipping/address.rb +48 -0
- data/lib/iloxx_shipping/api.rb +146 -0
- data/lib/iloxx_shipping/daily_transaction_request.rb +19 -0
- data/lib/iloxx_shipping/order_request.rb +33 -0
- data/lib/iloxx_shipping/parcel.rb +31 -0
- data/lib/iloxx_shipping/request.rb +40 -0
- data/lib/iloxx_shipping/service.rb +21 -0
- data/lib/iloxx_shipping/service/express.rb +24 -0
- data/lib/iloxx_shipping/service/normalpaket.rb +27 -0
- data/lib/iloxx_shipping/service/retoure.rb +20 -0
- data/lib/iloxx_shipping/version.rb +5 -0
- data/spec/fixtures/address/simple.xml +1 -0
- data/spec/fixtures/address/with_company.xml +1 -0
- data/spec/fixtures/api/bad_auth_request.xml +1 -0
- data/spec/fixtures/api/bad_auth_response.xml +17 -0
- data/spec/fixtures/api/request.xml +1 -0
- data/spec/fixtures/api/response.xml +17 -0
- data/spec/fixtures/order_request/simple.xml +1 -0
- data/spec/fixtures/parcel/simple.xml +1 -0
- data/spec/fixtures/wsdl_curl.txt +310 -0
- data/spec/iloxx_shipping/address_spec.rb +52 -0
- data/spec/iloxx_shipping/api_spec.rb +71 -0
- data/spec/iloxx_shipping/order_request_spec.rb +46 -0
- data/spec/iloxx_shipping/parcel_spec.rb +32 -0
- data/spec/spec_helper.rb +36 -0
- metadata +142 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Iloxx::Shipping::Address do
|
5
|
+
|
6
|
+
it "should generate simple xml for a simple address" do
|
7
|
+
receiver = Iloxx::Shipping::Address.new({
|
8
|
+
:name => "Lilly Lox",
|
9
|
+
:street => "Gutenstetter Str. 8b",
|
10
|
+
:zip => "90449",
|
11
|
+
:city => "Nürnberg",
|
12
|
+
:country_code => "DE"
|
13
|
+
})
|
14
|
+
|
15
|
+
xml = wrap_in_xml_tree do |xml|
|
16
|
+
receiver.append_to_xml xml
|
17
|
+
end
|
18
|
+
|
19
|
+
xml.should eq(f :address, :simple)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should raise an error if the country is not in ISO-3166 format" do
|
23
|
+
expect {
|
24
|
+
receiver = Iloxx::Shipping::Address.new({
|
25
|
+
:country_code => "TEST"
|
26
|
+
})
|
27
|
+
}.to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should include a company xml tag if company is set" do
|
31
|
+
receiver = Iloxx::Shipping::Address.new({
|
32
|
+
:company => "Testcompany",
|
33
|
+
:name => "Lilly Lox",
|
34
|
+
:street => "Gutenstetter Str. 8b",
|
35
|
+
:zip => "90449",
|
36
|
+
:city => "Nürnberg",
|
37
|
+
:country_code => "DE"
|
38
|
+
})
|
39
|
+
|
40
|
+
xml = wrap_in_xml_tree do |xml|
|
41
|
+
receiver.append_to_xml xml
|
42
|
+
end
|
43
|
+
|
44
|
+
xml.should eq(f :address, :with_company)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should raise an error if sex is not in NoSexCode, Female, Male" do
|
48
|
+
expect {
|
49
|
+
Iloxx::Shipping::Address.new({ :sex => "TEST" })
|
50
|
+
}.to raise_error
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Iloxx::Shipping do
|
5
|
+
include Savon::SpecHelper
|
6
|
+
|
7
|
+
before(:all) {
|
8
|
+
@receiver = Iloxx::Shipping::Address.new({
|
9
|
+
:name => "Lilly Lox",
|
10
|
+
:street => "Gutenstetter Str. 8b",
|
11
|
+
:zip => "90449",
|
12
|
+
:city => "Nürnberg",
|
13
|
+
:country_code => "DE"
|
14
|
+
})
|
15
|
+
|
16
|
+
@parcel = Iloxx::Shipping::Parcel.new(
|
17
|
+
weight: 1.25,
|
18
|
+
content: "Stones",
|
19
|
+
address: @receiver,
|
20
|
+
service: Iloxx::Shipping::NormalpaketService.new,
|
21
|
+
reference: "Order #1234",
|
22
|
+
)
|
23
|
+
|
24
|
+
@shipment_date = Date.parse("2012-05-15")
|
25
|
+
|
26
|
+
savon.mock!
|
27
|
+
}
|
28
|
+
after(:all) { savon.unmock! }
|
29
|
+
|
30
|
+
it "should send a successful soap request" do
|
31
|
+
stub_wsdl
|
32
|
+
savon.expects(:ppv_add_order).with(message: f(:api, :request)).returns(f :api, :response)
|
33
|
+
|
34
|
+
config = {
|
35
|
+
user: 404,
|
36
|
+
token: "testuser-token"
|
37
|
+
}
|
38
|
+
api = Iloxx::Shipping::API.new(config, { test: true })
|
39
|
+
result = api.add_order(@parcel, @shipment_date)
|
40
|
+
|
41
|
+
result[:shipments][0][:partner_order_reference].should eq "0"
|
42
|
+
result[:shipments][0][:parcel_number].should eq "09445306577674"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should throw a AuthenticationError" do
|
46
|
+
stub_wsdl
|
47
|
+
savon.expects(:ppv_add_order).with(message: f(:api, :bad_auth_request)).returns(f :api, :bad_auth_response)
|
48
|
+
|
49
|
+
config = {
|
50
|
+
user: 404,
|
51
|
+
token: "testuser-token"
|
52
|
+
}
|
53
|
+
api = Iloxx::Shipping::API.new(config, { test: true })
|
54
|
+
expect {
|
55
|
+
api.add_order(@parcel, @shipment_date)
|
56
|
+
}.to raise_error(Iloxx::Shipping::AuthenticationError)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should throw a ShippingDateError if the shipping date is too far in the future" do
|
60
|
+
stub_wsdl
|
61
|
+
config = {
|
62
|
+
user: 404,
|
63
|
+
token: "testuser-token"
|
64
|
+
}
|
65
|
+
api = Iloxx::Shipping::API.new(config, { test: true })
|
66
|
+
future_date = Date.today + 15
|
67
|
+
expect {
|
68
|
+
api.add_order(@parcel, future_date)
|
69
|
+
}.to raise_error(Iloxx::Shipping::ShippingDateError)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
describe Iloxx::Shipping::OrderRequest do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@receiver = Iloxx::Shipping::Address.new(
|
9
|
+
name: "Lilly Lox",
|
10
|
+
street: "Gutenstetter Str. 8b",
|
11
|
+
zip: "90449",
|
12
|
+
city: "Nürnberg",
|
13
|
+
country_code: "DE"
|
14
|
+
)
|
15
|
+
|
16
|
+
@parcel = Iloxx::Shipping::Parcel.new(
|
17
|
+
weight: 1.25,
|
18
|
+
content: "Stones",
|
19
|
+
address: @receiver,
|
20
|
+
service: Iloxx::Shipping::NormalpaketService.new,
|
21
|
+
reference: "Order #1234",
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should generate xml for a normal request" do
|
26
|
+
request = Iloxx::Shipping::OrderRequest.new(
|
27
|
+
:version => Iloxx::Shipping::API::API_VERSION,
|
28
|
+
:auth => {
|
29
|
+
:partner => {
|
30
|
+
:name => "testpartner",
|
31
|
+
:key => "testpartner-KEY"
|
32
|
+
},
|
33
|
+
:user => {
|
34
|
+
:id => 404,
|
35
|
+
:token => "testuser-TOKEN"
|
36
|
+
}
|
37
|
+
},
|
38
|
+
:shipping_date => Date.parse("2012-05-15"),
|
39
|
+
:parcels => [@parcel]
|
40
|
+
)
|
41
|
+
|
42
|
+
xml = request.build!
|
43
|
+
xml.should eq(f :order_request, :simple)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Iloxx::Shipping::Parcel do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
@receiver = Iloxx::Shipping::Address.new({
|
8
|
+
:name => "Lilly Lox",
|
9
|
+
:street => "Gutenstetter Str. 8b",
|
10
|
+
:zip => "90449",
|
11
|
+
:city => "Nürnberg",
|
12
|
+
:country_code => "DE"
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should generate simple xml for a simple parcel" do
|
17
|
+
parcel = Iloxx::Shipping::Parcel.new(
|
18
|
+
weight: 1.25,
|
19
|
+
content: "Stones",
|
20
|
+
address: @receiver,
|
21
|
+
service: Iloxx::Shipping::NormalpaketService.new,
|
22
|
+
reference: "Order #1234",
|
23
|
+
)
|
24
|
+
|
25
|
+
xml = wrap_in_xml_tree do |xml|
|
26
|
+
parcel.append_to_xml xml
|
27
|
+
end
|
28
|
+
|
29
|
+
xml.should eq(f :parcel, :simple)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require "bundler/setup"
|
8
|
+
|
9
|
+
require "savon"
|
10
|
+
require "savon/mock/spec_helper"
|
11
|
+
|
12
|
+
require "webmock/rspec"
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
config.filter_run :focus
|
18
|
+
config.mock_with :rspec
|
19
|
+
end
|
20
|
+
|
21
|
+
def f method, response
|
22
|
+
File.read File.join(File.expand_path("../fixtures", __FILE__), method.to_s, "#{response.to_s}.xml")
|
23
|
+
end
|
24
|
+
|
25
|
+
def wrap_in_xml_tree
|
26
|
+
builder = Builder::XmlMarkup.new
|
27
|
+
yield builder
|
28
|
+
builder.target!
|
29
|
+
end
|
30
|
+
|
31
|
+
def stub_wsdl
|
32
|
+
raw_response_file = File.new File.join(File.expand_path("../fixtures", __FILE__), "wsdl_curl.txt")
|
33
|
+
stub_request(:get, "http://qa.www.iloxx.de/iloxxapi/ppvapi.asmx?WSDL").to_return(raw_response_file)
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'iloxx_shipping'
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iloxx_shipping
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maximilian Richt
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: savon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.11.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.11.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: webmock
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.13.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.13.0
|
62
|
+
description: A simple way to access the iloxx shipping API
|
63
|
+
email:
|
64
|
+
- maxi@richt.name
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rspec
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- iloxx_shipping.gemspec
|
76
|
+
- lib/iloxx_shipping.rb
|
77
|
+
- lib/iloxx_shipping/address.rb
|
78
|
+
- lib/iloxx_shipping/api.rb
|
79
|
+
- lib/iloxx_shipping/daily_transaction_request.rb
|
80
|
+
- lib/iloxx_shipping/order_request.rb
|
81
|
+
- lib/iloxx_shipping/parcel.rb
|
82
|
+
- lib/iloxx_shipping/request.rb
|
83
|
+
- lib/iloxx_shipping/service.rb
|
84
|
+
- lib/iloxx_shipping/service/express.rb
|
85
|
+
- lib/iloxx_shipping/service/normalpaket.rb
|
86
|
+
- lib/iloxx_shipping/service/retoure.rb
|
87
|
+
- lib/iloxx_shipping/version.rb
|
88
|
+
- spec/fixtures/address/simple.xml
|
89
|
+
- spec/fixtures/address/with_company.xml
|
90
|
+
- spec/fixtures/api/bad_auth_request.xml
|
91
|
+
- spec/fixtures/api/bad_auth_response.xml
|
92
|
+
- spec/fixtures/api/request.xml
|
93
|
+
- spec/fixtures/api/response.xml
|
94
|
+
- spec/fixtures/order_request/simple.xml
|
95
|
+
- spec/fixtures/parcel/simple.xml
|
96
|
+
- spec/fixtures/wsdl_curl.txt
|
97
|
+
- spec/iloxx_shipping/address_spec.rb
|
98
|
+
- spec/iloxx_shipping/api_spec.rb
|
99
|
+
- spec/iloxx_shipping/order_request_spec.rb
|
100
|
+
- spec/iloxx_shipping/parcel_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: https://github.com/robbi5/iloxx_shipping
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.8.24
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: A wrapper around the SOAP-based iloxx shipping web service. Generate a shipping
|
127
|
+
request and get a label back.
|
128
|
+
test_files:
|
129
|
+
- spec/fixtures/address/simple.xml
|
130
|
+
- spec/fixtures/address/with_company.xml
|
131
|
+
- spec/fixtures/api/bad_auth_request.xml
|
132
|
+
- spec/fixtures/api/bad_auth_response.xml
|
133
|
+
- spec/fixtures/api/request.xml
|
134
|
+
- spec/fixtures/api/response.xml
|
135
|
+
- spec/fixtures/order_request/simple.xml
|
136
|
+
- spec/fixtures/parcel/simple.xml
|
137
|
+
- spec/fixtures/wsdl_curl.txt
|
138
|
+
- spec/iloxx_shipping/address_spec.rb
|
139
|
+
- spec/iloxx_shipping/api_spec.rb
|
140
|
+
- spec/iloxx_shipping/order_request_spec.rb
|
141
|
+
- spec/iloxx_shipping/parcel_spec.rb
|
142
|
+
- spec/spec_helper.rb
|