Class: CanadaPost::Rate

Inherits:
Object
  • Object
show all
Defined in:
lib/canada_post/rate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Rate

Returns a new instance of Rate.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/canada_post/rate.rb', line 8

def initialize(options={})
  @service_type = options[:service_name]
  @service_code = options[:service_code]
  @service_link = options[:service_link]
  @total_net_charge = options[:price_details][:due]
  @total_base_charge = options[:price_details][:base]
  @gst_taxes = options[:price_details][:taxes][:gst]
  @pst_taxes = options[:price_details][:taxes][:pst]
  @hst_taxes = options[:price_details][:taxes][:hst]
  @expected_transit_time = options[:service_standard][:expected_transit_time]
  @expected_delivery_date = options[:service_standard][:expected_delivery_date]
  @guaranteed_delivery = options[:service_standard][:guaranteed_delivery]
  @am_delivery = options[:service_standard][:am_delivery]
end

Instance Attribute Details

#am_deliveryObject

Returns the value of attribute am_delivery.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def am_delivery
  @am_delivery
end

#expected_delivery_dateObject

Returns the value of attribute expected_delivery_date.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def expected_delivery_date
  @expected_delivery_date
end

#expected_transit_timeObject

Returns the value of attribute expected_transit_time.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def expected_transit_time
  @expected_transit_time
end

#guaranteed_deliveryObject

Returns the value of attribute guaranteed_delivery.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def guaranteed_delivery
  @guaranteed_delivery
end

#rate_typeObject

Returns the value of attribute rate_type.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def rate_type
  @rate_type
end

#service_codeObject

Returns the value of attribute service_code.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def service_code
  @service_code
end

Returns the value of attribute service_link.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def service_link
  @service_link
end

#service_typeObject

Returns the value of attribute service_type.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def service_type
  @service_type
end

#total_base_chargeObject

Returns the value of attribute total_base_charge.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def total_base_charge
  @total_base_charge
end

#total_net_chargeObject

Returns the value of attribute total_net_charge.



4
5
6
# File 'lib/canada_post/rate.rb', line 4

def total_net_charge
  @total_net_charge
end

Instance Method Details

#total_taxesObject



23
24
25
# File 'lib/canada_post/rate.rb', line 23

def total_taxes
  (@gst_taxes.to_f + @pst_taxes.to_f + @hst_taxes.to_f).to_s
end