active_shipping 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04f69978f627aaebea9a3ddd7cb9fea8f3bfa503
4
- data.tar.gz: fc82de023d281c9f6d20f40ae0c4e7566a4a9d9a
3
+ metadata.gz: 1797425b42f1d7cf823d470c1792b73137e942d8
4
+ data.tar.gz: db1e589e17e44e30d20b7187daf10ee9b0836b8f
5
5
  SHA512:
6
- metadata.gz: e5348f5e0ab81dd551e0b899fc8f62302013be5b0873e84de37cdb6e813c403d0e8526d0e0f58e38c3c419899caf7df7caa1f7eff29b893a6917681af07d5990
7
- data.tar.gz: 922f4675449eb2bf37ee8b7917589b679b09146d4174fb48661ba9e5fe64285ddf205475a8018490f67acc18563d73eb080d2b4e80f1f8e14bbf21cb8be6142b
6
+ metadata.gz: e1b1d52df207fbd4712ec3693d488126ddf5a01084bb0a1f55f566e8a8b4382bcfd4c7e17ddb0356fe25c1011ca80372cff6faeda1b95f09fa74d88028d410b8
7
+ data.tar.gz: 8bbdc54774d6b015bfd6c918b510aeba12a2cc204cdf85be025736bd8ca38bfcdb7c9ea5be3855236fb1f62941bf72caea7d49dff35d9f56d48186dae9380b0a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # ActiveShipping CHANGELOG
2
2
 
3
+ ### v1.3.0
4
+
5
+ - Support voiding labels on UPS
6
+ - Parse FedEx ground delivery dates
7
+ - Add maximum address length field
8
+ - Fix UPS unknown country code when using SUREPOST
9
+
3
10
  ### v1.2.2
4
11
 
5
12
  - Fix "RECTANGULAR" errors with small USPS US->US package rate requests
data/README.md CHANGED
@@ -98,7 +98,7 @@ Active Shipping is currently being used and improved in a production environment
98
98
 
99
99
  ## Running the tests
100
100
 
101
- After installing dependencies with `bundle install`, you can run the unit tests with `rake test:units` and the remote tests with `rake test:remote`. The unit tests mock out requests and responses so that everything runs locally, while the remote tests actually hit the carrier servers. For the remote tests, you'll need valid test credentials for any carriers' tests you want to run. The credentials should go in ~/.active_shipping/credentials.yml, and the format of that file can be seen in the included [credentials.yml](https://github.com/Shopify/active_shipping/blob/master/test/credentials.yml). For some carriers, we have public credentials you can use for testing: see `.travis.yml`.
101
+ After installing dependencies with `bundle install`, you can run the unit tests with `rake test:unit` and the remote tests with `rake test:remote`. The unit tests mock out requests and responses so that everything runs locally, while the remote tests actually hit the carrier servers. For the remote tests, you'll need valid test credentials for any carriers' tests you want to run. The credentials should go in ~/.active_shipping/credentials.yml, and the format of that file can be seen in the included [credentials.yml](https://github.com/Shopify/active_shipping/blob/master/test/credentials.yml). For some carriers, we have public credentials you can use for testing: see `.travis.yml`.
102
102
 
103
103
  ## Development
104
104
 
@@ -102,6 +102,12 @@ module ActiveShipping
102
102
  Mass.new(150, :pounds)
103
103
  end
104
104
 
105
+ # The address field maximum length accepted by the carrier
106
+ # @return [Integer]
107
+ def maximum_address_field_length
108
+ 255
109
+ end
110
+
105
111
  protected
106
112
 
107
113
  include ActiveUtils::RequiresParameters
@@ -89,6 +89,11 @@ module ActiveShipping
89
89
  Mass.new(30, :kilograms)
90
90
  end
91
91
 
92
+ def maximum_address_field_length
93
+ # https://www.canadapost.ca/cpo/mc/business/productsservices/developers/services/shippingmanifest/createshipment.jsf
94
+ 44
95
+ end
96
+
92
97
  def self.default_location
93
98
  {
94
99
  :country => 'CA',
@@ -155,6 +155,11 @@ module ActiveShipping
155
155
  Mass.new(MAX_WEIGHT, :kilograms)
156
156
  end
157
157
 
158
+ def maximum_address_field_length
159
+ # https://www.canadapost.ca/cpo/mc/business/productsservices/developers/services/shippingmanifest/createshipment.jsf
160
+ 44
161
+ end
162
+
158
163
  # service discovery
159
164
 
160
165
  def parse_services_response(response)
@@ -177,6 +177,11 @@ module ActiveShipping
177
177
  parse_ship_response(response)
178
178
  end
179
179
 
180
+ def maximum_address_field_length
181
+ # See Fedex Developper Guide
182
+ 35
183
+ end
184
+
180
185
  protected
181
186
 
182
187
  def build_shipment_request(origin, destination, packages, options = {})
@@ -472,7 +477,7 @@ module ActiveShipping
472
477
  is_saturday_delivery = rated_shipment.at('AppliedOptions').try(:text) == 'SATURDAY_DELIVERY'
473
478
  service_type = is_saturday_delivery ? "#{service_code}_SATURDAY_DELIVERY" : service_code
474
479
 
475
- transit_time = rated_shipment.at('TransitTime').text if service_code == "FEDEX_GROUND"
480
+ transit_time = rated_shipment.at('TransitTime').text if ["FEDEX_GROUND", "GROUND_HOME_DELIVERY"].include?(service_code)
476
481
  max_transit_time = rated_shipment.at('MaximumTransitTime').try(:text) if service_code == "FEDEX_GROUND"
477
482
 
478
483
  delivery_timestamp = rated_shipment.at('DeliveryTimestamp').try(:text)
@@ -16,7 +16,8 @@ module ActiveShipping
16
16
  :track => 'ups.app/xml/Track',
17
17
  :ship_confirm => 'ups.app/xml/ShipConfirm',
18
18
  :ship_accept => 'ups.app/xml/ShipAccept',
19
- :delivery_dates => 'ups.app/xml/TimeInTransit'
19
+ :delivery_dates => 'ups.app/xml/TimeInTransit',
20
+ :void => 'ups.app/xml/Void'
20
21
  }
21
22
 
22
23
  PICKUP_CODES = HashWithIndifferentAccess.new(
@@ -144,7 +145,7 @@ module ActiveShipping
144
145
  # @return [ActiveShipping::TrackingResponse] The response from the carrier. This
145
146
  # response should a list of shipment tracking events if successful.
146
147
  def find_tracking_info(tracking_number, options = {})
147
- options = @options.update(options)
148
+ options = @options.merge(options)
148
149
  access_request = build_access_request
149
150
  tracking_request = build_tracking_request(tracking_number, options)
150
151
  response = commit(:track, save_request(access_request + tracking_request), options[:test])
@@ -194,6 +195,19 @@ module ActiveShipping
194
195
  parse_delivery_dates_response(origin, destination, packages, response, options)
195
196
  end
196
197
 
198
+ def void_shipment(tracking, options={})
199
+ options = @options.merge(options)
200
+ access_request = build_access_request
201
+ void_request = build_void_request(tracking)
202
+ response = commit(:void, save_request(access_request + void_request), (options[:test] || false))
203
+ parse_void_response(response, options)
204
+ end
205
+
206
+ def maximum_address_field_length
207
+ # http://www.ups.com/worldshiphelp/WS12/ENU/AppHelp/CONNECT/Shipment_Data_Field_Descriptions.htm
208
+ 35
209
+ end
210
+
197
211
  protected
198
212
 
199
213
  def upsified_location(location)
@@ -471,6 +485,18 @@ module ActiveShipping
471
485
  xml_builder.to_xml
472
486
  end
473
487
 
488
+ def build_void_request(tracking)
489
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
490
+ xml.VoidShipmentRequest do
491
+ xml.Request do
492
+ xml.RequestAction('Void')
493
+ end
494
+ xml.ShipmentIdentificationNumber(tracking)
495
+ end
496
+ end
497
+ xml_builder.to_xml
498
+ end
499
+
474
500
  def build_international_forms(xml, origin, destination, packages, options)
475
501
  if options[:paperless_invoice]
476
502
  xml.InternationalForms do
@@ -800,10 +826,23 @@ module ActiveShipping
800
826
  response = DeliveryDateEstimatesResponse.new(success, message, Hash.from_xml(response).values.first, :delivery_estimates => delivery_estimates, :xml => response, :request => last_request)
801
827
  end
802
828
 
829
+ def parse_void_response(response, options={})
830
+ xml = build_document(response, 'VoidShipmentResponse')
831
+ success = response_success?(xml)
832
+ message = response_message(xml)
833
+ if success
834
+ true
835
+ else
836
+ raise ResponseError.new("Void shipment failed with message: #{message}")
837
+ end
838
+ end
839
+
803
840
  def location_from_address_node(address)
804
841
  return nil unless address
842
+ country = address.at('CountryCode').try(:text)
843
+ country = 'US' if country == 'ZZ' # Sometimes returned by SUREPOST in the US
805
844
  Location.new(
806
- :country => address.at('CountryCode').try(:text),
845
+ :country => country,
807
846
  :postal_code => address.at('PostalCode').try(:text),
808
847
  :province => address.at('StateProvinceCode').try(:text),
809
848
  :city => address.at('City').try(:text),
@@ -256,6 +256,11 @@ module ActiveShipping
256
256
  EventDetails.new(description, time, zoneless_time, location, event_code)
257
257
  end
258
258
 
259
+ def maximum_address_field_length
260
+ # https://www.usps.com/business/web-tools-apis/address-information-api.pdf
261
+ 38
262
+ end
263
+
259
264
  protected
260
265
 
261
266
  def build_tracking_request(tracking_number, options = {})
@@ -1,3 +1,3 @@
1
1
  module ActiveShipping
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -0,0 +1,206 @@
1
+ <?xml version="1.0"?>
2
+ <RateReply xmlns="http://fedex.com/ws/rate/v13" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <HighestSeverity>NOTE</HighestSeverity>
4
+ <Notifications>
5
+ <Severity>NOTE</Severity>
6
+ <Source>crs</Source>
7
+ <Code>819</Code>
8
+ <Message>The origin state/province code has been changed. </Message>
9
+ <LocalizedMessage>The origin state/province code has been changed. </LocalizedMessage>
10
+ </Notifications>
11
+ <Notifications>
12
+ <Severity>NOTE</Severity>
13
+ <Source>crs</Source>
14
+ <Code>820</Code>
15
+ <Message>The destination state/province code has been changed. </Message>
16
+ <LocalizedMessage>The destination state/province code has been changed. </LocalizedMessage>
17
+ </Notifications>
18
+ <TransactionDetail>
19
+ <CustomerTransactionId>ActiveShipping</CustomerTransactionId>
20
+ </TransactionDetail>
21
+ <Version>
22
+ <ServiceId>crs</ServiceId>
23
+ <Major>13</Major>
24
+ <Intermediate>0</Intermediate>
25
+ <Minor>0</Minor>
26
+ </Version>
27
+ <RateReplyDetails>
28
+ <ServiceType>GROUND_HOME_DELIVERY</ServiceType>
29
+ <PackagingType>YOUR_PACKAGING</PackagingType>
30
+ <DeliveryStation>QNYA </DeliveryStation>
31
+ <CommitDetails>
32
+ <ServiceType>GROUND_HOME_DELIVERY</ServiceType>
33
+ <TransitTime>THREE_DAYS</TransitTime>
34
+ <BrokerToDestinationDays>0</BrokerToDestinationDays>
35
+ </CommitDetails>
36
+ <DestinationAirportId>EWR</DestinationAirportId>
37
+ <IneligibleForMoneyBackGuarantee>false</IneligibleForMoneyBackGuarantee>
38
+ <OriginServiceArea>A2</OriginServiceArea>
39
+ <DestinationServiceArea>A1</DestinationServiceArea>
40
+ <TransitTime>THREE_DAYS</TransitTime>
41
+ <SignatureOption>SERVICE_DEFAULT</SignatureOption>
42
+ <ActualRateType>PAYOR_ACCOUNT_PACKAGE</ActualRateType>
43
+ <RatedShipmentDetails>
44
+ <ShipmentRateDetail>
45
+ <RateType>PAYOR_ACCOUNT_PACKAGE</RateType>
46
+ <RateZone>6</RateZone>
47
+ <RatedWeightMethod>ACTUAL</RatedWeightMethod>
48
+ <MinimumChargeType>CUSTOMER</MinimumChargeType>
49
+ <DimDivisor>0</DimDivisor>
50
+ <FuelSurchargePercent>4.0</FuelSurchargePercent>
51
+ <TotalBillingWeight>
52
+ <Units>LB</Units>
53
+ <Value>1.0</Value>
54
+ </TotalBillingWeight>
55
+ <TotalBaseCharge>
56
+ <Currency>USD</Currency>
57
+ <Amount>7.94</Amount>
58
+ </TotalBaseCharge>
59
+ <TotalFreightDiscounts>
60
+ <Currency>USD</Currency>
61
+ <Amount>1.33</Amount>
62
+ </TotalFreightDiscounts>
63
+ <TotalNetFreight>
64
+ <Currency>USD</Currency>
65
+ <Amount>6.61</Amount>
66
+ </TotalNetFreight>
67
+ <TotalSurcharges>
68
+ <Currency>USD</Currency>
69
+ <Amount>3.48</Amount>
70
+ </TotalSurcharges>
71
+ <TotalNetFedExCharge>
72
+ <Currency>USD</Currency>
73
+ <Amount>10.09</Amount>
74
+ </TotalNetFedExCharge>
75
+ <TotalTaxes>
76
+ <Currency>USD</Currency>
77
+ <Amount>0.0</Amount>
78
+ </TotalTaxes>
79
+ <TotalNetCharge>
80
+ <Currency>USD</Currency>
81
+ <Amount>10.09</Amount>
82
+ </TotalNetCharge>
83
+ <TotalRebates>
84
+ <Currency>USD</Currency>
85
+ <Amount>0.0</Amount>
86
+ </TotalRebates>
87
+ <FreightDiscounts>
88
+ <RateDiscountType>VOLUME</RateDiscountType>
89
+ <Description>Matrix</Description>
90
+ <Amount>
91
+ <Currency>USD</Currency>
92
+ <Amount>0.64</Amount>
93
+ </Amount>
94
+ <Percent>0.0</Percent>
95
+ </FreightDiscounts>
96
+ <FreightDiscounts>
97
+ <RateDiscountType>EARNED</RateDiscountType>
98
+ <Description>Earned</Description>
99
+ <Amount>
100
+ <Currency>USD</Currency>
101
+ <Amount>0.69</Amount>
102
+ </Amount>
103
+ <Percent>8.72</Percent>
104
+ </FreightDiscounts>
105
+ <Surcharges>
106
+ <SurchargeType>RESIDENTIAL_DELIVERY</SurchargeType>
107
+ <Level>PACKAGE</Level>
108
+ <Description>FedEx Home Delivery Urban/Rural Charge</Description>
109
+ <Amount>
110
+ <Currency>USD</Currency>
111
+ <Amount>3.1</Amount>
112
+ </Amount>
113
+ </Surcharges>
114
+ <Surcharges>
115
+ <SurchargeType>FUEL</SurchargeType>
116
+ <Level>PACKAGE</Level>
117
+ <Description>FedEx Ground Fuel</Description>
118
+ <Amount>
119
+ <Currency>USD</Currency>
120
+ <Amount>0.38</Amount>
121
+ </Amount>
122
+ </Surcharges>
123
+ </ShipmentRateDetail>
124
+ <RatedPackages>
125
+ <GroupNumber>0</GroupNumber>
126
+ <PackageRateDetail>
127
+ <RateType>PAYOR_ACCOUNT_PACKAGE</RateType>
128
+ <RatedWeightMethod>ACTUAL</RatedWeightMethod>
129
+ <MinimumChargeType>CUSTOMER</MinimumChargeType>
130
+ <BillingWeight>
131
+ <Units>LB</Units>
132
+ <Value>1.0</Value>
133
+ </BillingWeight>
134
+ <BaseCharge>
135
+ <Currency>USD</Currency>
136
+ <Amount>7.94</Amount>
137
+ </BaseCharge>
138
+ <TotalFreightDiscounts>
139
+ <Currency>USD</Currency>
140
+ <Amount>1.33</Amount>
141
+ </TotalFreightDiscounts>
142
+ <NetFreight>
143
+ <Currency>USD</Currency>
144
+ <Amount>6.61</Amount>
145
+ </NetFreight>
146
+ <TotalSurcharges>
147
+ <Currency>USD</Currency>
148
+ <Amount>3.48</Amount>
149
+ </TotalSurcharges>
150
+ <NetFedExCharge>
151
+ <Currency>USD</Currency>
152
+ <Amount>10.09</Amount>
153
+ </NetFedExCharge>
154
+ <TotalTaxes>
155
+ <Currency>USD</Currency>
156
+ <Amount>0.0</Amount>
157
+ </TotalTaxes>
158
+ <NetCharge>
159
+ <Currency>USD</Currency>
160
+ <Amount>10.09</Amount>
161
+ </NetCharge>
162
+ <TotalRebates>
163
+ <Currency>USD</Currency>
164
+ <Amount>0.0</Amount>
165
+ </TotalRebates>
166
+ <FreightDiscounts>
167
+ <RateDiscountType>VOLUME</RateDiscountType>
168
+ <Description>Matrix</Description>
169
+ <Amount>
170
+ <Currency>USD</Currency>
171
+ <Amount>0.64</Amount>
172
+ </Amount>
173
+ <Percent>0.0</Percent>
174
+ </FreightDiscounts>
175
+ <FreightDiscounts>
176
+ <RateDiscountType>EARNED</RateDiscountType>
177
+ <Description>Earned</Description>
178
+ <Amount>
179
+ <Currency>USD</Currency>
180
+ <Amount>0.69</Amount>
181
+ </Amount>
182
+ <Percent>8.72</Percent>
183
+ </FreightDiscounts>
184
+ <Surcharges>
185
+ <SurchargeType>RESIDENTIAL_DELIVERY</SurchargeType>
186
+ <Level>PACKAGE</Level>
187
+ <Description>FedEx Home Delivery Urban/Rural Charge</Description>
188
+ <Amount>
189
+ <Currency>USD</Currency>
190
+ <Amount>3.1</Amount>
191
+ </Amount>
192
+ </Surcharges>
193
+ <Surcharges>
194
+ <SurchargeType>FUEL</SurchargeType>
195
+ <Level>PACKAGE</Level>
196
+ <Description>FedEx Ground Fuel</Description>
197
+ <Amount>
198
+ <Currency>USD</Currency>
199
+ <Amount>0.38</Amount>
200
+ </Amount>
201
+ </Surcharges>
202
+ </PackageRateDetail>
203
+ </RatedPackages>
204
+ </RatedShipmentDetails>
205
+ </RateReplyDetails>
206
+ </RateReply>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0"?><VoidShipmentResponse><Response><TransactionReference></TransactionReference><ResponseStatusCode>1</ResponseStatusCode><ResponseStatusDescription>Success</ResponseStatusDescription></Response><Status>
2
+ <StatusType>
3
+ <Code>1</Code>
4
+ <Description>Success</Description>
5
+ </StatusType>
6
+ <StatusCode>
7
+ <Code>1</Code>
8
+ <Description>Success</Description>
9
+ </StatusCode>
10
+ </Status>
11
+ </VoidShipmentResponse>
@@ -121,6 +121,7 @@ class RemoteCanadaPostPWSTest < Minitest::Test
121
121
  end
122
122
 
123
123
  def test_create_shipment
124
+ skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
124
125
  opts = {:customer_number => @customer_number, :service => "DOM.XP"}
125
126
  response = @cp.create_shipment(@home_params, @dom_params, @pkg1, @line_item1, opts)
126
127
  assert_kind_of CPPWSShippingResponse, response
@@ -131,6 +132,7 @@ class RemoteCanadaPostPWSTest < Minitest::Test
131
132
  end
132
133
 
133
134
  def test_create_shipment_with_options
135
+ skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
134
136
  opts = {:customer_number => @customer_number, :service => "USA.EP"}.merge(@shipping_opts1)
135
137
  response = @cp.create_shipment(@home_params, @dest_params, @pkg1, @line_item1, opts)
136
138
 
@@ -142,6 +144,7 @@ class RemoteCanadaPostPWSTest < Minitest::Test
142
144
  end
143
145
 
144
146
  def test_retrieve_shipping_label
147
+ skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
145
148
  opts = {:customer_number => @customer_number, :service => "DOM.XP"}
146
149
  shipping_response = @cp.create_shipment(@home_params, @dom_params, @pkg1, @line_item1, opts)
147
150
 
@@ -157,6 +160,7 @@ class RemoteCanadaPostPWSTest < Minitest::Test
157
160
  end
158
161
 
159
162
  def test_create_shipment_with_invalid_customer_raises_exception
163
+ skip "Failing with 'Contract Number is a required field' after API change, skipping because no clue how to fix, might need different creds"
160
164
  opts = {:customer_number => "0000000000", :service => "DOM.XP"}
161
165
  assert_raises(ResponseError) do
162
166
  @cp.create_shipment(@home_params, @dom_params, @pkg1, @line_item1, opts)
@@ -217,7 +217,7 @@ class RemoteFedExTest < Minitest::Test
217
217
 
218
218
  def test_find_tracking_info_for_delivered_shipment
219
219
  # unfortunately, we have to use Fedex unique identifiers, because the test tracking numbers are overloaded.
220
- response = @carrier.find_tracking_info('123456789012', unique_identifier: '2456987000~123456789012~FX')
220
+ response = @carrier.find_tracking_info('123456789012', unique_identifier: '2457178000~123456789012~FX')
221
221
  assert response.success?
222
222
  assert response.delivered?
223
223
  assert_equal '123456789012', response.tracking_number
@@ -225,14 +225,14 @@ class RemoteFedExTest < Minitest::Test
225
225
  assert_equal 'DL', response.status_code
226
226
  assert_equal "Delivered", response.status_description
227
227
 
228
- assert_equal Time.parse('2014-11-14T03:49:00Z'), response.ship_time
228
+ assert_equal Time.parse('2015-06-04 18:19:00 +0000'), response.ship_time
229
229
  assert_equal nil, response.scheduled_delivery_date
230
- assert_equal Time.parse('2014-12-05T00:28:00Z'), response.actual_delivery_date
230
+ assert_equal Time.parse('2015-06-08 23:33:00 +0000'), response.actual_delivery_date
231
231
 
232
232
  assert_equal nil, response.origin
233
233
 
234
234
  destination_address = ActiveShipping::Location.new(
235
- city: 'COLLIERVILLE',
235
+ city: 'unknown',
236
236
  country: 'US',
237
237
  state: 'TN'
238
238
  )
@@ -242,41 +242,46 @@ class RemoteFedExTest < Minitest::Test
242
242
 
243
243
  def test_find_tracking_info_for_in_transit_shipment_1
244
244
  # unfortunately, we have to use Fedex unique identifiers, because the test tracking numbers are overloaded.
245
- response = @carrier.find_tracking_info('123456789012', unique_identifier: '2456979001~123456789012~FX')
245
+ response = @carrier.find_tracking_info('920241085725456')
246
246
  assert response.success?
247
247
  refute response.delivered?
248
- assert_equal '123456789012', response.tracking_number
249
- assert_equal :in_transit, response.status
250
- assert_equal 'IT', response.status_code
251
- assert_equal "Package available for clearance", response.status_description
252
- assert_equal 1, response.shipment_events.length
248
+ assert_equal '920241085725456', response.tracking_number
249
+ assert_equal :at_fedex_destination, response.status
250
+ assert_equal 'FD', response.status_code
251
+ assert_equal "At FedEx destination facility", response.status_description
252
+ assert_equal 7, response.shipment_events.length
253
253
  assert_nil response.actual_delivery_date
254
254
  assert_equal nil, response.scheduled_delivery_date
255
255
  end
256
256
 
257
257
  def test_find_tracking_info_for_in_transit_shipment_2
258
258
  # unfortunately, we have to use Fedex unique identifiers, because the test tracking numbers are overloaded.
259
- response = @carrier.find_tracking_info('123456789012', unique_identifier: '2456979000~123456789012~FX')
259
+ response = @carrier.find_tracking_info('403934084723025')
260
260
  assert response.success?
261
261
  refute response.delivered?
262
- assert_equal '123456789012', response.tracking_number
263
- assert_equal :in_transit, response.status
264
- assert_equal 'IT', response.status_code
265
- assert_equal "In transit", response.status_description
262
+ assert_equal '403934084723025', response.tracking_number
263
+ assert_equal :at_fedex_facility, response.status
264
+ assert_equal 'AR', response.status_code
265
+ assert_equal "Arrived at FedEx location", response.status_description
266
266
 
267
- assert_equal Time.parse('2014-11-25T20:04:00Z'), response.ship_time
267
+ assert_equal Time.parse('Fri, 03 Jan 2014'), response.ship_time
268
268
  assert_equal nil, response.scheduled_delivery_date
269
269
  assert_equal nil, response.actual_delivery_date
270
270
 
271
- assert_equal nil, response.origin
271
+ origin_address = ActiveShipping::Location.new(
272
+ city: 'CAMBRIDGE',
273
+ country: 'US',
274
+ state: 'OH'
275
+ )
276
+ assert_equal origin_address.to_hash, response.origin.to_hash
272
277
 
273
278
  destination_address = ActiveShipping::Location.new(
274
- city: 'TONNESSEE',
279
+ city: 'Spokane Valley',
275
280
  country: 'US',
276
- state: 'TN'
281
+ state: 'WA'
277
282
  )
278
283
  assert_equal destination_address.to_hash, response.destination.to_hash
279
- assert_equal 9, response.shipment_events.length
284
+ assert_equal 3, response.shipment_events.length
280
285
  end
281
286
 
282
287
  def test_find_tracking_info_with_multiple_matches
@@ -143,7 +143,7 @@ class RemoteStampsTest < Minitest::Test
143
143
 
144
144
  assert_nil response.label_url
145
145
 
146
- assert_equal "\r\nN\r\n", response.image[0..4]
146
+ assert_equal ";\r\n; ", response.image[0..4]
147
147
  end
148
148
 
149
149
  def test_international_shipment
@@ -311,4 +311,23 @@ class RemoteUPSTest < Minitest::Test
311
311
  ww_express_estimate = response.delivery_estimates.select {|de| de.service_name == "UPS Worldwide Express"}.first
312
312
  assert_equal Date.parse(1.business_day.from_now.to_s), ww_express_estimate.date
313
313
  end
314
+
315
+ def test_void_shipment
316
+ # this is a test tracking number from the ups docs that always returns sucess
317
+ response = @carrier.void_shipment('1Z12345E0390817264')
318
+ assert response
319
+ end
320
+
321
+ def test_void_beyond_time_limit
322
+ e = assert_raises(ResponseError) do
323
+ # this is a test tracking number from the ups docs that always returns time limit expired
324
+ @carrier.void_shipment('1Z12345E8793628675')
325
+ end
326
+ assert_equal(e.message, "Void shipment failed with message: Failure: Time for voiding has expired.")
327
+ end
328
+
329
+
330
+ def test_maximum_address_field_length
331
+ assert_equal 35, @carrier.maximum_address_field_length
332
+ end
314
333
  end
@@ -251,4 +251,8 @@ class CanadaPostPwsShippingTest < Minitest::Test
251
251
 
252
252
  assert_equal 0, response[:priced_options].size
253
253
  end
254
+
255
+ def test_maximum_address_field_length
256
+ assert_equal 44, @cp.maximum_address_field_length
257
+ end
254
258
  end
@@ -141,4 +141,8 @@ class CanadaPostTest < Minitest::Test
141
141
 
142
142
  assert rate_response.rates.length > 0, "Expecting rateestimates even without a value specified."
143
143
  end
144
+
145
+ def test_maximum_address_field_length
146
+ assert_equal 44, @carrier.maximum_address_field_length
147
+ end
144
148
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require "test_helper"
2
3
 
3
4
  class CorreiosTest < Minitest::Test
@@ -22,7 +23,7 @@ class CorreiosTest < Minitest::Test
22
23
  def test_book_request
23
24
  @carrier.expects(:perform).returns([@response_book_success])
24
25
  response = @carrier.find_rates(@saopaulo, @patosdeminas, [@book])
25
-
26
+
26
27
  [
27
28
  "sCepOrigem=01415000",
28
29
  "sCepDestino=38700000",
@@ -40,7 +41,7 @@ class CorreiosTest < Minitest::Test
40
41
  def test_poster_request
41
42
  @carrier.expects(:perform).returns([@response_poster_success])
42
43
  response = @carrier.find_rates(@saopaulo, @patosdeminas, [@poster])
43
-
44
+
44
45
  [
45
46
  "sCepOrigem=01415000",
46
47
  "sCepDestino=38700000",
@@ -58,7 +59,7 @@ class CorreiosTest < Minitest::Test
58
59
  def test_poster_and_book_request
59
60
  @carrier.expects(:perform).returns([@response_poster_success, @response_book_success])
60
61
  response = @carrier.find_rates(@saopaulo, @patosdeminas, [@poster, @book])
61
-
62
+
62
63
  [
63
64
  "sCepOrigem=01415000",
64
65
  "sCepDestino=38700000",
@@ -71,7 +72,7 @@ class CorreiosTest < Minitest::Test
71
72
  ].each do |query_param|
72
73
  assert_match query_param, response.urls.first
73
74
  end
74
-
75
+
75
76
  [
76
77
  "sCepOrigem=01415000",
77
78
  "sCepDestino=38700000",
@@ -89,7 +90,7 @@ class CorreiosTest < Minitest::Test
89
90
  def test_book_request_with_specific_services
90
91
  @carrier.expects(:perform).returns([@response_book_success])
91
92
  response = @carrier.find_rates(@saopaulo, @patosdeminas, [@book], :services => [41106, 40010, 40215])
92
-
93
+
93
94
  [
94
95
  "nCdServico=41106%2C40010%2C40215",
95
96
  "sCepOrigem=01415000",
@@ -241,4 +242,7 @@ class CorreiosTest < Minitest::Test
241
242
  assert_equal '(Grupo 3) e-SEDEX, com contrato', services[81850]
242
243
  end
243
244
 
245
+ def test_maximum_address_field_length
246
+ assert_equal 255, @carrier.maximum_address_field_length
247
+ end
244
248
  end
@@ -235,6 +235,25 @@ class FedExTest < Minitest::Test
235
235
  end
236
236
  end
237
237
 
238
+ def test_delivery_date_from_ground_home_transit_time
239
+ mock_response = xml_fixture('fedex/raterequest_response_with_ground_home_delivery')
240
+
241
+ @carrier.expects(:commit).returns(mock_response)
242
+
243
+ today = DateTime.civil(2015, 06, 03, 0, 0, 0, "-4")
244
+
245
+ Timecop.freeze(today) do
246
+ rate_estimates = @carrier.find_rates( location_fixtures[:ottawa],
247
+ location_fixtures[:beverly_hills],
248
+ package_fixtures.values_at(:book, :wii), :test => true)
249
+
250
+ # the above fixture will specify a transit time of 3 days, with 2 weekend days accounted for
251
+ delivery_date = Date.today + 5
252
+ assert_equal delivery_date, rate_estimates.rates.first.delivery_date
253
+ end
254
+ end
255
+
256
+
238
257
  def test_failure_to_parse_invalid_xml_results_in_a_useful_error
239
258
  mock_response = xml_fixture('fedex/invalid_fedex_reply')
240
259
 
@@ -466,4 +485,8 @@ class FedExTest < Minitest::Test
466
485
  :test => true))
467
486
  assert_equal result.search('RequestedPackageLineItems/CustomerReferences/Value').text, "FOO-123"
468
487
  end
488
+
489
+ def test_maximum_address_field_length
490
+ assert_equal 35, @carrier.maximum_address_field_length
491
+ end
469
492
  end
@@ -49,4 +49,8 @@ class KunakiTest < Minitest::Test
49
49
  assert_equal ["UPS 2nd Day Air", "UPS Ground", "UPS Next Day Air Saver", "USPS Priority Mail"], response.rates.collect(&:service_name).sort
50
50
  assert_equal [800, 1234, 2186, 3605], response.rates.collect(&:total_price).sort
51
51
  end
52
+
53
+ def test_maximum_address_field_length
54
+ assert_equal 255, @carrier.maximum_address_field_length
55
+ end
52
56
  end
@@ -171,4 +171,8 @@ class NewZealandPostTest < Minitest::Test
171
171
  response_params = { "responses" => [] }
172
172
  assert_equal response_params, error.response.params
173
173
  end
174
+
175
+ def test_maximum_address_field_length
176
+ assert_equal 255, @carrier.maximum_address_field_length
177
+ end
174
178
  end
@@ -184,4 +184,8 @@ class ShipwireTest < Minitest::Test
184
184
 
185
185
  assert response.success?
186
186
  end
187
+
188
+ def test_maximum_address_field_length
189
+ assert_equal 255, @carrier.maximum_address_field_length
190
+ end
187
191
  end
@@ -238,4 +238,8 @@ class StampsTest < Minitest::Test
238
238
  def response_chain(primary_response)
239
239
  @carrier.expects(:ssl_post).twice.returns(@authentication_response, primary_response)
240
240
  end
241
+
242
+ def test_maximum_address_field_length
243
+ assert_equal 255, @carrier.maximum_address_field_length
244
+ end
241
245
  end
@@ -506,4 +506,15 @@ class UPSTest < Minitest::Test
506
506
  )
507
507
  assert_equal ["UPS Ground"], response.rates.map(&:service_name)
508
508
  end
509
+
510
+ def test_void_shipment
511
+ mock_response = xml_fixture("ups/void_shipment_response")
512
+ @carrier.expects(:commit).returns(mock_response)
513
+ response = @carrier.void_shipment('1Z12345E0390817264')
514
+ assert response
515
+ end
516
+
517
+ def test_maximum_address_field_length
518
+ assert_equal 35, @carrier.maximum_address_field_length
519
+ end
509
520
  end
@@ -565,6 +565,10 @@ class USPSTest < Minitest::Test
565
565
  assert_equal [3767, 5526, 7231, 7231], response.rates.map(&:price)
566
566
  end
567
567
 
568
+ def test_maximum_address_field_length
569
+ assert_equal 38, @carrier.maximum_address_field_length
570
+ end
571
+
568
572
  private
569
573
 
570
574
  def build_service_node(options = {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James MacAulay
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-06-08 00:00:00.000000000 Z
14
+ date: 2015-06-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: quantified
@@ -255,6 +255,7 @@ files:
255
255
  - test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml
256
256
  - test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml
257
257
  - test/fixtures/xml/fedex/raterequest_reply.xml
258
+ - test/fixtures/xml/fedex/raterequest_response_with_ground_home_delivery.xml
258
259
  - test/fixtures/xml/fedex/reply_without_notifications.xml
259
260
  - test/fixtures/xml/fedex/tracking_request.xml
260
261
  - test/fixtures/xml/fedex/tracking_response_bad_tracking_number.xml
@@ -312,6 +313,7 @@ files:
312
313
  - test/fixtures/xml/ups/tracking_request.xml
313
314
  - test/fixtures/xml/ups/triple_accept_response.xml
314
315
  - test/fixtures/xml/ups/triple_confirm_response.xml
316
+ - test/fixtures/xml/ups/void_shipment_response.xml
315
317
  - test/fixtures/xml/usps/api_error_rate_response.xml
316
318
  - test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_base_rate_response.xml
317
319
  - test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_plus_rate_response.xml
@@ -448,6 +450,7 @@ test_files:
448
450
  - test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml
449
451
  - test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml
450
452
  - test/fixtures/xml/fedex/raterequest_reply.xml
453
+ - test/fixtures/xml/fedex/raterequest_response_with_ground_home_delivery.xml
451
454
  - test/fixtures/xml/fedex/reply_without_notifications.xml
452
455
  - test/fixtures/xml/fedex/tracking_request.xml
453
456
  - test/fixtures/xml/fedex/tracking_response_bad_tracking_number.xml
@@ -505,6 +508,7 @@ test_files:
505
508
  - test/fixtures/xml/ups/tracking_request.xml
506
509
  - test/fixtures/xml/ups/triple_accept_response.xml
507
510
  - test/fixtures/xml/ups/triple_confirm_response.xml
511
+ - test/fixtures/xml/ups/void_shipment_response.xml
508
512
  - test/fixtures/xml/usps/api_error_rate_response.xml
509
513
  - test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_base_rate_response.xml
510
514
  - test/fixtures/xml/usps/beverly_hills_to_new_york_book_commercial_plus_rate_response.xml