File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- ups-ruby (0.17.0 )
4+ ups-ruby (0.18.1 )
55 excon (~> 0.45 , >= 0.45.3 )
66 insensitive_hash (~> 0.3.3 )
77 levenshtein-ffi (~> 1.1 )
1414 simplecov
1515 docile (1.1.5 )
1616 excon (0.73.0 )
17- ffi (1.12.2 )
17+ ffi (1.13.1 )
1818 insensitive_hash (0.3.3 )
1919 json (1.8.6 )
2020 levenshtein-ffi (1.1.0 )
Original file line number Diff line number Diff line change @@ -42,8 +42,30 @@ def packages
4242 [ UPS ::Models ::PackageResult . new ( package_results ) ]
4343 end
4444
45+ def total_charge
46+ return shipment_charge unless negotiated_rate
47+
48+ negotiated_rate
49+ end
50+
51+ def negotiated_rate
52+ negotiated_rate_response && negotiated_rate_response [ :NetSummaryCharges ] [ :GrandTotal ] [ :MonetaryValue ] . to_f
53+ end
54+
55+ def currency_code
56+ shipment_results [ :ShipmentCharges ] [ :TotalCharges ] [ :CurrencyCode ]
57+ end
58+
4559 private
4660
61+ def negotiated_rate_response
62+ shipment_results [ :NegotiatedRates ]
63+ end
64+
65+ def shipment_charge
66+ shipment_results [ :ShipmentCharges ] [ :TotalCharges ] [ :MonetaryValue ] . to_f
67+ end
68+
4769 def form_graphic
4870 shipment_results [ :Form ]
4971 end
Original file line number Diff line number Diff line change 11module UPS
22 module Version
33 MAJOR = 0
4- MINOR = 17
4+ MINOR = 18
55 PATCH = 1
66 BUILD = nil
77
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1515
1616 let ( :stub_path ) { File . expand_path ( "../../../stubs" , __FILE__ ) }
1717 let ( :server ) { UPS ::Connection . new ( test_mode : true ) }
18+ let ( :ship_accept_stub_file ) { 'ship_accept_success' }
1819
1920 describe 'if requesting a shipment' do
2021 describe 'single package shipment' do
2728 }
2829 when UPS ::Connection ::SHIP_ACCEPT_PATH
2930 {
30- body : File . read ( "#{ stub_path } /ship_accept_success .xml" ) , status : 200
31+ body : File . read ( "#{ stub_path } /#{ ship_accept_stub_file } .xml" ) , status : 200
3132 }
3233 end
3334 end
8081 it 'should return the tracking number' do
8182 subject . tracking_number . must_equal '1Z2220060292353829'
8283 end
84+
85+ describe 'total shipment cost' do
86+ describe 'with negotiated rates' do
87+ it 'returns the total shipment cost' do
88+ subject . total_charge . must_equal 115.14
89+ subject . currency_code . must_equal 'USD'
90+ end
91+ end
92+
93+ describe 'without negotiated rates' do
94+ let ( :ship_accept_stub_file ) { 'ship_accept_success_without_negotiated_price' }
95+
96+ it 'returns the total shipment cost' do
97+ subject . total_charge . must_equal 118.48
98+ subject . currency_code . must_equal 'USD'
99+ end
100+ end
101+ end
83102 end
84103
85104 describe 'when packaging type is specified' do
You can’t perform that action at this time.
0 commit comments