erisitohang / fm-api

Friends Management API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Friends Management API

Requirements

  • PHP >= 7.1.0
  • Database MySQL
  • Composer
  • Webserver Nngix/Apache

OR

  • Docker

Getting Started

Follow the below procedures for installing Application

Clone this repo

$ git clone git@github.com:erisitohang/fm-api.git fm-api
$ cd fm-api

Run Server (docker)

$ docker-compose up --build -d

Run Composer

Go in to php server

$ docker exec -it fm-api_php_1 bash

install composer

$ composer install

Environment Configuration

$ cp .env.example .env

After this file copy, update the attributes in .env to match your environment, database

Run migration

$ php artisan migrate

Seed the Database

$ php artisan db:seed

Running the tests

$ ./vendor/bin/phpunit

API server url

http://localhost

List of routes

+------+------------------+-----------------+-------------------------------------------------+---------+------------+
| Verb | Path             | NamedRoute      | Controller                                      | Action  | Middleware |
+------+------------------+-----------------+-------------------------------------------------+---------+------------+
| GET  | /                |                 | None                                            | Closure |            |
| POST | /user            | user            | App\Http\Controllers\Api\UserController         | store   |            |
| POST | /friend          | friend          | App\Http\Controllers\Api\RelationshipController | store   |            |
| POST | /friend/mine     | friend.mine     | App\Http\Controllers\Api\RelationshipController | mine    |            |
| POST | /friend/common   | friend.common   | App\Http\Controllers\Api\RelationshipController | common  |            |
| POST | /subscribe       | subscribe.store | App\Http\Controllers\Api\SubscriberController   | store   |            |
| POST | /subscribe/block | subscribe.block | App\Http\Controllers\Api\SubscriberController   | block   |            |
| POST | /feed            | feed.index      | App\Http\Controllers\Api\FeedController         | index   |            |
+------+------------------+-----------------+-------------------------------------------------+---------+------------+

Usage

Create User

POST /user

POST

{
	"email": "test1@test.com",
	"name": "John Doe"
}

Response

{
    "email": "test1@test.com",
    "name": "John Doe",
    "id": 1
}

Friend connection between two email addresses(1)

POST /friend

POST

{
  "friends":
    [
      "test1@test.com",
      "test2@test.com"
    ]
}

Response

{
  "success": true
}

Retrieve the friends list for an email address (2)

POST /friend/mine

POST

{
  "email": "test1@test.com"
}

Response

{
  "success": true,
  "friends" :
    [
      "test2@test.com"
    ],
  "count" : 1   
}

Retrieve the common friends list between two email addresses (3)

POST /friend/common

POST

{
  "friends":
    [
      "test1@test.com",
      "test2@test.com"
    ]
}

Response

{
  "success": true,
  "friends" :
    [
      "test3@test.com",
      "test4@test.com"
    ],
  "count" : 2 
}

Subscribe to updates from an email address (4)

POST /subscribe

POST

{
  "requestor": "test1@test.com",
  "target": "test2@test.com"
}

Response

{
  "success": true
}

Block updates from an email address (5)

POST /subscribe/block

POST

{
  "requestor": "test1@test.com",
  "target": "test2@test.com"
}

Response

{
  "success": true
}

Retrieve all email addresses that can receive updates from an email address (6)

POST /feed

POST

{
  "sender": "test1@test.com",
  "text": "Hello test2@test.com"
}

Response

{
  "success": true,
  "recipients":
      [
        "test2@test.com",
        "test3@test.com"
      ]
}

About

Friends Management API


Languages

Language:PHP 98.9%Language:Dockerfile 1.1%