Giter Club home page Giter Club logo

takeaway's Introduction

Takeaway

Code challenge for Takeaway

Steps to run:

  1. Copy the .env file provided to the main directory
  2. Run docker-compose up to start up the containers
  3. Run docker exec web composer install
  4. Run docker exec web php artisan migrate
  5. The service should be running at https://ivailotakeaway.localtunnel.me/

Sending message

Do a POST request to https://ivailotakeaway.localtunnel.me/send/{type} where {type} is either shipped or review with such body:

{
  "to": "+359897981948",
  "restaurant": "Subway",
  "time": "21:35"
}

How and what

The microservice runs on 3 containers - Db, apache and tunnel.

The tunnel is needed for convenient local testing and is required to update the message status since it's done via a remote callback. The tunnel container tends to crash and restart at random periods of time, this is a known bug and the developer is unable to fix it. I've noticed that it also crashes if your firewall is running, so bear that in mind. Might not be able to receive callbacks if firewall is running.

The parameters needed for the notification are minimal - restaurant name, hour of delivery (if applicable) and number of the recipient.

The templates are currently stored in the config file, but would be better off in a db table when the service grows so they can be managed by non-programmers as well.

Twilio provides their own php SDK which I used. Not sure if you wanted to see me making an http call.

Tests

I've added some tests which check if the homepage gets http 200, if the sms is sent and the record is inserted in the logs db. To run them execute vendor/bin/phpunit from the docker console docker exec -it web /bin/bash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.