Skip to content

Api written in Nodejs and using Mongodb. SMS Management Application is an API that manages sending and receiving of SMS messages. With this API, you can manage contacts, send SMS, update an SMS, receive SMS, view an SMS.

Notifications You must be signed in to change notification settings

hadijahkyampeire/sms-management-api-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sms Management Api

Build Status Coverage Status

Documentation

  • Find the live documentation Here

About the API

SMS Management Application is an API that manages sending and receiving of SMS messages. With this API, you can manage contacts, send SMS, update an SMS, receive SMS, view an SMS.

Requirements

Ensure to have these on your machine.

How to set it up

  1. Clone the repository.

git clone https://github.com/hadijahkyampeire/sms-management-api-mongo.git

  1. Install the dependencies by running:

yarn install

  1. Start you mongodb service

mongod, if it requires authentication use sudo mongod

  1. Get started

yarn start:dev

  1. you can now access the application using postman

http://localhost:5000

Testing

The application's tests can be executed by running the script below within the terminal at the application root directory:


yarn test or npm test

if you want to know the coverage use:


yarn test -- --coverage

Endpoints

  • After creating a contact one has to get authenticated first before they access other endpoints.

CONTACTS

api/v1/contacts

description: Creates a contact method : POST headers: content-Type →application/json sample payload:

`{
    "first_name": "Haddy",
    "last_name":"Kyamps"
    "phoneNumber": "0781980273",
    "password": "password"
 }`

api/v1/contacts

description: Updates user contact information method : PUT headers: content-Type →application/json Authorization: put a token got from authorization sample payload:

`{
    "phoneNumber": "0705221421",
    "first_name":"Hadijah"
 }`

api/v1/contacts

description: Retrieves users contacts information method : GET headers: content-Type →application/json Authorization: put a token got from authorization returns:

`{
"contacts": [
    {
        "_id": "5c7434ad282c7f95ee924353",
        "first_name": "kyampeire",
        "last_name": "hadijah",
        "password": "$2b$10$31Ibyx0d76W1A.OBaum8NuX7s7ayo51VJHt3yBhzP/zvR432DyKH6",
        "phone_number": "0781980273",
        "__v": 0
    },
]

}`

api/v1/contacts

description: Deletes a contact for the authenticated user along with messages associated to them method : DELETE headers: content-Type →application/json Authorization: put a token got from authorization

returns:

` {
  message:"contact deleted successfully"
  }`

AUTHENTICATION

api/v1/authentication

description: Login and authenticate the user method : POST headers: content-Type →application/json payload:

 `{
	"phone_number": "0705221421",
	"password": "password"
  }`

returns:

` {
  "message": "You were successfully authenticated",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXlsb2FkIjp7InBob25lX251bWJlciI6IjA3MDUyMjE0MjEiLCJjb250YWN0X2lkIjoiNWM3NTM1ZWM2OWJlYzUyZmQ1Y2MwN2VkIn0sImlhdCI6MTU1MTE4NTQzNSwiZXhwIjoxNTUxMjcxODM1fQ.p0l_mnTwTNcYME2jmXtpEyjRXNsyE4Ws3wt_PWilBRc"
}`

MESSAGES

api/vi/messages

description: Sends a message method : POST headers: content-Type →application/json Authorization: put a token got from authorization sample payload:

`{
    "receiver": "5c1337021fbf86ef244f8534",
    "message": "Test massage 3"
}`

api/v1/messages

description: Retrieves all messages belonging to the authenticated user method : GET headers: content-Type →application/json Authorization: put a token got from authorization returns:

`
`{
    "success": true,
    "data": [
    {
        "status": "sent",
        "_id": "5c162261bcaf48e17ca22c76",
        "sender": "5c155afb60bf0f0518328497",
        "receiver": "5c1337021fbf86ef244f8534",
        "message": "Test massage 3",
        "created": "2018-12-16T10:01:05.372Z",
        "__v": 0
    }
    ],
    "message": "SMS collected succefully"
}`

api/v1/messages/id

description: Updates a message method : PUT headers: content-Type →application/json Authorization: put a token got from authorization payload:

`{
    "message": "How are you"
}`

returns:

`{
"status": "sent",
"_id": "5c743665282c7f95ee924357",
"receiver": "0781980273",
"message": "How are you",
"sender": "0705221421",
"created": "2019-02-25T18:39:33.062Z",
"__v": 0

}`

api/v1/messages/:id

description: Returns one message by ID method : GET headers: content-Type →application/json Authorization: put a token got from authorization returns:

`
{
"status": "sent",
"_id": "5c743665282c7f95ee924357",
"receiver": "0781980273",
"message": "Hey dia how are you",
"sender": "0705221421",
"created": "2019-02-25T18:39:33.062Z",
"__v": 0

}`

api/v1/messages/:id

description: Deletes a message you created by ID method : DELETE headers: content-Type →application/json Authorization: put a token got from authorization

About

Api written in Nodejs and using Mongodb. SMS Management Application is an API that manages sending and receiving of SMS messages. With this API, you can manage contacts, send SMS, update an SMS, receive SMS, view an SMS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published