shipwire 0.0.1 → 0.0.2
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile.lock +69 -0
- data/lib/shipwire/shipping_rate.rb +27 -2
- data/lib/shipwire/version.rb +1 -1
- data/spec/shipwire/shipping_rate_spec.rb +20 -0
- data/spec/spec_helper.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aab9009a262f57e4b33e9289fbcd72799e0bf89
|
4
|
+
data.tar.gz: 0eb2542713cfd7a73b494d2b2c4377f5c97968eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f26396f851cb2dbe6e221f86dd892e83b36f1ffcb8b1a8451495a9034f231c51f6c47ffdef4aa1dac91280d058d3171a1c44737adae0a29ec8ad23b0dd4649b
|
7
|
+
data.tar.gz: 3e41bd6e6b86075b501d030f016b5c4a137251c6d1f68e2f63573403ae7eb90f5ee0e2b51a77d83ed268d7b9191dca45810f6da13dcc52d43e0fe84e517a6a64
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
shipwire
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.2
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shipwire (0.0.2)
|
5
|
+
faraday
|
6
|
+
nokogiri
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.6)
|
12
|
+
coderay (1.1.0)
|
13
|
+
crack (0.4.2)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.2.5)
|
16
|
+
dotenv (0.11.1)
|
17
|
+
dotenv-deployment (~> 0.0.2)
|
18
|
+
dotenv-deployment (0.0.2)
|
19
|
+
faraday (0.9.0)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
metaclass (0.0.4)
|
22
|
+
method_source (0.8.2)
|
23
|
+
mini_portile (0.6.0)
|
24
|
+
mocha (1.1.0)
|
25
|
+
metaclass (~> 0.0.1)
|
26
|
+
multipart-post (2.0.0)
|
27
|
+
nokogiri (1.6.3.1)
|
28
|
+
mini_portile (= 0.6.0)
|
29
|
+
pry (0.10.0)
|
30
|
+
coderay (~> 1.1.0)
|
31
|
+
method_source (~> 0.8.1)
|
32
|
+
slop (~> 3.4)
|
33
|
+
rack (1.5.2)
|
34
|
+
rack-test (0.6.2)
|
35
|
+
rack (>= 1.0)
|
36
|
+
rake (10.3.2)
|
37
|
+
rspec (3.0.0)
|
38
|
+
rspec-core (~> 3.0.0)
|
39
|
+
rspec-expectations (~> 3.0.0)
|
40
|
+
rspec-mocks (~> 3.0.0)
|
41
|
+
rspec-core (3.0.3)
|
42
|
+
rspec-support (~> 3.0.0)
|
43
|
+
rspec-expectations (3.0.3)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.0.0)
|
46
|
+
rspec-mocks (3.0.3)
|
47
|
+
rspec-support (~> 3.0.0)
|
48
|
+
rspec-support (3.0.3)
|
49
|
+
safe_yaml (1.0.3)
|
50
|
+
slop (3.6.0)
|
51
|
+
vcr (2.9.2)
|
52
|
+
webmock (1.18.0)
|
53
|
+
addressable (>= 2.3.6)
|
54
|
+
crack (>= 0.3.2)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
bundler (~> 1.6)
|
61
|
+
dotenv
|
62
|
+
mocha
|
63
|
+
pry
|
64
|
+
rack-test
|
65
|
+
rake
|
66
|
+
rspec
|
67
|
+
shipwire!
|
68
|
+
vcr
|
69
|
+
webmock
|
@@ -29,13 +29,38 @@ module Shipwire
|
|
29
29
|
quotes.each do |quote|
|
30
30
|
service = quote.xpath('Service').text
|
31
31
|
carrier_code = quote.xpath('CarrierCode').text
|
32
|
-
cost = quote.xpath('Cost').text
|
32
|
+
cost = quote.xpath('Cost').text.to_f
|
33
|
+
subtotals = quote.xpath('Subtotals')
|
34
|
+
|
35
|
+
freight = 0.0
|
36
|
+
insurance = 0.0
|
37
|
+
packaging = 0.0
|
38
|
+
handling = 0.0
|
39
|
+
|
40
|
+
subtotals.xpath('Subtotal').each do |subtotal|
|
41
|
+
case subtotal.attributes['type'].text
|
42
|
+
when 'Freight'
|
43
|
+
freight = subtotal.xpath('Cost').text.to_f
|
44
|
+
when 'Insurance'
|
45
|
+
insurance = subtotal.xpath('Cost').text.to_f
|
46
|
+
when 'Packaging'
|
47
|
+
packaging = subtotal.xpath('Cost').text.to_f
|
48
|
+
when 'Handling'
|
49
|
+
handling = subtotal.xpath('Cost').text.to_f
|
50
|
+
end
|
51
|
+
end
|
33
52
|
|
34
53
|
@shipping_quotes << {
|
35
54
|
service: service,
|
36
55
|
carrier_code: carrier_code,
|
37
56
|
code: quote.attributes['method'].value,
|
38
|
-
cost: cost
|
57
|
+
cost: cost,
|
58
|
+
subtotals: {
|
59
|
+
freight: freight,
|
60
|
+
insurance: insurance,
|
61
|
+
packaging: packaging,
|
62
|
+
handling: handling
|
63
|
+
}
|
39
64
|
}
|
40
65
|
end
|
41
66
|
else
|
data/lib/shipwire/version.rb
CHANGED
@@ -39,4 +39,24 @@ describe Shipwire::ShippingRate, vcr: true do
|
|
39
39
|
expect(shipping_rate.shipping_quotes.count).to eql(0)
|
40
40
|
expect(shipping_rate.errors.count).to be > 0
|
41
41
|
end
|
42
|
+
|
43
|
+
it 'should have valid return values for a shipping quote' do
|
44
|
+
shipping_rate = Shipwire::ShippingRate.new({
|
45
|
+
address: address,
|
46
|
+
items: items
|
47
|
+
})
|
48
|
+
|
49
|
+
shipping_rate.send
|
50
|
+
shipping_rate.parse_response
|
51
|
+
|
52
|
+
shipping_quote = shipping_rate.shipping_quotes.first
|
53
|
+
expect(shipping_quote[:service]).to_not be nil
|
54
|
+
expect(shipping_quote[:carrier_code]).to_not be nil
|
55
|
+
expect(shipping_quote[:code]).to_not be nil
|
56
|
+
expect(shipping_quote[:cost]).to be > 0
|
57
|
+
expect(shipping_quote[:subtotals][:freight]).to be > 0.0
|
58
|
+
expect(shipping_quote[:subtotals][:insurance]).to eql 0.0
|
59
|
+
expect(shipping_quote[:subtotals][:packaging]).to eql 0.0
|
60
|
+
expect(shipping_quote[:subtotals][:handling]).to eql 0.0
|
61
|
+
end
|
42
62
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipwire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Rowell
|
@@ -174,7 +174,10 @@ files:
|
|
174
174
|
- ".env"
|
175
175
|
- ".env.example"
|
176
176
|
- ".gitignore"
|
177
|
+
- ".ruby-gemset"
|
178
|
+
- ".ruby-version"
|
177
179
|
- Gemfile
|
180
|
+
- Gemfile.lock
|
178
181
|
- LICENSE
|
179
182
|
- README.md
|
180
183
|
- Rakefile
|
@@ -212,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
215
|
version: '0'
|
213
216
|
requirements: []
|
214
217
|
rubyforge_project:
|
215
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.2.2
|
216
219
|
signing_key:
|
217
220
|
specification_version: 4
|
218
221
|
summary: Exchange data with Shipwire fullfillment
|