Class: ActiveShipping::Correios::CorreiosRequest
- Inherits:
-
Object
- Object
- ActiveShipping::Correios::CorreiosRequest
- Defined in:
- lib/active_shipping/carriers/correios.rb
Constant Summary collapse
- URL =
"http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx"
- RETURN_TYPE =
'xml'
- RETURN_INFORMATION_TYPE =
{ :prices => '1', :time => '2', :prices_and_time => '3' }
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
Instance Method Summary collapse
- #create_response(raw_xmls) ⇒ Object
-
#initialize(origin, destination, packages, options) ⇒ CorreiosRequest
constructor
A new instance of CorreiosRequest.
Constructor Details
#initialize(origin, destination, packages, options) ⇒ CorreiosRequest
Returns a new instance of CorreiosRequest.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/active_shipping/carriers/correios.rb', line 64 def initialize(origin, destination, packages, ) @options = @origin = origin @destination = destination packages = packages.map do |package| CorreiosPackage.new(package, 1) end @params = { company_id: [:company_id], password: [:password], service_type: service_type, origin_zip: origin.zip, destination_zip: destination.zip, mao_propria_extra: parse_boolean([:mao_propria_extra]), declared_value_extra: parse_currency([:declared_value_extra]), delivery_notice_extra: parse_boolean([:delivery_notice_extra]), return_type: RETURN_TYPE, return_information: RETURN_INFORMATION_TYPE[:prices] } @urls = packages.map { |package| create_url(package).to_s } end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
62 63 64 |
# File 'lib/active_shipping/carriers/correios.rb', line 62 def destination @destination end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
62 63 64 |
# File 'lib/active_shipping/carriers/correios.rb', line 62 def origin @origin end |
#urls ⇒ Object (readonly)
Returns the value of attribute urls.
62 63 64 |
# File 'lib/active_shipping/carriers/correios.rb', line 62 def urls @urls end |
Instance Method Details
#create_response(raw_xmls) ⇒ Object
88 89 90 91 |
# File 'lib/active_shipping/carriers/correios.rb', line 88 def create_response(raw_xmls) correios_response = CorreiosResponse.new(self, raw_xmls) correios_response.rate_response end |