DEV Community

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

Posted on • Edited on

2 3

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:

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay