purolator_ruby 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/purolator_ruby.rb +8 -1
  3. data/lib/purolator_ruby/client.rb +19 -8
  4. data/lib/purolator_ruby/create_shipment_response.rb +15 -0
  5. data/lib/purolator_ruby/environment_credentials.rb +22 -10
  6. data/lib/purolator_ruby/get_documents_payload.rb +28 -0
  7. data/lib/purolator_ruby/get_documents_response.rb +13 -0
  8. data/lib/purolator_ruby/purolator_response.rb +36 -0
  9. data/lib/purolator_ruby/request.rb +45 -0
  10. data/lib/purolator_ruby/validate_city_postal_code_zip_payload.rb +27 -0
  11. data/lib/purolator_ruby/validate_city_postal_code_zip_response.rb +13 -0
  12. data/lib/purolator_ruby/version.rb +1 -1
  13. data/lib/purolator_ruby/wsdl_location.rb +35 -0
  14. data/spec/fixtures/ServiceAvailabilityService.wsdl +1055 -0
  15. data/spec/fixtures/ShippingDocumentsService.wsdl +704 -0
  16. data/spec/fixtures/vcr_cassettes/get_documents.yml +55 -0
  17. data/spec/fixtures/vcr_cassettes/shipping_service_integration.yml +5 -5
  18. data/spec/fixtures/vcr_cassettes/shipping_service_integration_2.yml +60 -0
  19. data/spec/fixtures/vcr_cassettes/validate_address.yml +56 -0
  20. data/spec/fixtures/vcr_cassettes/validate_address_invalid.yml +57 -0
  21. data/spec/purolator_ruby/client_spec.rb +39 -12
  22. data/spec/purolator_ruby/create_shipment_response_spec.rb +57 -0
  23. data/spec/purolator_ruby/get_documents_payload_spec.rb +16 -0
  24. data/spec/purolator_ruby/get_documents_response_spec.rb +40 -0
  25. data/spec/purolator_ruby/integration/create_shipment_spec.rb +53 -0
  26. data/spec/purolator_ruby/integration/get_documents_spec.rb +29 -0
  27. data/spec/purolator_ruby/integration/validate_address_spec.rb +51 -0
  28. data/spec/purolator_ruby/validate_city_postal_code_zip_payload_spec.rb +31 -0
  29. data/spec/purolator_ruby/wsdl_location_spec.rb +37 -0
  30. data/spec/spec_helper.rb +9 -0
  31. metadata +38 -5
  32. data/lib/purolator_ruby/create_shipment_request.rb +0 -55
  33. data/spec/purolator_ruby/create_shipment_request_spec.rb +0 -64
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://f1096de28f3d43d6a27872cc0c3c39a9:10Wl%29dh%7D@devwebservices.purolator.com/EWS/V1/ShippingDocuments/ShippingDocumentsService.asmx
6
+ body:
7
+ encoding: UTF-8
8
+ string: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
9
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://purolator.com/pws/datatypes/v1"
10
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation"
11
+ xmlns:ins1="http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF"><SOAP-ENV:Header><ns1:RequestContext><ns1:Version>1.3</ns1:Version><ns1:Language>en</ns1:Language><ns1:GroupID>xxx</ns1:GroupID><ns1:RequestReference>Rating
12
+ Example</ns1:RequestReference><ns1:UserToken>9999999999</ns1:UserToken></ns1:RequestContext></SOAP-ENV:Header><SOAP-ENV:Body><ns1:GetDocumentsRequest><ns1:DocumentCriterium><ns1:DocumentCriteria><ns1:PIN><ns1:Value>42</ns1:Value></ns1:PIN><ns1:DocumentTypes><ns1:DocumentType>DomesticBillOfLading</ns1:DocumentType></ns1:DocumentTypes></ns1:DocumentCriteria></ns1:DocumentCriterium></ns1:GetDocumentsRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
13
+ headers:
14
+ User-Agent:
15
+ - HTTPClient/1.0 (2.6.0.1, ruby 2.1.3 (2014-09-19))
16
+ Accept:
17
+ - "*/*"
18
+ Date:
19
+ - Fri, 24 Jul 2015 13:46:08 GMT
20
+ Soapaction:
21
+ - '"http://purolator.com/pws/service/v1/GetDocuments"'
22
+ Content-Type:
23
+ - text/xml;charset=UTF-8
24
+ Content-Length:
25
+ - '1073'
26
+ Authorization:
27
+ - Basic ZjEwOTZkZTI4ZjNkNDNkNmEyNzg3MmNjMGMzYzM5YTk6MTBXbClkaH0=
28
+ response:
29
+ status:
30
+ code: 200
31
+ message: OK
32
+ headers:
33
+ Cache-Control:
34
+ - private
35
+ Content-Length:
36
+ - '1021'
37
+ Content-Type:
38
+ - text/xml; charset=utf-8
39
+ Server:
40
+ - Microsoft-IIS/7.5
41
+ X-Powered-By:
42
+ - ASP.NET
43
+ Date:
44
+ - Fri, 24 Jul 2015 13:46:10 GMT
45
+ body:
46
+ encoding: UTF-8
47
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ResponseContext
48
+ xmlns:h="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><h:ResponseReference>Rating
49
+ Example</h:ResponseReference></h:ResponseContext></s:Header><s:Body><GetDocumentsResponse
50
+ xmlns="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ResponseInformation><Errors
51
+ i:nil="true"/><InformationalMessages i:nil="true"/></ResponseInformation><Documents><Document><PIN><Value>42</Value></PIN><DocumentDetails><DocumentDetail><DocumentType>DomesticBillOfLading</DocumentType><Description>Description
52
+ for DomesticBillOfLading</Description><DocumentStatus>Completed</DocumentStatus><URL>https://eshiponline.purolator.com/ShipOnline/shipment/getLabel.ashx?TEMP_TYPE=STUB&amp;REPORT_NAME=GenericDummyReport.pdf&amp;REPORT_NAME=GenericDummyReport.pdf</URL></DocumentDetail></DocumentDetails></Document></Documents></GetDocumentsResponse></s:Body></s:Envelope>
53
+ http_version:
54
+ recorded_at: Fri, 24 Jul 2015 13:46:10 GMT
55
+ recorded_with: VCR 2.9.3
@@ -12,7 +12,7 @@ http_interactions:
12
12
  Example</ns1:RequestReference><ns1:UserToken>9999999999</ns1:UserToken></ns1:RequestContext></SOAP-ENV:Header><SOAP-ENV:Body><ns1:CreateShipmentRequest><ns1:Shipment><ns1:SenderInformation><ns1:Address><ns1:Name>Thehydropothecary</ns1:Name><ns1:StreetNumber>120</ns1:StreetNumber><ns1:StreetName>Chemin
13
13
  de la Rive</ns1:StreetName><ns1:City>Gatineau</ns1:City><ns1:Province>QC</ns1:Province><ns1:Country>CA</ns1:Country><ns1:PostalCode>J8M1V2</ns1:PostalCode><ns1:PhoneNumber><ns1:CountryCode>1</ns1:CountryCode><ns1:AreaCode>905</ns1:AreaCode><ns1:Phone>5555555</ns1:Phone></ns1:PhoneNumber></ns1:Address></ns1:SenderInformation><ns1:ReceiverInformation><ns1:Address><ns1:Name>Fake
14
14
  Name</ns1:Name><ns1:StreetNumber>5</ns1:StreetNumber><ns1:StreetName>Douglas
15
- Road</ns1:StreetName><ns1:City>Burnaby</ns1:City><ns1:Province>BC</ns1:Province><ns1:Country>CA</ns1:Country><ns1:PostalCode>V5C1A1</ns1:PostalCode><ns1:PhoneNumber><ns1:CountryCode>1</ns1:CountryCode><ns1:AreaCode>604</ns1:AreaCode><ns1:Phone>2982181</ns1:Phone></ns1:PhoneNumber></ns1:Address></ns1:ReceiverInformation><ns1:ShipmentDate>2015-07-22</ns1:ShipmentDate><ns1:PackageInformation><ns1:ServiceID>PurolatorExpress</ns1:ServiceID><ns1:TotalWeight><ns1:Value>10</ns1:Value><ns1:WeightUnit>lb</ns1:WeightUnit></ns1:TotalWeight><ns1:TotalPieces>1</ns1:TotalPieces><ns1:OptionsInformation><ns1:Options><ns1:OptionIDValuePair><ns1:ID>ResidentialSignatureDomestic</ns1:ID><ns1:Value>true</ns1:Value></ns1:OptionIDValuePair></ns1:Options></ns1:OptionsInformation></ns1:PackageInformation><ns1:PaymentInformation><ns1:PaymentType>Sender</ns1:PaymentType><ns1:RegisteredAccountNumber>9999999999</ns1:RegisteredAccountNumber><ns1:BillingAccountNumber>9999999999</ns1:BillingAccountNumber></ns1:PaymentInformation><ns1:PickupInformation><ns1:PickupType>DropOff</ns1:PickupType></ns1:PickupInformation><ns1:TrackingReferenceInformation><ns1:Reference1>ref
15
+ Road</ns1:StreetName><ns1:City>Burnaby</ns1:City><ns1:Province>BC</ns1:Province><ns1:Country>CA</ns1:Country><ns1:PostalCode>V5C1A1</ns1:PostalCode><ns1:PhoneNumber><ns1:CountryCode>1</ns1:CountryCode><ns1:AreaCode>604</ns1:AreaCode><ns1:Phone>2982181</ns1:Phone></ns1:PhoneNumber></ns1:Address></ns1:ReceiverInformation><ns1:ShipmentDate>2015-07-23</ns1:ShipmentDate><ns1:PackageInformation><ns1:ServiceID>PurolatorExpress</ns1:ServiceID><ns1:TotalWeight><ns1:Value>10</ns1:Value><ns1:WeightUnit>lb</ns1:WeightUnit></ns1:TotalWeight><ns1:TotalPieces>1</ns1:TotalPieces><ns1:OptionsInformation><ns1:Options><ns1:OptionIDValuePair><ns1:ID>ResidentialSignatureDomestic</ns1:ID><ns1:Value>true</ns1:Value></ns1:OptionIDValuePair></ns1:Options></ns1:OptionsInformation></ns1:PackageInformation><ns1:PaymentInformation><ns1:PaymentType>Sender</ns1:PaymentType><ns1:RegisteredAccountNumber>9999999999</ns1:RegisteredAccountNumber><ns1:BillingAccountNumber>9999999999</ns1:BillingAccountNumber></ns1:PaymentInformation><ns1:PickupInformation><ns1:PickupType>DropOff</ns1:PickupType></ns1:PickupInformation><ns1:TrackingReferenceInformation><ns1:Reference1>ref
16
16
  45</ns1:Reference1></ns1:TrackingReferenceInformation></ns1:Shipment><ns1:PrinterType>Thermal</ns1:PrinterType></ns1:CreateShipmentRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
17
17
  headers:
18
18
  User-Agent:
@@ -20,7 +20,7 @@ http_interactions:
20
20
  Accept:
21
21
  - "*/*"
22
22
  Date:
23
- - Wed, 22 Jul 2015 11:35:14 GMT
23
+ - Thu, 23 Jul 2015 12:26:32 GMT
24
24
  Soapaction:
25
25
  - '"http://purolator.com/pws/service/v1/CreateShipment"'
26
26
  Content-Type:
@@ -45,14 +45,14 @@ http_interactions:
45
45
  X-Powered-By:
46
46
  - ASP.NET
47
47
  Date:
48
- - Wed, 22 Jul 2015 11:35:14 GMT
48
+ - Thu, 23 Jul 2015 12:26:33 GMT
49
49
  body:
50
50
  encoding: UTF-8
51
51
  string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ResponseContext
52
52
  xmlns:h="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><h:ResponseReference>Rating
53
53
  Example</h:ResponseReference></h:ResponseContext></s:Header><s:Body><CreateShipmentResponse
54
54
  xmlns="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ResponseInformation><Errors/><InformationalMessages
55
- i:nil="true"/></ResponseInformation><ShipmentPIN><Value>329018601172</Value></ShipmentPIN><PiecePINs><PIN><Value>329018601172</Value></PIN></PiecePINs><ReturnShipmentPINs/><ExpressChequePIN><Value/></ExpressChequePIN></CreateShipmentResponse></s:Body></s:Envelope>
55
+ i:nil="true"/></ResponseInformation><ShipmentPIN><Value>329018602238</Value></ShipmentPIN><PiecePINs><PIN><Value>329018602238</Value></PIN></PiecePINs><ReturnShipmentPINs/><ExpressChequePIN><Value/></ExpressChequePIN></CreateShipmentResponse></s:Body></s:Envelope>
56
56
  http_version:
57
- recorded_at: Wed, 22 Jul 2015 11:35:15 GMT
57
+ recorded_at: Thu, 23 Jul 2015 12:26:33 GMT
58
58
  recorded_with: VCR 2.9.3
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://f1096de28f3d43d6a27872cc0c3c39a9:10Wl%29dh%7D@devwebservices.purolator.com/EWS/V1/Shipping/ShippingService.asmx
6
+ body:
7
+ encoding: UTF-8
8
+ string: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
9
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://purolator.com/pws/datatypes/v1"
10
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation"
11
+ xmlns:ins1="http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF"><SOAP-ENV:Header><ns1:RequestContext><ns1:Version>1.5</ns1:Version><ns1:Language>en</ns1:Language><ns1:GroupID>xxx</ns1:GroupID><ns1:RequestReference>Rating
12
+ Example</ns1:RequestReference><ns1:UserToken>9999999999</ns1:UserToken></ns1:RequestContext></SOAP-ENV:Header><SOAP-ENV:Body><ns1:CreateShipmentRequest><ns1:Shipment><ns1:SenderInformation><ns1:Address><ns1:Name>Thehydropothecary</ns1:Name><ns1:StreetNumber>120</ns1:StreetNumber><ns1:StreetName>Chemin
13
+ de la Rive</ns1:StreetName><ns1:City>Gatineau</ns1:City><ns1:Province>QC</ns1:Province><ns1:Country>CA</ns1:Country><ns1:PostalCode>J8M1V2</ns1:PostalCode><ns1:PhoneNumber><ns1:CountryCode>1</ns1:CountryCode><ns1:AreaCode>905</ns1:AreaCode><ns1:Phone>5555555</ns1:Phone></ns1:PhoneNumber></ns1:Address></ns1:SenderInformation><ns1:ReceiverInformation><ns1:Address><ns1:Name>Fake
14
+ Name</ns1:Name><ns1:StreetNumber>5</ns1:StreetNumber><ns1:StreetName>Douglas
15
+ Road</ns1:StreetName><ns1:City>Burnaby</ns1:City><ns1:Province>BC</ns1:Province><ns1:Country>CA</ns1:Country><ns1:PostalCode>V5C1A1</ns1:PostalCode><ns1:PhoneNumber><ns1:CountryCode>1</ns1:CountryCode><ns1:AreaCode>604</ns1:AreaCode><ns1:Phone>2982181</ns1:Phone></ns1:PhoneNumber></ns1:Address></ns1:ReceiverInformation><ns1:ShipmentDate>2014-01-01</ns1:ShipmentDate><ns1:PackageInformation><ns1:ServiceID>PurolatorExpress</ns1:ServiceID><ns1:TotalWeight><ns1:Value>10</ns1:Value><ns1:WeightUnit>lb</ns1:WeightUnit></ns1:TotalWeight><ns1:TotalPieces>1</ns1:TotalPieces><ns1:OptionsInformation><ns1:Options><ns1:OptionIDValuePair><ns1:ID>ResidentialSignatureDomestic</ns1:ID><ns1:Value>true</ns1:Value></ns1:OptionIDValuePair></ns1:Options></ns1:OptionsInformation></ns1:PackageInformation><ns1:PaymentInformation><ns1:PaymentType>Sender</ns1:PaymentType><ns1:RegisteredAccountNumber>9999999999</ns1:RegisteredAccountNumber><ns1:BillingAccountNumber>9999999999</ns1:BillingAccountNumber></ns1:PaymentInformation><ns1:PickupInformation><ns1:PickupType>DropOff</ns1:PickupType></ns1:PickupInformation><ns1:TrackingReferenceInformation><ns1:Reference1>12</ns1:Reference1></ns1:TrackingReferenceInformation></ns1:Shipment><ns1:PrinterType>Thermal</ns1:PrinterType></ns1:CreateShipmentRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
16
+ headers:
17
+ User-Agent:
18
+ - HTTPClient/1.0 (2.6.0.1, ruby 2.1.3 (2014-09-19))
19
+ Accept:
20
+ - "*/*"
21
+ Date:
22
+ - Thu, 23 Jul 2015 12:45:38 GMT
23
+ Soapaction:
24
+ - '"http://purolator.com/pws/service/v1/CreateShipment"'
25
+ Content-Type:
26
+ - text/xml;charset=UTF-8
27
+ Content-Length:
28
+ - '2712'
29
+ Authorization:
30
+ - Basic ZjEwOTZkZTI4ZjNkNDNkNmEyNzg3MmNjMGMzYzM5YTk6MTBXbClkaH0=
31
+ response:
32
+ status:
33
+ code: 200
34
+ message: OK
35
+ headers:
36
+ Cache-Control:
37
+ - private
38
+ Content-Length:
39
+ - '891'
40
+ Content-Type:
41
+ - text/xml; charset=utf-8
42
+ Server:
43
+ - Microsoft-IIS/7.5
44
+ X-Powered-By:
45
+ - ASP.NET
46
+ Date:
47
+ - Thu, 23 Jul 2015 12:45:39 GMT
48
+ body:
49
+ encoding: UTF-8
50
+ string: '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ResponseContext
51
+ xmlns:h="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><h:ResponseReference>Rating
52
+ Example</h:ResponseReference></h:ResponseContext></s:Header><s:Body><CreateShipmentResponse
53
+ xmlns="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ResponseInformation><Errors><Error><Code>1100759</Code><Description>Invalid
54
+ Shipment Date: Date must be between Thursday, July 23, 2015 and Sunday, August
55
+ 2, 2015.</Description><AdditionalInformation>Shipping Error</AdditionalInformation></Error></Errors><InformationalMessages
56
+ i:nil="true"/></ResponseInformation><ShipmentPIN i:nil="true"/><PiecePINs
57
+ i:nil="true"/><ReturnShipmentPINs i:nil="true"/><ExpressChequePIN i:nil="true"/></CreateShipmentResponse></s:Body></s:Envelope>'
58
+ http_version:
59
+ recorded_at: Thu, 23 Jul 2015 12:45:39 GMT
60
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://f1096de28f3d43d6a27872cc0c3c39a9:10Wl%29dh%7D@devwebservices.purolator.com/EWS/V1/ServiceAvailability/ServiceAvailabilityService.asmx
6
+ body:
7
+ encoding: UTF-8
8
+ string: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
9
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://purolator.com/pws/datatypes/v1"
10
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation"
11
+ xmlns:ins1="http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF"><SOAP-ENV:Header><ns1:RequestContext><ns1:Version>1.3</ns1:Version><ns1:Language>en</ns1:Language><ns1:GroupID>xxx</ns1:GroupID><ns1:RequestReference>Rating
12
+ Example</ns1:RequestReference><ns1:UserToken>9999999999</ns1:UserToken></ns1:RequestContext></SOAP-ENV:Header><SOAP-ENV:Body><ns1:ValidateCityPostalCodeZipRequest><ns1:Addresses><ns1:ShortAddress><ns1:City>Ottawa</ns1:City><ns1:Province>ON</ns1:Province><ns1:Country>CA</ns1:Country><ns1:PostalCode>K1Y
13
+ 0M5</ns1:PostalCode></ns1:ShortAddress></ns1:Addresses></ns1:ValidateCityPostalCodeZipRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
14
+ headers:
15
+ User-Agent:
16
+ - HTTPClient/1.0 (2.6.0.1, ruby 2.1.3 (2014-09-19))
17
+ Accept:
18
+ - "*/*"
19
+ Date:
20
+ - Fri, 24 Jul 2015 13:06:52 GMT
21
+ Soapaction:
22
+ - '"http://purolator.com/pws/service/v1/ValidateCityPostalCodeZip"'
23
+ Content-Type:
24
+ - text/xml;charset=UTF-8
25
+ Content-Length:
26
+ - '1062'
27
+ Authorization:
28
+ - Basic ZjEwOTZkZTI4ZjNkNDNkNmEyNzg3MmNjMGMzYzM5YTk6MTBXbClkaH0=
29
+ response:
30
+ status:
31
+ code: 200
32
+ message: OK
33
+ headers:
34
+ Cache-Control:
35
+ - private
36
+ Content-Length:
37
+ - '849'
38
+ Content-Type:
39
+ - text/xml; charset=utf-8
40
+ Server:
41
+ - Microsoft-IIS/7.5
42
+ X-Powered-By:
43
+ - ASP.NET
44
+ Date:
45
+ - Fri, 24 Jul 2015 13:06:59 GMT
46
+ body:
47
+ encoding: UTF-8
48
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ResponseContext
49
+ xmlns:h="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><h:ResponseReference>Rating
50
+ Example</h:ResponseReference></h:ResponseContext></s:Header><s:Body><ValidateCityPostalCodeZipResponse
51
+ xmlns="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ResponseInformation><Errors/><InformationalMessages
52
+ i:nil="true"/></ResponseInformation><SuggestedAddresses><SuggestedAddress><Address><City>Ottawa</City><Province>ON</Province><Country>CA</Country><PostalCode>K1Y0M5</PostalCode></Address><ResponseInformation><Errors/><InformationalMessages
53
+ i:nil="true"/></ResponseInformation></SuggestedAddress></SuggestedAddresses></ValidateCityPostalCodeZipResponse></s:Body></s:Envelope>
54
+ http_version:
55
+ recorded_at: Fri, 24 Jul 2015 13:06:59 GMT
56
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://f1096de28f3d43d6a27872cc0c3c39a9:10Wl%29dh%7D@devwebservices.purolator.com/EWS/V1/ServiceAvailability/ServiceAvailabilityService.asmx
6
+ body:
7
+ encoding: UTF-8
8
+ string: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
9
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://purolator.com/pws/datatypes/v1"
10
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation"
11
+ xmlns:ins1="http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF"><SOAP-ENV:Header><ns1:RequestContext><ns1:Version>1.3</ns1:Version><ns1:Language>en</ns1:Language><ns1:GroupID>xxx</ns1:GroupID><ns1:RequestReference>Rating
12
+ Example</ns1:RequestReference><ns1:UserToken>9999999999</ns1:UserToken></ns1:RequestContext></SOAP-ENV:Header><SOAP-ENV:Body><ns1:ValidateCityPostalCodeZipRequest><ns1:Addresses><ns1:ShortAddress><ns1:City>Berlin</ns1:City><ns1:Province>ON</ns1:Province><ns1:Country>CA</ns1:Country><ns1:PostalCode>1</ns1:PostalCode></ns1:ShortAddress></ns1:Addresses></ns1:ValidateCityPostalCodeZipRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
13
+ headers:
14
+ User-Agent:
15
+ - HTTPClient/1.0 (2.6.0.1, ruby 2.1.3 (2014-09-19))
16
+ Accept:
17
+ - "*/*"
18
+ Date:
19
+ - Fri, 24 Jul 2015 13:19:02 GMT
20
+ Soapaction:
21
+ - '"http://purolator.com/pws/service/v1/ValidateCityPostalCodeZip"'
22
+ Content-Type:
23
+ - text/xml;charset=UTF-8
24
+ Content-Length:
25
+ - '1056'
26
+ Authorization:
27
+ - Basic ZjEwOTZkZTI4ZjNkNDNkNmEyNzg3MmNjMGMzYzM5YTk6MTBXbClkaH0=
28
+ response:
29
+ status:
30
+ code: 200
31
+ message: OK
32
+ headers:
33
+ Cache-Control:
34
+ - private
35
+ Content-Length:
36
+ - '1196'
37
+ Content-Type:
38
+ - text/xml; charset=utf-8
39
+ Server:
40
+ - Microsoft-IIS/7.5
41
+ X-Powered-By:
42
+ - ASP.NET
43
+ Date:
44
+ - Fri, 24 Jul 2015 13:19:04 GMT
45
+ body:
46
+ encoding: UTF-8
47
+ string: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ResponseContext
48
+ xmlns:h="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><h:ResponseReference>Rating
49
+ Example</h:ResponseReference></h:ResponseContext></s:Header><s:Body><ValidateCityPostalCodeZipResponse
50
+ xmlns="http://purolator.com/pws/datatypes/v1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ResponseInformation><Errors><Error><Code>1001144</Code><Description>One
51
+ or more addresses are invalid or suggestions are supplied</Description><AdditionalInformation>Shipping
52
+ Error</AdditionalInformation></Error></Errors><InformationalMessages i:nil="true"/></ResponseInformation><SuggestedAddresses><SuggestedAddress><Address><City>Berlin</City><Province>ON</Province><Country>CA</Country><PostalCode>1</PostalCode></Address><ResponseInformation><Errors><Error><Code>1141</Code><Description>Postal
53
+ / Zip code 1 code is not valid for Canada or U.S.</Description><AdditionalInformation
54
+ i:nil="true"/></Error></Errors><InformationalMessages i:nil="true"/></ResponseInformation></SuggestedAddress></SuggestedAddresses></ValidateCityPostalCodeZipResponse></s:Body></s:Envelope>
55
+ http_version:
56
+ recorded_at: Fri, 24 Jul 2015 13:19:04 GMT
57
+ recorded_with: VCR 2.9.3
@@ -11,6 +11,14 @@ describe PurolatorRuby::Client do
11
11
  {'Request' => 'Header'}
12
12
  end
13
13
 
14
+ def soap_header_v13
15
+ soap_header
16
+ end
17
+
18
+ def soap_header_v15
19
+ soap_header
20
+ end
21
+
14
22
  def basic_auth
15
23
  ['FOO', 'BAR']
16
24
  end
@@ -26,23 +34,42 @@ describe PurolatorRuby::Client do
26
34
 
27
35
  subject { build_client }
28
36
 
29
- it "creates new Savon client with the parameters from env" do
30
- expect(Savon).to receive(:client) do |attributes|
31
- expect(attributes).to be_a(Hash)
32
- end
33
-
34
- build_client
35
- end
36
-
37
37
  it "uses account_number and billing_number from credentials" do
38
38
  expect(subject.account_number).to eq(1)
39
39
  expect(subject.billing_number).to eq(2)
40
40
  end
41
41
 
42
- it "has a factory method for a shipment request" do
43
- req = subject.build_shipment({})
44
- expect(req).to be_a(PurolatorRuby::CreateShipmentRequest)
45
- expect(req.client).to eq(subject)
42
+ context "call method" do
43
+ let(:resp) { double(body: {}) }
44
+ let(:savon) { double(call: resp) }
45
+
46
+ before do
47
+ expect(Savon).to receive(:client).and_return(savon)
48
+
49
+ expect(PurolatorRuby::CreateShipmentPayload).to receive(:new)
50
+ expect(PurolatorRuby::CreateShipmentResponse).to receive(:new)
51
+ end
52
+
53
+ it "has a call method which creates request and response objects" do
54
+ subject.call(:create_shipment, {shipping_date: Date.today})
55
+ end
56
+
57
+ it "has a create_shipment method" do
58
+ subject.create_shipment shipping_date: Date.today
59
+ end
60
+
61
+ end
62
+ context "wsdl" do
63
+
64
+ it "instantiates Savon with WsdlLocation" do
65
+ allow(PurolatorRuby::WsdlLocation).to receive(:new).and_return(double(location_for: '42', soap_header_for: {}))
66
+
67
+ expect(Savon).to receive(:client) do |params|
68
+ expect(params[:wsdl]).to eq('42')
69
+ end.and_return(double(call: double(body: {})))
70
+
71
+ subject.call(:create_shipment, {shipping_date: Date.today})
72
+ end
46
73
  end
47
74
 
48
75
  def build_client
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe PurolatorRuby::CreateShipmentResponse do
4
+
5
+ subject { described_class.new(response) }
6
+
7
+ context "success" do
8
+ let(:response) do
9
+ {
10
+ :create_shipment_response => {
11
+ :response_information => {
12
+ :errors => nil,
13
+ :informational_messages => nil
14
+ },
15
+ :shipment_pin => {
16
+ :value => "329018602212"
17
+ },
18
+ :piece_pi_ns => {
19
+ :pin => {
20
+ :value => "329018602212"
21
+ }
22
+ },
23
+ :return_shipment_pi_ns => nil,
24
+ :express_cheque_pin => {
25
+ :value => nil
26
+ },
27
+ :@xmlns => "http://purolator.com/pws/datatypes/v1",
28
+ :"@xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance"
29
+ }
30
+ }
31
+ end
32
+
33
+ it "has status success" do
34
+ expect(subject.status).to eq(:ok)
35
+ end
36
+
37
+ it "has shipment_pin" do
38
+ expect(subject.shipment_pin).to eq("329018602212")
39
+ end
40
+
41
+ end
42
+
43
+ context "failure" do
44
+ let(:response) do
45
+ {:create_shipment_response=>{:response_information=>{:errors=>{:error=>{:code=>"1100759", :description=>"Invalid Shipment Date: Date must be between Thursday, July 23, 2015 and Sunday, August 2, 2015.", :additional_information=>"Shipping Error"}}, :informational_messages=>nil}, :shipment_pin=>nil, :piece_pi_ns=>nil, :return_shipment_pi_ns=>nil, :express_cheque_pin=>nil, :@xmlns=>"http://purolator.com/pws/datatypes/v1", :"@xmlns:i"=>"http://www.w3.org/2001/XMLSchema-instance"}}
46
+ end
47
+
48
+ it "has status error" do
49
+ expect(subject.status).to eq(:error)
50
+ end
51
+
52
+ it "has errors" do
53
+ expect(subject.errors).to eq(['Invalid Shipment Date: Date must be between Thursday, July 23, 2015 and Sunday, August 2, 2015.'])
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe PurolatorRuby::GetDocumentsPayload do
4
+
5
+ let(:pin) { 42 }
6
+ let(:document_type) { 'DomesticBillOfLading' }
7
+
8
+ subject do
9
+ described_class.new(pin: pin, document_type: document_type)
10
+ end
11
+
12
+ it "creates a valid SOAP payload" do
13
+ expect(subject.to_h).to eq({"DocumentCriterium"=>{"DocumentCriteria"=>{"PIN"=>{"Value"=>42}, "DocumentTypes"=>{"DocumentType"=>"DomesticBillOfLading"}}}})
14
+ end
15
+
16
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe PurolatorRuby::GetDocumentsResponse do
4
+ let(:url) { 'https://eshiponline.purolator.com/ShipOnline/shipment/getLabel.ashx?TEMP_TYPE=STUB&REPORT_NAME=GenericDummyReport.pdf&REPORT_NAME=GenericDummyReport.pdf' }
5
+ let(:raw_response) do
6
+ {
7
+ :get_documents_response => {
8
+ :response_information => {
9
+ :errors => nil,
10
+ :informational_messages => nil
11
+ },
12
+ :documents => {
13
+ :document => {
14
+ :pin => {
15
+ :value => "42"
16
+ },
17
+ :document_details => {
18
+ :document_detail => {
19
+ :document_type => "DomesticBillOfLading",
20
+ :description => "Description for DomesticBillOfLading",
21
+ :document_status => "Completed",
22
+ :url => url
23
+ }
24
+ }
25
+ }
26
+ },
27
+ :@xmlns => "http://purolator.com/pws/datatypes/v1",
28
+ :"@xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance"
29
+ }
30
+ }
31
+
32
+ end
33
+
34
+ subject { described_class.new(raw_response) }
35
+
36
+ it "can extract url" do
37
+ expect(subject.url).to eq(url)
38
+ end
39
+
40
+ end