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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f525a6d09dadb0aad42adbed55c08e926231ded
4
- data.tar.gz: 2cdbbb4bc4c3c1d6cfb1e1a05a7d1c43458f26a4
3
+ metadata.gz: 8aab9009a262f57e4b33e9289fbcd72799e0bf89
4
+ data.tar.gz: 0eb2542713cfd7a73b494d2b2c4377f5c97968eb
5
5
  SHA512:
6
- metadata.gz: 91cbb7af2c124a73355926f782b0fc283eb039e519159f4c4470ddd922e5aa8d3dcb73bd755ec94ece238d411b112dd3c3b9080690f97e7070b87f758d556943
7
- data.tar.gz: 18ca37d66f4288967099bc8af70c0b6250d0f789bd3045f4cc115aa8d0cce195d5f86f4320adccb71161dae499cfd5696f8a66809c5502ae8b3086b34ca38b9e
6
+ metadata.gz: 7f26396f851cb2dbe6e221f86dd892e83b36f1ffcb8b1a8451495a9034f231c51f6c47ffdef4aa1dac91280d058d3171a1c44737adae0a29ec8ad23b0dd4649b
7
+ data.tar.gz: 3e41bd6e6b86075b501d030f016b5c4a137251c6d1f68e2f63573403ae7eb90f5ee0e2b51a77d83ed268d7b9191dca45810f6da13dcc52d43e0fe84e517a6a64
@@ -0,0 +1 @@
1
+ shipwire
@@ -0,0 +1 @@
1
+ ruby-2.1.2
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Shipwire
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
@@ -16,5 +16,5 @@ end
16
16
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
17
17
 
18
18
  RSpec.configure do |config|
19
- config.mock_framework = 'mocha'
19
+ config.mock_framework = :mocha
20
20
  end
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.1
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.4.1
218
+ rubygems_version: 2.2.2
216
219
  signing_key:
217
220
  specification_version: 4
218
221
  summary: Exchange data with Shipwire fullfillment