Coder Social home page Coder Social logo

safeboda_promotion's Introduction

License

SafeBoda Promotion Module

The Application was built to generate promotion codes for user during rides. The promotion codes are set to be a percentage of the ride cost. The percentage is returned as a value in the api/promo endpoint. This is to be used for calculations with the value ride cost value.

This module has not calculated ride cost, this was assumed to be outside the scope of the assignment but the structure can be modified to calculate the same.

Installation

To install the node dependancies run

npm install

then run

composer install

Finally generate the tables and seed data to the database with

php artisan migrate --seed

You will need to set up the .env file, this can be done by copying the .env.example file and editing the variables based on your set up

You will need to add two additional fields for the application to function as expected.

JWT_SECRET=puSxYea6Glx4ZuJnnfe3Mii9DHhyr871B5b43lPJ4bQDf9tOlJLPijJreA58SPPd
GOOGLE_API=

The Google API can be acquired by following the instructions shared at https://developers.google.com/maps/documentation/directions/overview

If the value is not updated, there will be no data for the route field on the api/promo endpoint.

Endpoints

  1. api/auth/login
  2. api/promocode/all
  3. api/promocode/active
  4. api/promo
  5. api/promocode/deactivate
  6. api/promolocation/delete

A postman collection and env has been added for purposes of testing the api

Code Generation

Using a schedule command, promo codes are generated periodically. This can be triggered by running. This will need to be set as a cron job to periodically generate promocodes.

php artisan  promocode:generate

For the specifc command or

php artisan schedule:run

to run all schedules commands in the system.

While testing the api/promo endpoint, you will need to select an existing promocode, this can be done after triggering the code generation and selecting an active promocode from api/promocode/all, otherwise the endpoint will return an error message.

Testing

Set up the testing env by running

php artisan migrate --seed --env=testing

then

php artisan test

safeboda_promotion's People

Contributors

rodneyonyi avatar

Watchers

 avatar

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.