DEV Community

Cover image for Getting package delivery status from docker at opt.nc
adriens
adriens

Posted on • Updated on

Getting package delivery status from docker at opt.nc

Context

Being able to get package delivery status is possible, and there is a dedicated Docker image fo this. This post explain how to do this within a very few lines of code so you can integrate that into your ERP, develop mobile app or simply develop any integration.

Code snippet

sudo docker run --net=host -d -p 8080:8080 rastadidi/colisnc-api:latest
sudo apt-get install httpie jq boxes toilet
http http://localhost:8080/colis/CA107308006SI/latest
http http://localhost:8080/colis/CA107308006SI

# Shell: now the fun part
cat << EOF > colis.sh
#!/bin/bash          
curl -sS http://localhost:8080/colis/\$1/latest | jq -r '.status' | boxes -d boy | toilet --gay -f term
EOF

chmod u+x colis.sh
./colis.sh CA107308006SI
cowsay -f tux That\'s all folks
Enter fullscreen mode Exit fullscreen mode

Outputs

Finally json output for the latest known status of the delivery process:

{
    "country": {
        "code": "NC",
        "iso": "NCL",
        "name": "nouvelle-caledonie"
    },
    "date": "2019-09-09T09:41:13",
    "informations": "",
    "itemId": "CA107308006SI",
    "localisation": "NOUMEA CDC",
    "localization": {
        "longName": "Office des Postes - Agence Principale",
        "name": "NOUMEA CDC",
        "url": "https://goo.gl/maps/verSQbb6tQaqzKq87"
    },
    "pays": "NOUVELLE-CALÉDONIE",
    "rawDateHeure": "09/09/2019 09:41:13",
    "status": "COLIS_LIVRE",
    "typeEvenement": "Votre courrier/colis a été livré"
}
Enter fullscreen mode Exit fullscreen mode

Resources

Full demo

Find below the full video demo, from scratch, with system install thanks to Vagrant:

Top comments (0)