Module: Deliveries::Couriers::Envialia

Extended by:
Deliveries::Courier
Defined in:
lib/deliveries/couriers/envialia.rb,
lib/deliveries/couriers/envialia/pickups/trace.rb,
lib/deliveries/couriers/envialia/authentication.rb,
lib/deliveries/couriers/envialia/pickups/create.rb,
lib/deliveries/couriers/envialia/labels/generate.rb,
lib/deliveries/couriers/envialia/shipments/trace.rb,
lib/deliveries/couriers/envialia/shipments/create.rb,
lib/deliveries/couriers/envialia/pickups/trace/format_response.rb,
lib/deliveries/couriers/envialia/shipments/trace/format_response.rb

Defined Under Namespace

Modules: Authentication, Labels, Pickups, Shipments Classes: Config

Constant Summary collapse

ENVIALIA_LOGIN_ENDPOINT_LIVE =
'http://ws.envialia.com/SOAP?service=LoginService'.freeze
ENVIALIA_LOGIN_ENDPOINT_TEST =
'http://wstest.envialia.com:9085/SOAP?service=LoginService'.freeze
ENVIALIA_ENDPOINT_LIVE =
'http://ws.envialia.com/SOAP?service=WebServService'.freeze
ENVIALIA_ENDPOINT_TEST =
'http://wstest.envialia.com:9085/SOAP?service=WebServService'.freeze

Class Method Summary collapse

Methods included from Deliveries::Courier

config, configure, configured?, get_collection_point, get_collection_points, live?, test?

Class Method Details

.create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, tracking_code: nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/deliveries/couriers/envialia.rb', line 40

def create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, tracking_code: nil, **)
  Pickups::Create.new(
    sender: sender,
    receiver: receiver,
    parcels: parcels,
    reference_code: reference_code,
    pickup_date: pickup_date,
    remarks: remarks,
    tracking_code: tracking_code
  ).execute
end

.create_shipment(sender:, receiver:, parcels:, reference_code:, collection_point: nil, shipment_date: nil, remarks: nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/deliveries/couriers/envialia.rb', line 28

def create_shipment(sender:, receiver:, parcels:, reference_code:, collection_point: nil, shipment_date: nil, remarks: nil, **)
  Shipments::Create.new(
    sender: sender,
    receiver: receiver,
    collection_point: collection_point,
    shipment_date: shipment_date,
    parcels: parcels,
    reference_code: reference_code,
    remarks: remarks
  ).execute
end

.get_label(tracking_code:) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/deliveries/couriers/envialia.rb', line 72

def get_label(tracking_code:, **)
  pdf = Labels::Generate.new(
    tracking_codes: tracking_code
  ).execute.first

  Deliveries::Label.new(raw: pdf)
end

.get_labels(tracking_codes:) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/deliveries/couriers/envialia.rb', line 80

def get_labels(tracking_codes:, **)
  labels = Deliveries::Labels.new

  Labels::Generate.new(
    tracking_codes: tracking_codes
  ).execute.each do |pdf|
    labels << pdf
  end

  labels
end

.pickup_info(tracking_code:) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/deliveries/couriers/envialia.rb', line 62

def pickup_info(tracking_code:, **)
  response = Pickups::Trace.new(
    tracking_code: tracking_code
  ).execute

  tracking_info_params = Pickups::Trace::FormatResponse.new(response: response).execute
  tracking_info_params.merge!({ tracking_code: tracking_code })
  Deliveries::TrackingInfo.new(**tracking_info_params)
end

.shipment_info(tracking_code:) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/deliveries/couriers/envialia.rb', line 52

def shipment_info(tracking_code:, **)
  response = Shipments::Trace.new(
    tracking_code: tracking_code
  ).execute

  tracking_info_params = Shipments::Trace::FormatResponse.new(response: response).execute
  tracking_info_params.merge!({ tracking_code: tracking_code })
  Deliveries::TrackingInfo.new(**tracking_info_params)
end