Class: ActiveMerchant::Shipping::BenchmarkCarrier

Inherits:
Carrier show all
Defined in:
lib/active_shipping/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

#create_shipment, #initialize, #maximum_weight, #requirements, #valid_credentials?

Constructor Details

This class inherits a constructor from ActiveMerchant::Shipping::Carrier

Instance Method Details

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


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

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