Class: ActiveShipping::Correios

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

Defined Under Namespace

Classes: CorreiosPackage, CorreiosRateResponse, CorreiosRequest, CorreiosResponse

Constant Summary collapse

DEFAULT_SERVICES =
['04510', '04014']
AVAILABLE_SERVICES =
{
  '04510' => 'PAC sem contrato',
  '04014' => 'SEDEX sem contrato',
  41106 => 'PAC sem contrato',
  41068 => 'PAC com contrato',
  41300 => 'PAC para grandes formatos',
  40010 => 'SEDEX sem contrato',
  40045 => 'SEDEX a Cobrar, sem contrato',
  40126 => 'SEDEX a Cobrar, com contrato',
  40215 => 'SEDEX 10, sem contrato',
  40290 => 'SEDEX Hoje, sem contrato',
  40096 => 'SEDEX com contrato',
  40436 => 'SEDEX com contrato',
  40444 => 'SEDEX com contrato',
  40568 => 'SEDEX com contrato',
  40606 => 'SEDEX com contrato',
  81019 => 'e-SEDEX, com contrato',
  81027 => 'e-SEDEX Prioritário, com contrato',
  81035 => 'e-SEDEX Express, com contrato',
  81868 => '(Grupo 1) e-SEDEX, com contrato',
  81833 => '(Grupo 2) e-SEDEX, com contrato',
  81850 => '(Grupo 3) e-SEDEX, com contrato'
}.freeze
@@name =
"Correios do Brasil"

Instance Attribute Summary

Attributes inherited from Carrier

#last_request, #test_mode

Class Method Summary collapse

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

Class Method Details

.available_servicesObject



16
17
18
# File 'lib/active_shipping/carriers/correios.rb', line 16

def self.available_services
  AVAILABLE_SERVICES
end

Instance Method Details

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



7
8
9
10
11
12
13
14
# File 'lib/active_shipping/carriers/correios.rb', line 7

def find_rates(origin, destination, packages, options = {})
  options = @options.merge(options)

  request = CorreiosRequest.new(origin, destination, packages, options)
  response = request.create_response(perform(request.urls))

  response
end

#perform(urls) ⇒ Object (protected)



47
48
49
# File 'lib/active_shipping/carriers/correios.rb', line 47

def perform(urls)
  urls.map { |url| ssl_get(url) }
end