Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Phase II: A Simple HTTPS Server

Aaron Turner edited this page Oct 21, 2016 · 23 revisions

API Endpoints

Login user

POST /api/v1/login

Creates and login the user by using their facebook profile.

Parameters:

Name Type Description
access_token String User's facebook access token

Response:

Response: 200
{
  "Session": "True",
  "user": {
    "_id": "58097afb4ea17b71a7f254c2",
    "name": "Aaron Turner",
    "email": "",
    "profilePhotoURL": "graph.facebook.com/AaronID/picture",
    "__v": 0,
    "pendingFriends": [],
    "friends": [],
    "facebook": {
      "id": "AaronID"
    }
  }
}

Get user information by id

GET /api/v1/user/id/:id

Retrieves the user information based on the Facebook ID.

Parameters:

Name Type Description
access_token String User's facebook access token
id String A User's facebook ID

Response:

Response: 200
{
  "_id": "5807f1f75e22d052a7fd7994",
  "name": "Kumin In",
  "email": "[email protected]",
  "profilePhotoURL": "graph.facebook.com/KuminID/picture",
  "__v": 0,
  "pendingFriends": [],
  "friends": [],
  "facebook": {
    "id": "KuminID"
  }
}

Get user information by email

GET /api/v1/user/email/:email

Retrieves the user information based on the Email.

Parameters:

Name Type Description
access_token String User's facebook access token
email String A User's email address

Response:

Response: 200
{
  "_id": "5807f1f75e22d052a7fd7994",
  "name": "Kumin In",
  "email": "[email protected]",
  "profilePhotoURL": "graph.facebook.com/KuminID/picture",
  "__v": 0,
  "pendingFriends": [],
  "friends": [],
  "facebook": {
    "id": "KuminID"
  }
}

Get public key for a user.

GET /api/v1/user/id/:id/publicKey


Update existing public key for the user.

PUT /api/v1/user/id/:id/publicKey


Accept pending friend request

PUT /api/v1/user/friend/accept


Decline pending friend request

PUT /api/v1/user/friend/decline


Create new friend request

PUT /api/v1/user/friend/add


Get all conversation for a user

GET /api/1/conversation

Retrieves All of the User's conversation.

Parameters:

Name Type Description
access_token String User's facebook access token

Response:

Response: 200
[
  {
    "_id": "AaronID_KuminID",
    "date": "2016-10-19T23:26:15.234Z",
    "__v": 2,
    "message": [
      {
        "message": "hey man how are you doing?",
        "from": "Aaron Turner",
        "date": "2016-10-19T22:58:13.564Z",
        "_id": "5807fa85df31ad5bde8b2582"
      },
      {
        "message": "I'm doing fine. Good job on the front end!",
        "from": "Kumin In",
        "date": "2016-10-19T23:13:20.497Z",
        "_id": "5807fe10bd56f65f33e8c85f"
      },
      {
        "message": "Hermdad was here!",
        "from": "Kumin In",
        "date": "2016-10-19T23:26:15.234Z",
        "_id": "58080117a6e859636442b90c"
      }
    ],
    "memberNames": [
      "Kumin In",
      "Aaron Turner"
    ],
    "memberIDs": [
      "AaronID",
      "KuminID"
    ]
  }
]

Update a conversation for a user.

PUT /api/v1/conversation

Updates a conversation with a new message from a user.

Parameters:

Name Type Description
access_token String User's facebook access token
message String The message being sent
conversationID String ID for the conversation

Response:

Response: 201
{
  "_id": "AaronID_KuminID",
  "date": "2016-10-21T01:55:32.882Z",
  "__v": 3,
  "message": [
    {
      "message": "hey man how are you doing?",
      "from": "Aaron Turner",
      "date": "2016-10-19T22:58:13.564Z",
      "_id": "5807fa85df31ad5bde8b2582"
    },
    {
      "message": "I'm doing fine. Good job on the front end!",
      "from": "Kumin In",
      "date": "2016-10-19T23:13:20.497Z",
      "_id": "5807fe10bd56f65f33e8c85f"
    },
    {
      "message": "Hermdad was here!",
      "from": "Kumin In",
      "date": "2016-10-19T23:26:15.234Z",
      "_id": "58080117a6e859636442b90c"
    },
    {
      "message": "THIS IS REALLY SICK!!!!!",
      "from": "Kumin In",
      "date": "2016-10-21T01:55:32.882Z",
      "_id": "58097594289e316c9aafbb7c"
    }
  ],
  "memberNames": [
    "Kumin In",
    "Aaron Turner"
  ],
  "memberIDs": [
    "AaronID",
    "KuminID"
  ]
}

Create a new conversation for a user.

Create a new conversation for the users provided. Message Object is sent as a JSON Object in the body.

POST /api/v1/conversation

Parameter:

Name Type Description
access_token String User's facebook access token
message Object The message being sent

message Object:

{
	"access_token": "UserAccessToken",
	"message": "hey man how are you doing?",
	"names": ["Kumin In"],
	"members": ["KuminID"]
}

Response:

Response 200
{
  "_id": "AaronID_KuminID",
  "date": "2016-10-21T02:24:03.247Z",
  "__v": 0,
  "message": [
    {
      "message": "hey man how are you doing?",
      "from": "Aaron Turner",
      "date": "2016-10-21T02:24:03.247Z",
      "_id": "58097c43143bbf72c60805ff"
    }
  ],
  "memberNames": [
    "Kumin In",
    "Aaron Turner"
  ],
  "memberIDs": [
    "AaronID",
    "KuminID"
  ]
}

Postman Test Images

Imgur

Imgur

Imgur

Imgur

Imgur

Imgur

Imgur

Clone this wiki locally