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.



5
6
7
8
9
10
11
12
13
14
# File 'lib/canada_post/rate.rb', line 5

def initialize(options={})
  @service_type = options[:service_name]
  @service_code = options[:service_code]
  @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]
  @transit_time = options[:service_standard][:expected_transit_time]
end

Instance Attribute Details

#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

#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

#transit_timeObject

Returns the value of attribute transit_time.



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

def transit_time
  @transit_time
end

Instance Method Details

#total_taxesObject



16
17
18
# File 'lib/canada_post/rate.rb', line 16

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