Class: ActiveShipping::BenchmarkCarrier

Inherits:
Carrier
  • Object
show all
Defined in:
lib/active_shipping/carriers/benchmark_carrier.rb

Constant Summary collapse

@@name =
"Benchmark Carrier"

Instance Attribute Summary

Attributes inherited from Carrier

#last_request, #test_mode

Instance Method Summary collapse

Methods inherited from Carrier

#available_services, #cancel_shipment, #create_shipment, default_location, #find_tracking_info, #initialize, #maximum_address_field_length, #maximum_weight, #requirements, #save_request, #timestamp_from_business_day, #valid_credentials?

Constructor Details

This class inherits a constructor from ActiveShipping::Carrier

Instance Method Details

#find_rates(origin, destination, packages, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/active_shipping/carriers/benchmark_carrier.rb', line 10

def find_rates(origin, destination, packages, options = {})
  origin = Location.from(origin)
  destination = Location.from(destination)
  packages = Array(packages)

  delay_time = generate_simulated_lag

  bogus_estimate = RateEstimate.new(
    origin, destination, @@name,
    "Free Benchmark Shipping", :total_price => 0, :currency => 'USD',
                               :packages => packages, :delivery_range => [Time.now.utc.strftime("%Y-%d-%m"), Time.now.utc.strftime("%Y-%d-%m")]
    )
  RateResponse.new(true, "Success (delayed #{delay_time} seconds)", {:rate => 'free'}, :rates => [bogus_estimate], :xml => "<rate>free</rate>")
end