dpd_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +468 -0
- data/Rakefile +2 -0
- data/dpd_api.gemspec +26 -0
- data/lib/dpd_api/base.rb +36 -0
- data/lib/dpd_api/calculator.rb +21 -0
- data/lib/dpd_api/configuration.rb +33 -0
- data/lib/dpd_api/geography.rb +26 -0
- data/lib/dpd_api/label_print.rb +32 -0
- data/lib/dpd_api/nl.rb +32 -0
- data/lib/dpd_api/order.rb +56 -0
- data/lib/dpd_api/tracing.rb +26 -0
- data/lib/dpd_api/version.rb +3 -0
- data/lib/dpd_api.rb +14 -0
- data/spec/fixtures/dpd_api/calculator/service_cost.xml +55 -0
- data/spec/fixtures/dpd_api/calculator/service_cost_by_parcels.xml +55 -0
- data/spec/fixtures/dpd_api/calculator/service_cost_by_parcels_fault.xml +15 -0
- data/spec/fixtures/dpd_api/calculator/service_cost_fault.xml +15 -0
- data/spec/fixtures/dpd_api/geography/cities_cash_pay.xml +23 -0
- data/spec/fixtures/dpd_api/geography/parcel_shops.xml +39 -0
- data/spec/fixtures/dpd_api/geography/terminals_self_delivery.xml +35 -0
- data/spec/fixtures/dpd_api/order/add_parcels.xml +0 -0
- data/spec/fixtures/dpd_api/order/cancel_order.xml +11 -0
- data/spec/fixtures/dpd_api/order/create_address.xml +11 -0
- data/spec/fixtures/dpd_api/order/create_order.xml +14 -0
- data/spec/fixtures/dpd_api/order/invoice_file.xml +0 -0
- data/spec/fixtures/dpd_api/order/order_status.xml +12 -0
- data/spec/fixtures/dpd_api/order/remove_parcels.xml +0 -0
- data/spec/fixtures/dpd_api/order/update_address.xml +11 -0
- data/spec/fixtures/dpd_api/tracing/states_by_client_order.xml +0 -0
- data/spec/fixtures/dpd_api/tracing/states_by_client_parcel.xml +0 -0
- data/spec/fixtures/dpd_api/tracing/states_by_dpd_order.xml +0 -0
- data/spec/lib/dpd_api/calculator_spec.rb +99 -0
- data/spec/lib/dpd_api/configuration_spec.rb +23 -0
- data/spec/lib/dpd_api/geography_spec.rb +53 -0
- data/spec/lib/dpd_api/order_spec.rb +200 -0
- data/spec/lib/dpd_api/tracing_spec.rb +58 -0
- data/spec/spec_helper.rb +7 -0
- metadata +165 -0
@@ -0,0 +1,200 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe DpdApi::Order do
|
4
|
+
include Savon::SpecHelper
|
5
|
+
before(:all) { savon.mock! }
|
6
|
+
after(:all) { savon.unmock! }
|
7
|
+
|
8
|
+
let(:auth) do
|
9
|
+
{ request: {
|
10
|
+
auth: {
|
11
|
+
client_number: "234",
|
12
|
+
client_key: "123"
|
13
|
+
} } }
|
14
|
+
end
|
15
|
+
let(:message) { auth.clone.deep_merge!({ request: params }) }
|
16
|
+
|
17
|
+
context ".create_order" do
|
18
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/create_order.xml") }
|
19
|
+
let(:params) do
|
20
|
+
{
|
21
|
+
header: {
|
22
|
+
date_pickup: Date.today.to_s,
|
23
|
+
sender_address: {
|
24
|
+
name: 'Иванов Иван Иваныч',
|
25
|
+
terminal_code: 'ABA',
|
26
|
+
city: 'Москва',
|
27
|
+
street: 'Ленина',
|
28
|
+
street_abbr: 'ул',
|
29
|
+
house: 1,
|
30
|
+
contact_fio: 'Иванов Иван Иваныч',
|
31
|
+
contact_phone: '+79211234567',
|
32
|
+
},
|
33
|
+
},
|
34
|
+
order: [
|
35
|
+
{
|
36
|
+
order_number_internal: '1234567',
|
37
|
+
service_code: 'TEN',
|
38
|
+
service_variant: 'ТД',
|
39
|
+
cargo_num_pack: '1',
|
40
|
+
cargo_weight: '1',
|
41
|
+
cargo_registered: false,
|
42
|
+
cargo_category: 'Одежда',
|
43
|
+
receiver_address: {
|
44
|
+
name: 'Петр Петров Петрович',
|
45
|
+
terminal_code: '',
|
46
|
+
city: 'Воронеж',
|
47
|
+
street: 'Красноармейская',
|
48
|
+
street_abbr: 'ул',
|
49
|
+
house: 1,
|
50
|
+
contact_fio: 'Иванов Иван Иваныч',
|
51
|
+
contact_phone: '+79211234567',
|
52
|
+
},
|
53
|
+
parcel: [
|
54
|
+
{
|
55
|
+
number: '123456789',
|
56
|
+
},
|
57
|
+
],
|
58
|
+
},
|
59
|
+
],
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
it "is success" do
|
64
|
+
savon.expects(:create_order).with(message: message).returns(fixture)
|
65
|
+
|
66
|
+
response = described_class.create_order(params)
|
67
|
+
expect(response.first).to have_key(:order_number_internal)
|
68
|
+
expect(response.first).to have_key(:status)
|
69
|
+
expect(response.first).to have_key(:error_message)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context ".cancel_order" do
|
74
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/cancel_order.xml") }
|
75
|
+
let(:params) do
|
76
|
+
{ cancel: {
|
77
|
+
order_num_internal: '1234567',
|
78
|
+
}, }
|
79
|
+
end
|
80
|
+
|
81
|
+
it "is success" do
|
82
|
+
savon.expects(:cancel_order).with(message: message).returns(fixture)
|
83
|
+
|
84
|
+
response = described_class.cancel_order(params)
|
85
|
+
expect(response.first).to have_key(:order_number_internal)
|
86
|
+
expect(response.first).to have_key(:status)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context ".order_status" do
|
91
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/order_status.xml") }
|
92
|
+
let(:params) do
|
93
|
+
{ order: {
|
94
|
+
order_number_internal: '1234567',
|
95
|
+
} }
|
96
|
+
end
|
97
|
+
|
98
|
+
it "is success" do
|
99
|
+
savon.expects(:get_order_status).with(message: message).returns(fixture)
|
100
|
+
|
101
|
+
response = described_class.order_status(params)
|
102
|
+
expect(response.first).to have_key(:order_number_internal)
|
103
|
+
expect(response.first).to have_key(:status)
|
104
|
+
expect(response.first).to have_key(:error_message)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context ".create_address" do
|
109
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/create_address.xml") }
|
110
|
+
let(:params) do
|
111
|
+
{ client_address: {
|
112
|
+
code: '78',
|
113
|
+
name: 'Перт Петров Петрович',
|
114
|
+
city: 'Воронеж',
|
115
|
+
street: 'Красноармейская',
|
116
|
+
street_abbr: 'ул',
|
117
|
+
house: 1,
|
118
|
+
contact_fio: 'Перт Петров Петрович',
|
119
|
+
contact_phone: '+79211234567',
|
120
|
+
} }
|
121
|
+
end
|
122
|
+
|
123
|
+
it "is success" do
|
124
|
+
savon.expects(:create_address).with(message: message).returns(fixture)
|
125
|
+
|
126
|
+
response = described_class.create_address(params)
|
127
|
+
expect(response.first).to have_key(:code)
|
128
|
+
expect(response.first).to have_key(:status)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context ".update_address" do
|
133
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/update_address.xml") }
|
134
|
+
let(:params) do
|
135
|
+
{ client_address: {
|
136
|
+
code: '78',
|
137
|
+
name: 'Перт Петров Петрович',
|
138
|
+
city: 'Владивосток',
|
139
|
+
street: 'Набережная',
|
140
|
+
street_abbr: 'ул',
|
141
|
+
house: 1,
|
142
|
+
contact_fio: 'Перт Петров Петрович',
|
143
|
+
contact_phone: '+79211234567',
|
144
|
+
} }
|
145
|
+
end
|
146
|
+
|
147
|
+
it "is success" do
|
148
|
+
savon.expects(:update_address).with(message: message).returns(fixture)
|
149
|
+
|
150
|
+
response = described_class.update_address(params)
|
151
|
+
expect(response.first).to have_key(:code)
|
152
|
+
expect(response.first).to have_key(:status)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# TODO: just fill with response the invoice_file.xml file and test should pass
|
157
|
+
xcontext ".invoice_file" do
|
158
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/invoice_file.xml") }
|
159
|
+
let(:params) do
|
160
|
+
{ order_num: '1234567', }
|
161
|
+
end
|
162
|
+
|
163
|
+
it "is success" do
|
164
|
+
savon.expects(:get_invoice_file).with(message: message).returns(fixture)
|
165
|
+
|
166
|
+
response = described_class.invoice_file(params)
|
167
|
+
expect(response.first).to have_key(:file)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# TODO: just fill with response the add_parcels.xml file and test should pass
|
172
|
+
xcontext ".add_parcels" do
|
173
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/add_parcels.xml") }
|
174
|
+
let(:params) do
|
175
|
+
end
|
176
|
+
|
177
|
+
it "is success" do
|
178
|
+
savon.expects(:add_parcels).with(message: message).returns(fixture)
|
179
|
+
|
180
|
+
response = described_class.add_parcels(params)
|
181
|
+
expect(response.first).to have_key(:parcel_status)
|
182
|
+
expect(response.first).to have_key(:status)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# TODO: just fill with response the add_parcels.xml file and test should pass
|
187
|
+
xcontext "#remove_parcels" do
|
188
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/order/remove_parcels.xml") }
|
189
|
+
let(:params) do
|
190
|
+
end
|
191
|
+
|
192
|
+
it "is success" do
|
193
|
+
savon.expects(:remove_parcels).with(message: message).returns(fixture)
|
194
|
+
|
195
|
+
response = service.remove_parcels(params)
|
196
|
+
expect(response.first).to have_key(:parcel_status)
|
197
|
+
expect(response.first).to have_key(:status)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe DpdApi::Order do
|
4
|
+
include Savon::SpecHelper
|
5
|
+
before(:all) { savon.mock! }
|
6
|
+
after(:all) { savon.unmock! }
|
7
|
+
|
8
|
+
let(:auth) do
|
9
|
+
{ request: {
|
10
|
+
auth: {
|
11
|
+
client_number: "234",
|
12
|
+
client_key: "123"
|
13
|
+
} } }
|
14
|
+
end
|
15
|
+
let(:message) { auth.clone.deep_merge!({ request: params }) }
|
16
|
+
|
17
|
+
# TODO: Add
|
18
|
+
xcontext ".states_by_client_order" do
|
19
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/tracing/states_by_client_order.xml") }
|
20
|
+
let(:params) do
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is success" do
|
24
|
+
savon.expects(:get_states_by_client_order).with(message: message).returns(fixture)
|
25
|
+
|
26
|
+
response = described_class.states_by_client_order(params)
|
27
|
+
expect(response.first).to have_key(:parcel_status)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# TODO: Add
|
32
|
+
xcontext ".states_by_client_parcel" do
|
33
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/tracing/states_by_client_parcel.xml") }
|
34
|
+
let(:params) do
|
35
|
+
end
|
36
|
+
|
37
|
+
it "is success" do
|
38
|
+
savon.expects(:get_states_by_client_parcel).with(message: message).returns(fixture)
|
39
|
+
|
40
|
+
response = described_class.states_by_client_parcel(params)
|
41
|
+
expect(response.first).to have_key(:parcel_status)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# TODO: Add
|
46
|
+
xcontext ".states_by_dpd_order" do
|
47
|
+
let(:fixture) { File.read("spec/fixtures/dpd_api/tracing/states_by_dpd_order.xml") }
|
48
|
+
let(:params) do
|
49
|
+
end
|
50
|
+
|
51
|
+
it "is success" do
|
52
|
+
savon.expects(:get_states_by_dpd_order).with(message: message).returns(fixture)
|
53
|
+
|
54
|
+
response = described_class.states_by_dpd_order(params)
|
55
|
+
expect(response.first).to have_key(:parcel_status)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dpd_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ponomarev Nikolay
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Ruby API for Dpd delivery service
|
70
|
+
email:
|
71
|
+
- itsnikolay@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- dpd_api.gemspec
|
83
|
+
- lib/dpd_api.rb
|
84
|
+
- lib/dpd_api/base.rb
|
85
|
+
- lib/dpd_api/calculator.rb
|
86
|
+
- lib/dpd_api/configuration.rb
|
87
|
+
- lib/dpd_api/geography.rb
|
88
|
+
- lib/dpd_api/label_print.rb
|
89
|
+
- lib/dpd_api/nl.rb
|
90
|
+
- lib/dpd_api/order.rb
|
91
|
+
- lib/dpd_api/tracing.rb
|
92
|
+
- lib/dpd_api/version.rb
|
93
|
+
- spec/fixtures/dpd_api/calculator/service_cost.xml
|
94
|
+
- spec/fixtures/dpd_api/calculator/service_cost_by_parcels.xml
|
95
|
+
- spec/fixtures/dpd_api/calculator/service_cost_by_parcels_fault.xml
|
96
|
+
- spec/fixtures/dpd_api/calculator/service_cost_fault.xml
|
97
|
+
- spec/fixtures/dpd_api/geography/cities_cash_pay.xml
|
98
|
+
- spec/fixtures/dpd_api/geography/parcel_shops.xml
|
99
|
+
- spec/fixtures/dpd_api/geography/terminals_self_delivery.xml
|
100
|
+
- spec/fixtures/dpd_api/order/add_parcels.xml
|
101
|
+
- spec/fixtures/dpd_api/order/cancel_order.xml
|
102
|
+
- spec/fixtures/dpd_api/order/create_address.xml
|
103
|
+
- spec/fixtures/dpd_api/order/create_order.xml
|
104
|
+
- spec/fixtures/dpd_api/order/invoice_file.xml
|
105
|
+
- spec/fixtures/dpd_api/order/order_status.xml
|
106
|
+
- spec/fixtures/dpd_api/order/remove_parcels.xml
|
107
|
+
- spec/fixtures/dpd_api/order/update_address.xml
|
108
|
+
- spec/fixtures/dpd_api/tracing/states_by_client_order.xml
|
109
|
+
- spec/fixtures/dpd_api/tracing/states_by_client_parcel.xml
|
110
|
+
- spec/fixtures/dpd_api/tracing/states_by_dpd_order.xml
|
111
|
+
- spec/lib/dpd_api/calculator_spec.rb
|
112
|
+
- spec/lib/dpd_api/configuration_spec.rb
|
113
|
+
- spec/lib/dpd_api/geography_spec.rb
|
114
|
+
- spec/lib/dpd_api/order_spec.rb
|
115
|
+
- spec/lib/dpd_api/tracing_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
homepage: ''
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.2.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Ruby API for Dpd delivery service
|
141
|
+
test_files:
|
142
|
+
- spec/fixtures/dpd_api/calculator/service_cost.xml
|
143
|
+
- spec/fixtures/dpd_api/calculator/service_cost_by_parcels.xml
|
144
|
+
- spec/fixtures/dpd_api/calculator/service_cost_by_parcels_fault.xml
|
145
|
+
- spec/fixtures/dpd_api/calculator/service_cost_fault.xml
|
146
|
+
- spec/fixtures/dpd_api/geography/cities_cash_pay.xml
|
147
|
+
- spec/fixtures/dpd_api/geography/parcel_shops.xml
|
148
|
+
- spec/fixtures/dpd_api/geography/terminals_self_delivery.xml
|
149
|
+
- spec/fixtures/dpd_api/order/add_parcels.xml
|
150
|
+
- spec/fixtures/dpd_api/order/cancel_order.xml
|
151
|
+
- spec/fixtures/dpd_api/order/create_address.xml
|
152
|
+
- spec/fixtures/dpd_api/order/create_order.xml
|
153
|
+
- spec/fixtures/dpd_api/order/invoice_file.xml
|
154
|
+
- spec/fixtures/dpd_api/order/order_status.xml
|
155
|
+
- spec/fixtures/dpd_api/order/remove_parcels.xml
|
156
|
+
- spec/fixtures/dpd_api/order/update_address.xml
|
157
|
+
- spec/fixtures/dpd_api/tracing/states_by_client_order.xml
|
158
|
+
- spec/fixtures/dpd_api/tracing/states_by_client_parcel.xml
|
159
|
+
- spec/fixtures/dpd_api/tracing/states_by_dpd_order.xml
|
160
|
+
- spec/lib/dpd_api/calculator_spec.rb
|
161
|
+
- spec/lib/dpd_api/configuration_spec.rb
|
162
|
+
- spec/lib/dpd_api/geography_spec.rb
|
163
|
+
- spec/lib/dpd_api/order_spec.rb
|
164
|
+
- spec/lib/dpd_api/tracing_spec.rb
|
165
|
+
- spec/spec_helper.rb
|