Code Monkey home page Code Monkey logo

subscriptionapi's Introduction

Subscription REST API

A simple subscription RESTful API with in which users can subscribe to a single/multiple websites and recieve emails whenever a post is published.

This API goal is to demonstrate the following Laravel concepts:

  • Structuring routes.
  • Events & Listeners.
  • Queues.
  • Commands.
  • Handling calls and formatting responses.

Install

git clone https://github.com/OussamaMater/SubscriptionAPI.git
cd SubscriptionAPI
composer install --ignore-platform-reqs
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan db:seed

Run the app

php artisan serve

Endpoints

The REST API to the example app is described below.

Create a Website

Request

POST /api/v1/websites

curl --request POST \
--url http://127.0.0.1:8000/api/v1/websites \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--form name=something

Response

{
"status": "created",
"message": "website was created."
}

Create a Client

Request

POST /api/v1/clients

curl --request POST \
--url http://127.0.0.1:8000/api/v1/clients \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--form [email protected] \
--form password=password \
--form name=something

Response

{
"status": "created",
"error": "client was created."
}

Login a Client

Request

POST /api/v1/clients/login

curl --request POST \
--url http://127.0.0.1:8000/api/v1/clients/login \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--form [email protected] \
--form password=password

Response

{
"status": "success",
"message": "2|eZaccuhspPrJTwK2iCB2xNj0Dj9qL3FH3rGoZLlD"
}

Logout a Client

Request

POST /api/v1/clients/logout

curl --request POST \
--url http://127.0.0.1:8000/api/v1/clients/logout \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 1|rWtxn3D5ERH3c7zU2Ai17fmJ9pWjhOwupB2b18Fw' \
--header 'Content-Type: multipart/form-data' \

Response

{
"status": "success",
"message": "2|eZaccuhspPrJTwK2iCB2xNj0Dj9qL3FH3rGoZLlD"
}

Create a Website Post

Request

POST /api/v1/posts

curl --request POST \
--url http://127.0.0.1:8000/api/v1/posts \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--form 'title=a title' \
--form 'description=some text' \
--form website=10

Response

{
"status": "success",
"message": "user logged out."
}

Subscribe to a Website

Request

POST /api/v1/clients/subscribe

curl --request POST \
--url http://127.0.0.1:8000/api/v1/clients/subscribe \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 1|rWtxn3D5ERH3c7zU2Ai17fmJ9pWjhOwupB2b18Fw' \
--header 'Content-Type: multipart/form-data' \
--form website=10

Response

{
"status": "created",
"error": "client subscribed to website."
}

subscriptionapi's People

Contributors

oussamamater avatar

Stargazers

Rani Zouaoui 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.