deliveries 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +19 -0
  3. data/.gitignore +12 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +34 -0
  6. data/CHANGELOG.md +13 -0
  7. data/Gemfile +12 -0
  8. data/Gemfile.lock +127 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +207 -0
  11. data/Rakefile +12 -0
  12. data/bin/console +15 -0
  13. data/bin/setup +8 -0
  14. data/deliveries.gemspec +36 -0
  15. data/lib/deliveries/address.rb +71 -0
  16. data/lib/deliveries/checkpoint.rb +12 -0
  17. data/lib/deliveries/collection_point.rb +45 -0
  18. data/lib/deliveries/courier.rb +69 -0
  19. data/lib/deliveries/couriers/correos_express/address.rb +31 -0
  20. data/lib/deliveries/couriers/correos_express/collection_points/search/format_response.rb +82 -0
  21. data/lib/deliveries/couriers/correos_express/collection_points/search.rb +56 -0
  22. data/lib/deliveries/couriers/correos_express/labels/generate.rb +68 -0
  23. data/lib/deliveries/couriers/correos_express/pickups/create/defaults.rb +60 -0
  24. data/lib/deliveries/couriers/correos_express/pickups/create/format_params.rb +95 -0
  25. data/lib/deliveries/couriers/correos_express/pickups/create.rb +66 -0
  26. data/lib/deliveries/couriers/correos_express/pickups/cutoff_time/format_params.rb +40 -0
  27. data/lib/deliveries/couriers/correos_express/pickups/cutoff_time.rb +61 -0
  28. data/lib/deliveries/couriers/correos_express/pickups/trace/correos.test.wsdl +163 -0
  29. data/lib/deliveries/couriers/correos_express/pickups/trace/correos.wsdl +163 -0
  30. data/lib/deliveries/couriers/correos_express/pickups/trace/format_response.rb +71 -0
  31. data/lib/deliveries/couriers/correos_express/pickups/trace.rb +49 -0
  32. data/lib/deliveries/couriers/correos_express/shipments/create/defaults.rb +80 -0
  33. data/lib/deliveries/couriers/correos_express/shipments/create/format_params.rb +99 -0
  34. data/lib/deliveries/couriers/correos_express/shipments/create.rb +101 -0
  35. data/lib/deliveries/couriers/correos_express/shipments/trace/format_response.rb +67 -0
  36. data/lib/deliveries/couriers/correos_express/shipments/trace.rb +65 -0
  37. data/lib/deliveries/couriers/correos_express.rb +162 -0
  38. data/lib/deliveries/couriers/dummy.rb +106 -0
  39. data/lib/deliveries/couriers/mondial_relay/address.rb +31 -0
  40. data/lib/deliveries/couriers/mondial_relay/collection_points/search/format_response.rb +103 -0
  41. data/lib/deliveries/couriers/mondial_relay/labels/generate.rb +40 -0
  42. data/lib/deliveries/couriers/mondial_relay/pickups/create/format_params.rb +57 -0
  43. data/lib/deliveries/couriers/mondial_relay/shipments/create/defaults.rb +96 -0
  44. data/lib/deliveries/couriers/mondial_relay/shipments/create/format_params.rb +68 -0
  45. data/lib/deliveries/couriers/mondial_relay/shipments/create.rb +36 -0
  46. data/lib/deliveries/couriers/mondial_relay/shipments/trace/format_response.rb +94 -0
  47. data/lib/deliveries/couriers/mondial_relay/shipments/trace.rb +47 -0
  48. data/lib/deliveries/couriers/mondial_relay/status_codes.rb +105 -0
  49. data/lib/deliveries/couriers/mondial_relay.rb +189 -0
  50. data/lib/deliveries/couriers/mondial_relay_dual/address.rb +31 -0
  51. data/lib/deliveries/couriers/mondial_relay_dual/pickups/create/format_params.rb +39 -0
  52. data/lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb +101 -0
  53. data/lib/deliveries/couriers/mondial_relay_dual/shipments/create.rb +133 -0
  54. data/lib/deliveries/couriers/mondial_relay_dual.rb +105 -0
  55. data/lib/deliveries/couriers/spring/address.rb +23 -0
  56. data/lib/deliveries/couriers/spring/labels/generate.rb +33 -0
  57. data/lib/deliveries/couriers/spring/request.rb +43 -0
  58. data/lib/deliveries/couriers/spring/shipments/create/defaults.rb +73 -0
  59. data/lib/deliveries/couriers/spring/shipments/create/format_params.rb +77 -0
  60. data/lib/deliveries/couriers/spring/shipments/create.rb +45 -0
  61. data/lib/deliveries/couriers/spring/shipments/trace/format_response.rb +79 -0
  62. data/lib/deliveries/couriers/spring/shipments/trace.rb +29 -0
  63. data/lib/deliveries/couriers/spring.rb +84 -0
  64. data/lib/deliveries/couriers/ups/collection_points/search.rb +142 -0
  65. data/lib/deliveries/couriers/ups/json_request.rb +40 -0
  66. data/lib/deliveries/couriers/ups/labels/generate.rb +72 -0
  67. data/lib/deliveries/couriers/ups/shipments/create.rb +210 -0
  68. data/lib/deliveries/couriers/ups/shipments/trace.rb +79 -0
  69. data/lib/deliveries/couriers/ups.rb +122 -0
  70. data/lib/deliveries/couriers.rb +14 -0
  71. data/lib/deliveries/delivery.rb +20 -0
  72. data/lib/deliveries/errors.rb +22 -0
  73. data/lib/deliveries/label.rb +20 -0
  74. data/lib/deliveries/label_utils.rb +67 -0
  75. data/lib/deliveries/labels.rb +40 -0
  76. data/lib/deliveries/pickup.rb +15 -0
  77. data/lib/deliveries/shipment.rb +15 -0
  78. data/lib/deliveries/tracking_info.rb +29 -0
  79. data/lib/deliveries/version.rb +5 -0
  80. data/lib/deliveries.rb +63 -0
  81. metadata +240 -0
@@ -0,0 +1,163 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="seguimiento"
3
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
4
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://org.apache.axis2/xsd"
5
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
6
+ xmlns:ax21="http://seguimiento.recogida.ws.chx.es/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
7
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
8
+ xmlns:es.chx.ws.recogida.seguimiento="seguimiento.recogida.ws.chx.es" xmlns:ax22="http://ws.chx.es/xsd"
9
+ targetNamespace="seguimiento">
10
+ <wsdl:types>
11
+ <xs:schema xmlns:ax23="http://ws.chx.es/xsd" attributeFormDefault="qualified"
12
+ elementFormDefault="qualified" targetNamespace="http://seguimiento.recogida.ws.chx.es/xsd">
13
+ <xs:import namespace="http://ws.chx.es/xsd"/>
14
+ <xs:complexType name="RetornoSeguimientoRecogida">
15
+ <xs:complexContent>
16
+ <xs:extension base="ax22:RetornoAbstract">
17
+ <xs:sequence>
18
+ <xs:element minOccurs="0" name="cliente" nillable="true" type="xs:string"/>
19
+ <xs:element minOccurs="0" name="codPosRecogida" nillable="true"
20
+ type="xs:string"/>
21
+ <xs:element minOccurs="0" name="contactoRecogida" nillable="true"
22
+ type="xs:string"/>
23
+ <xs:element minOccurs="0" name="domRecogida" nillable="true"
24
+ type="xs:string"/>
25
+ <xs:element minOccurs="0" name="fecRecogida" nillable="true"
26
+ type="xs:string"/>
27
+ <xs:element minOccurs="0" name="importe" nillable="true" type="xs:string"/>
28
+ <xs:element minOccurs="0" name="kilos" nillable="true" type="xs:string"/>
29
+ <xs:element minOccurs="0" name="mercancia" nillable="true" type="xs:string"/>
30
+ <xs:element minOccurs="0" name="nifRecogida" nillable="true"
31
+ type="xs:string"/>
32
+ <xs:element minOccurs="0" name="nomRecogida" nillable="true"
33
+ type="xs:string"/>
34
+ <xs:element minOccurs="0" name="numBultos" nillable="true" type="xs:string"/>
35
+ <xs:element minOccurs="0" name="numBultosReales" nillable="true"
36
+ type="xs:string"/>
37
+ <xs:element minOccurs="0" name="observaciones" nillable="true"
38
+ type="xs:string"/>
39
+ <xs:element minOccurs="0" name="paisRecogida" nillable="true"
40
+ type="xs:string"/>
41
+ <xs:element minOccurs="0" name="pobRecogida" nillable="true"
42
+ type="xs:string"/>
43
+ <xs:element minOccurs="0" name="recogida" nillable="true" type="xs:string"/>
44
+ <xs:element minOccurs="0" name="referencia" nillable="true" type="xs:string"/>
45
+ <xs:element minOccurs="0" name="resultado" nillable="true" type="xs:string"/>
46
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="situaciones"
47
+ nillable="true" type="ax21:Situacion"/>
48
+ <xs:element minOccurs="0" name="telefonoRecogida" nillable="true"
49
+ type="xs:string"/>
50
+ <xs:element minOccurs="0" name="tipoRecogida" nillable="true"
51
+ type="xs:string"/>
52
+ </xs:sequence>
53
+ </xs:extension>
54
+ </xs:complexContent>
55
+ </xs:complexType>
56
+ <xs:complexType name="Situacion">
57
+ <xs:sequence>
58
+ <xs:element minOccurs="0" name="ampliacion" nillable="true" type="xs:string"/>
59
+ <xs:element minOccurs="0" name="codMotivo" nillable="true" type="xs:string"/>
60
+ <xs:element minOccurs="0" name="codSituacion" nillable="true" type="xs:string"/>
61
+ <xs:element minOccurs="0" name="descMotivo" nillable="true" type="xs:string"/>
62
+ <xs:element minOccurs="0" name="descSituacion" nillable="true" type="xs:string"/>
63
+ <xs:element minOccurs="0" name="fecSistema" nillable="true" type="xs:string"/>
64
+ <xs:element minOccurs="0" name="fecSituacion" nillable="true" type="xs:string"/>
65
+ <xs:element minOccurs="0" name="usrSituacion" nillable="true" type="xs:string"/>
66
+ </xs:sequence>
67
+ </xs:complexType>
68
+ </xs:schema>
69
+ <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
70
+ targetNamespace="http://ws.chx.es/xsd">
71
+ <xs:complexType name="RetornoAbstract">
72
+ <xs:sequence>
73
+ <xs:element minOccurs="0" name="codigoRetorno" type="xs:int"/>
74
+ <xs:element minOccurs="0" name="mensajeRetorno" nillable="true" type="xs:string"/>
75
+ </xs:sequence>
76
+ </xs:complexType>
77
+ </xs:schema>
78
+ <xs:schema xmlns:ax24="http://seguimiento.recogida.ws.chx.es/xsd" attributeFormDefault="qualified"
79
+ elementFormDefault="qualified" targetNamespace="seguimiento.recogida.ws.chx.es">
80
+ <xs:import namespace="http://seguimiento.recogida.ws.chx.es/xsd"/>
81
+ <xs:element name="seguimientoRecogida">
82
+ <xs:complexType>
83
+ <xs:sequence>
84
+ <xs:element minOccurs="0" name="solicitante" nillable="true" type="xs:string"/>
85
+ <xs:element minOccurs="0" name="dato" nillable="true" type="xs:string"/>
86
+ <xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>
87
+ <xs:element minOccurs="0" name="codCliente" nillable="true" type="xs:string"/>
88
+ <xs:element minOccurs="0" name="fecRecogida" nillable="true" type="xs:string"/>
89
+ </xs:sequence>
90
+ </xs:complexType>
91
+ </xs:element>
92
+ <xs:element name="seguimientoRecogidaResponse">
93
+ <xs:complexType>
94
+ <xs:sequence>
95
+ <xs:element minOccurs="0" name="return" nillable="true"
96
+ type="ax24:RetornoSeguimientoRecogida"/>
97
+ </xs:sequence>
98
+ </xs:complexType>
99
+ </xs:element>
100
+ </xs:schema>
101
+ </wsdl:types>
102
+ <wsdl:message name="seguimientoRecogidaRequest">
103
+ <wsdl:part name="parameters" element="es.chx.ws.recogida.seguimiento:seguimientoRecogida"/>
104
+ </wsdl:message>
105
+ <wsdl:message name="seguimientoRecogidaResponse">
106
+ <wsdl:part name="parameters"
107
+ element="es.chx.ws.recogida.seguimiento:seguimientoRecogidaResponse"/>
108
+ </wsdl:message>
109
+ <wsdl:portType name="SeguimientoRecogidaPortType">
110
+ <wsdl:operation name="seguimientoRecogida">
111
+ <wsdl:input message="axis2:seguimientoRecogidaRequest" wsaw:Action="urn:seguimientoRecogida"/>
112
+ <wsdl:output message="axis2:seguimientoRecogidaResponse"
113
+ wsaw:Action="urn:seguimientoRecogidaResponse"/>
114
+ </wsdl:operation>
115
+ </wsdl:portType>
116
+ <wsdl:binding name="SeguimientoRecogidaSoap11Binding" type="axis2:SeguimientoRecogidaPortType">
117
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
118
+ <wsdl:operation name="seguimientoRecogida">
119
+ <soap:operation soapAction="urn:seguimientoRecogida" style="document"/>
120
+ <wsdl:input>
121
+ <soap:body use="literal"/>
122
+ </wsdl:input>
123
+ <wsdl:output>
124
+ <soap:body use="literal"/>
125
+ </wsdl:output>
126
+ </wsdl:operation>
127
+ </wsdl:binding>
128
+ <wsdl:binding name="SeguimientoRecogidaSoap12Binding" type="axis2:SeguimientoRecogidaPortType">
129
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
130
+ <wsdl:operation name="seguimientoRecogida">
131
+ <soap12:operation soapAction="urn:seguimientoRecogida" style="document"/>
132
+ <wsdl:input>
133
+ <soap12:body use="literal"/>
134
+ </wsdl:input>
135
+ <wsdl:output>
136
+ <soap12:body use="literal"/>
137
+ </wsdl:output>
138
+ </wsdl:operation>
139
+ </wsdl:binding>
140
+ <wsdl:binding name="SeguimientoRecogidaHttpBinding" type="axis2:SeguimientoRecogidaPortType">
141
+ <http:binding verb="POST"/>
142
+ <wsdl:operation name="seguimientoRecogida">
143
+ <http:operation location="SeguimientoRecogida/seguimientoRecogida"/>
144
+ <wsdl:input>
145
+ <mime:content type="text/xml" part="seguimientoRecogida"/>
146
+ </wsdl:input>
147
+ <wsdl:output>
148
+ <mime:content type="text/xml" part="seguimientoRecogida"/>
149
+ </wsdl:output>
150
+ </wsdl:operation>
151
+ </wsdl:binding>
152
+ <wsdl:service name="SeguimientoRecogida">
153
+ <wsdl:port name="SeguimientoRecogidaHttpSoap11Endpoint" binding="axis2:SeguimientoRecogidaSoap11Binding">
154
+ <soap:address location="https://www.correosexpress.com/wspsc/services/SeguimientoRecogida"/>
155
+ </wsdl:port>
156
+ <wsdl:port name="SeguimientoRecogidaHttpSoap12Endpoint" binding="axis2:SeguimientoRecogidaSoap12Binding">
157
+ <soap12:address location="https://www.correosexpress.com/wspsc/services/SeguimientoRecogida"/>
158
+ </wsdl:port>
159
+ <wsdl:port name="SeguimientoRecogidaHttpEndpoint" binding="axis2:SeguimientoRecogidaHttpBinding">
160
+ <http:address location="https://www.correosexpress.com/wspsc/services/SeguimientoRecogida"/>
161
+ </wsdl:port>
162
+ </wsdl:service>
163
+ </wsdl:definitions>
@@ -0,0 +1,163 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="seguimiento"
3
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
4
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://org.apache.axis2/xsd"
5
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
6
+ xmlns:ax21="http://seguimiento.recogida.ws.chx.es/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
7
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
8
+ xmlns:es.chx.ws.recogida.seguimiento="seguimiento.recogida.ws.chx.es" xmlns:ax22="http://ws.chx.es/xsd"
9
+ targetNamespace="seguimiento">
10
+ <wsdl:types>
11
+ <xs:schema xmlns:ax23="http://ws.chx.es/xsd" attributeFormDefault="qualified"
12
+ elementFormDefault="qualified" targetNamespace="http://seguimiento.recogida.ws.chx.es/xsd">
13
+ <xs:import namespace="http://ws.chx.es/xsd"/>
14
+ <xs:complexType name="RetornoSeguimientoRecogida">
15
+ <xs:complexContent>
16
+ <xs:extension base="ax22:RetornoAbstract">
17
+ <xs:sequence>
18
+ <xs:element minOccurs="0" name="cliente" nillable="true" type="xs:string"/>
19
+ <xs:element minOccurs="0" name="codPosRecogida" nillable="true"
20
+ type="xs:string"/>
21
+ <xs:element minOccurs="0" name="contactoRecogida" nillable="true"
22
+ type="xs:string"/>
23
+ <xs:element minOccurs="0" name="domRecogida" nillable="true"
24
+ type="xs:string"/>
25
+ <xs:element minOccurs="0" name="fecRecogida" nillable="true"
26
+ type="xs:string"/>
27
+ <xs:element minOccurs="0" name="importe" nillable="true" type="xs:string"/>
28
+ <xs:element minOccurs="0" name="kilos" nillable="true" type="xs:string"/>
29
+ <xs:element minOccurs="0" name="mercancia" nillable="true" type="xs:string"/>
30
+ <xs:element minOccurs="0" name="nifRecogida" nillable="true"
31
+ type="xs:string"/>
32
+ <xs:element minOccurs="0" name="nomRecogida" nillable="true"
33
+ type="xs:string"/>
34
+ <xs:element minOccurs="0" name="numBultos" nillable="true" type="xs:string"/>
35
+ <xs:element minOccurs="0" name="numBultosReales" nillable="true"
36
+ type="xs:string"/>
37
+ <xs:element minOccurs="0" name="observaciones" nillable="true"
38
+ type="xs:string"/>
39
+ <xs:element minOccurs="0" name="paisRecogida" nillable="true"
40
+ type="xs:string"/>
41
+ <xs:element minOccurs="0" name="pobRecogida" nillable="true"
42
+ type="xs:string"/>
43
+ <xs:element minOccurs="0" name="recogida" nillable="true" type="xs:string"/>
44
+ <xs:element minOccurs="0" name="referencia" nillable="true" type="xs:string"/>
45
+ <xs:element minOccurs="0" name="resultado" nillable="true" type="xs:string"/>
46
+ <xs:element maxOccurs="unbounded" minOccurs="0" name="situaciones"
47
+ nillable="true" type="ax21:Situacion"/>
48
+ <xs:element minOccurs="0" name="telefonoRecogida" nillable="true"
49
+ type="xs:string"/>
50
+ <xs:element minOccurs="0" name="tipoRecogida" nillable="true"
51
+ type="xs:string"/>
52
+ </xs:sequence>
53
+ </xs:extension>
54
+ </xs:complexContent>
55
+ </xs:complexType>
56
+ <xs:complexType name="Situacion">
57
+ <xs:sequence>
58
+ <xs:element minOccurs="0" name="ampliacion" nillable="true" type="xs:string"/>
59
+ <xs:element minOccurs="0" name="codMotivo" nillable="true" type="xs:string"/>
60
+ <xs:element minOccurs="0" name="codSituacion" nillable="true" type="xs:string"/>
61
+ <xs:element minOccurs="0" name="descMotivo" nillable="true" type="xs:string"/>
62
+ <xs:element minOccurs="0" name="descSituacion" nillable="true" type="xs:string"/>
63
+ <xs:element minOccurs="0" name="fecSistema" nillable="true" type="xs:string"/>
64
+ <xs:element minOccurs="0" name="fecSituacion" nillable="true" type="xs:string"/>
65
+ <xs:element minOccurs="0" name="usrSituacion" nillable="true" type="xs:string"/>
66
+ </xs:sequence>
67
+ </xs:complexType>
68
+ </xs:schema>
69
+ <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
70
+ targetNamespace="http://ws.chx.es/xsd">
71
+ <xs:complexType name="RetornoAbstract">
72
+ <xs:sequence>
73
+ <xs:element minOccurs="0" name="codigoRetorno" type="xs:int"/>
74
+ <xs:element minOccurs="0" name="mensajeRetorno" nillable="true" type="xs:string"/>
75
+ </xs:sequence>
76
+ </xs:complexType>
77
+ </xs:schema>
78
+ <xs:schema xmlns:ax24="http://seguimiento.recogida.ws.chx.es/xsd" attributeFormDefault="qualified"
79
+ elementFormDefault="qualified" targetNamespace="seguimiento.recogida.ws.chx.es">
80
+ <xs:import namespace="http://seguimiento.recogida.ws.chx.es/xsd"/>
81
+ <xs:element name="seguimientoRecogida">
82
+ <xs:complexType>
83
+ <xs:sequence>
84
+ <xs:element minOccurs="0" name="solicitante" nillable="true" type="xs:string"/>
85
+ <xs:element minOccurs="0" name="dato" nillable="true" type="xs:string"/>
86
+ <xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>
87
+ <xs:element minOccurs="0" name="codCliente" nillable="true" type="xs:string"/>
88
+ <xs:element minOccurs="0" name="fecRecogida" nillable="true" type="xs:string"/>
89
+ </xs:sequence>
90
+ </xs:complexType>
91
+ </xs:element>
92
+ <xs:element name="seguimientoRecogidaResponse">
93
+ <xs:complexType>
94
+ <xs:sequence>
95
+ <xs:element minOccurs="0" name="return" nillable="true"
96
+ type="ax24:RetornoSeguimientoRecogida"/>
97
+ </xs:sequence>
98
+ </xs:complexType>
99
+ </xs:element>
100
+ </xs:schema>
101
+ </wsdl:types>
102
+ <wsdl:message name="seguimientoRecogidaRequest">
103
+ <wsdl:part name="parameters" element="es.chx.ws.recogida.seguimiento:seguimientoRecogida"/>
104
+ </wsdl:message>
105
+ <wsdl:message name="seguimientoRecogidaResponse">
106
+ <wsdl:part name="parameters"
107
+ element="es.chx.ws.recogida.seguimiento:seguimientoRecogidaResponse"/>
108
+ </wsdl:message>
109
+ <wsdl:portType name="SeguimientoRecogidaPortType">
110
+ <wsdl:operation name="seguimientoRecogida">
111
+ <wsdl:input message="axis2:seguimientoRecogidaRequest" wsaw:Action="urn:seguimientoRecogida"/>
112
+ <wsdl:output message="axis2:seguimientoRecogidaResponse"
113
+ wsaw:Action="urn:seguimientoRecogidaResponse"/>
114
+ </wsdl:operation>
115
+ </wsdl:portType>
116
+ <wsdl:binding name="SeguimientoRecogidaSoap11Binding" type="axis2:SeguimientoRecogidaPortType">
117
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
118
+ <wsdl:operation name="seguimientoRecogida">
119
+ <soap:operation soapAction="urn:seguimientoRecogida" style="document"/>
120
+ <wsdl:input>
121
+ <soap:body use="literal"/>
122
+ </wsdl:input>
123
+ <wsdl:output>
124
+ <soap:body use="literal"/>
125
+ </wsdl:output>
126
+ </wsdl:operation>
127
+ </wsdl:binding>
128
+ <wsdl:binding name="SeguimientoRecogidaSoap12Binding" type="axis2:SeguimientoRecogidaPortType">
129
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
130
+ <wsdl:operation name="seguimientoRecogida">
131
+ <soap12:operation soapAction="urn:seguimientoRecogida" style="document"/>
132
+ <wsdl:input>
133
+ <soap12:body use="literal"/>
134
+ </wsdl:input>
135
+ <wsdl:output>
136
+ <soap12:body use="literal"/>
137
+ </wsdl:output>
138
+ </wsdl:operation>
139
+ </wsdl:binding>
140
+ <wsdl:binding name="SeguimientoRecogidaHttpBinding" type="axis2:SeguimientoRecogidaPortType">
141
+ <http:binding verb="POST"/>
142
+ <wsdl:operation name="seguimientoRecogida">
143
+ <http:operation location="SeguimientoRecogida/seguimientoRecogida"/>
144
+ <wsdl:input>
145
+ <mime:content type="text/xml" part="seguimientoRecogida"/>
146
+ </wsdl:input>
147
+ <wsdl:output>
148
+ <mime:content type="text/xml" part="seguimientoRecogida"/>
149
+ </wsdl:output>
150
+ </wsdl:operation>
151
+ </wsdl:binding>
152
+ <wsdl:service name="SeguimientoRecogida">
153
+ <wsdl:port name="SeguimientoRecogidaHttpSoap11Endpoint" binding="axis2:SeguimientoRecogidaSoap11Binding">
154
+ <soap:address location="https://www.correosexpress.com/wpsc/services/SeguimientoRecogida"/>
155
+ </wsdl:port>
156
+ <wsdl:port name="SeguimientoRecogidaHttpSoap12Endpoint" binding="axis2:SeguimientoRecogidaSoap12Binding">
157
+ <soap12:address location="https://www.correosexpress.com/wpsc/services/SeguimientoRecogida"/>
158
+ </wsdl:port>
159
+ <wsdl:port name="SeguimientoRecogidaHttpEndpoint" binding="axis2:SeguimientoRecogidaHttpBinding">
160
+ <http:address location="https://www.correosexpress.com/wpsc/services/SeguimientoRecogida"/>
161
+ </wsdl:port>
162
+ </wsdl:service>
163
+ </wsdl:definitions>
@@ -0,0 +1,71 @@
1
+ require 'active_support/time'
2
+
3
+ module Deliveries
4
+ module Couriers
5
+ module CorreosExpress
6
+ module Pickups
7
+ class Trace
8
+ class FormatResponse
9
+ attr_accessor :response
10
+
11
+ def initialize(response:)
12
+ self.response = response
13
+ end
14
+
15
+ def execute
16
+ tracking_info_params = {}
17
+
18
+ checkpoints = formatted_checkpoints([response[:situaciones]].flatten)
19
+
20
+ tracking_info_params[:status] = checkpoints.last.try(:status)
21
+ tracking_info_params[:checkpoints] = checkpoints
22
+ tracking_info_params[:courier_id] = 'correos_express'
23
+ tracking_info_params[:tracking_code] = response[:recogida]
24
+
25
+ tracking_info_params
26
+ end
27
+
28
+ private
29
+
30
+ def formatted_checkpoints(shipment_statuses)
31
+ checkpoints = []
32
+ shipment_statuses.each do |shipment_status|
33
+ checkpoints << formatted_checkpoint(shipment_status)
34
+ end
35
+ checkpoints.delete_if { |k, _v| k.status == :unknown_status }
36
+ .sort_by(&:tracked_at)
37
+ end
38
+
39
+ def formatted_checkpoint(shipment_status)
40
+ description = shipment_status[:desc_situacion].to_s
41
+ description += " (#{shipment_status[:desc_motivo]})" if shipment_status[:desc_motivo].present?
42
+ Deliveries::Checkpoint.new(
43
+ status: status_code(shipment_status[:desc_situacion]),
44
+ location: nil,
45
+ tracked_at: Time.zone.strptime((shipment_status[:fec_situacion]).to_s, '%d/%m/%Y %H:%M:%S'),
46
+ description: description
47
+ )
48
+ end
49
+
50
+ def status_code(code)
51
+ case code
52
+ when 'PDTE ASIGNAR'
53
+ :registered
54
+ when 'TRANSMITIDA'
55
+ :in_transit
56
+ when 'FALLIDA'
57
+ :delivery_failed
58
+ when 'ANULADA'
59
+ :canceled
60
+ when 'EFECTUADA'
61
+ :delivered
62
+ else
63
+ :unknown_status
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,49 @@
1
+ require 'savon'
2
+
3
+ module Deliveries
4
+ module Couriers
5
+ module CorreosExpress
6
+ module Pickups
7
+ class Trace
8
+ WSDL_LIVE_PATH = File.expand_path('../..', __dir__) + '/correos_express/pickups/trace/correos.wsdl'.freeze
9
+ WSDL_TEST_PATH = File.expand_path('../..', __dir__) + '/correos_express/pickups/trace/correos.test.wsdl'.freeze
10
+
11
+ attr_accessor :tracking_code
12
+
13
+ def initialize(tracking_code:)
14
+ self.tracking_code = tracking_code
15
+ end
16
+
17
+ def execute
18
+ params = {
19
+ 'solicitante' => CorreosExpress.config(:client_code),
20
+ 'dato' => tracking_code,
21
+ 'password' => '',
22
+ 'codCliente' => CorreosExpress.config(:pickup_receiver_code)
23
+ }
24
+
25
+ basic_auth = [
26
+ CorreosExpress.config(:username),
27
+ CorreosExpress.config(:password)
28
+ ]
29
+
30
+ client = Savon.client wsdl: CorreosExpress.live? ? WSDL_LIVE_PATH : WSDL_TEST_PATH,
31
+ basic_auth: basic_auth,
32
+ logger: Deliveries.logger,
33
+ log: Deliveries.debug
34
+
35
+ response = client.call(:seguimiento_recogida, message: params)
36
+
37
+ response_result = response.body[:seguimiento_recogida_response][:return]
38
+ unless response_result && response_result[:recogida].present?
39
+ raise Deliveries::APIError,
40
+ response_result[:mensaje_retorno].to_s.strip
41
+ end
42
+
43
+ response_result
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,80 @@
1
+ module Deliveries
2
+ module Couriers
3
+ module CorreosExpress
4
+ module Shipments
5
+ class Create
6
+ module Defaults
7
+ PARAMS = {
8
+ solicitante: '1',
9
+ canalEntrada: '',
10
+ numEnvio: '',
11
+ ref: '',
12
+ fecha: '', # DDMMYYYY
13
+ codRte: '',
14
+ nomRte: '',
15
+ nifRte: '',
16
+ dirRte: '',
17
+ pobRte: '',
18
+ codPosNacRte: '',
19
+ paisISORte: '',
20
+ codPosIntRte: '',
21
+ contacRte: '',
22
+ telefRte: '',
23
+ emailRte: '',
24
+ codDest: '',
25
+ nomDest: '',
26
+ nifDest: '',
27
+ dirDest: '',
28
+ pobDest: '',
29
+ codPosNacDest: '',
30
+ paisISODest: '',
31
+ codPosIntDest: '',
32
+ contacDest: '',
33
+ telefDest: '',
34
+ emailDest: '',
35
+ contacOtrs: '',
36
+ telefOtrs: '',
37
+ emailOtrs: '',
38
+ observac: '',
39
+ numBultos: '1',
40
+ kilos: '1',
41
+ volumen: '',
42
+ alto: '',
43
+ largo: '',
44
+ ancho: '',
45
+ producto: '63',
46
+ portes: 'P',
47
+ reembolso: '',
48
+ entrSabado: '',
49
+ seguro: '',
50
+ numEnvioVuelta: '',
51
+ listaBultos: [
52
+ {
53
+ alto: '',
54
+ ancho: '',
55
+ codBultoCli: '',
56
+ codUnico: '',
57
+ descripcion: '',
58
+ kilos: '',
59
+ largo: '',
60
+ observaciones: '',
61
+ orden: '1',
62
+ referencia: '',
63
+ volumen: ''
64
+ }
65
+ ],
66
+ codDirecDestino: '',
67
+ password: '',
68
+ listaInformacionAdicional: [
69
+ {
70
+ tipoEtiqueta: '1', # 1 PDF, 2 ZPL
71
+ etiquetaPDF: ''
72
+ }
73
+ ]
74
+ }.freeze
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,99 @@
1
+ module Deliveries
2
+ module Couriers
3
+ module CorreosExpress
4
+ module Shipments
5
+ class Create
6
+ class FormatParams
7
+ attr_accessor :sender, :receiver, :collection_point, :shipment_date,
8
+ :parcels, :reference_code, :remarks
9
+
10
+ NATIONAL_COUNTRY = :es
11
+
12
+ def initialize(sender:, receiver:, collection_point:, parcels:,
13
+ reference_code:, shipment_date:, remarks:)
14
+ self.sender = sender
15
+ self.receiver = receiver
16
+ self.collection_point = collection_point
17
+ self.parcels = parcels
18
+ self.reference_code = reference_code
19
+ self.shipment_date = shipment_date
20
+ self.remarks = remarks
21
+ end
22
+
23
+ def execute
24
+ params = {
25
+ solicitante: CorreosExpress.config(:client_code),
26
+ codRte: CorreosExpress.config(:shipment_sender_code),
27
+ ref: reference_code,
28
+ fecha: format_date(shipment_date),
29
+ nomRte: sender.name,
30
+ dirRte: sender.street,
31
+ pobRte: sender.city,
32
+ paisISORte: sender.country.to_s,
33
+ contacRte: sender.name,
34
+ telefRte: sender.phone,
35
+ emailRte: sender.email,
36
+ nomDest: receiver.name,
37
+ dirDest: receiver.street,
38
+ pobDest: receiver.city,
39
+ paisISODest: receiver.country.to_s,
40
+ contacDest: receiver.name,
41
+ telefDest: receiver.phone,
42
+ emailDest: receiver.email,
43
+ numBultos: parcels.to_s,
44
+ observac: remarks&.truncate(50, omission: '')
45
+ }
46
+
47
+ if collection_point.present?
48
+ params = params.merge(
49
+ codDirecDestino: collection_point.point_id
50
+ )
51
+ end
52
+
53
+ params = if national_country?(sender.country)
54
+ params.merge(codPosNacRte: format_postcode(sender.postcode, sender.country))
55
+ else
56
+ params.merge(codPosIntRte: format_postcode(sender.postcode, sender.country))
57
+ end
58
+
59
+ params = if national_country?(receiver.country)
60
+ params.merge(codPosNacDest: format_postcode(receiver.postcode, receiver.country))
61
+ else
62
+ params.merge(codPosIntDest: format_postcode(receiver.postcode, receiver.country))
63
+ end
64
+
65
+ unless CorreosExpress.test?
66
+ custom_product = CorreosExpress.config("countries.#{receiver.country.to_s.downcase}.product")
67
+ params[:producto] = custom_product if custom_product
68
+ end
69
+
70
+ defaults = Defaults::PARAMS
71
+
72
+ defaults.merge(params).to_json
73
+ end
74
+
75
+ private
76
+
77
+ def format_date(date)
78
+ raise Deliveries::Error if date.blank?
79
+
80
+ date.strftime('%d%m%Y')
81
+ end
82
+
83
+ def format_postcode(postcode, country)
84
+ if country.to_sym.downcase == :pt
85
+ postcode&.split('-')&.first
86
+ else
87
+ postcode
88
+ end
89
+ end
90
+
91
+ def national_country?(country)
92
+ country.to_sym.downcase == NATIONAL_COUNTRY
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end