Skip to content

Repository files navigation

Users-API

Rails API for a simple user administration system.

Features

  • Authentication with JWT tokens
  • Perform CRUD operations on Users

Technologies

  • Ruby on Rails
  • PostgreSQL

Deployment and CI/CD

Deploy to AWS on push/merge to master if tests pass, keywords:

  • CircleCI
  • Capistrano
  • AWS
  • Amazon RDS

Endpoints

All endpoints are protected and require authentication with JSON Web Tokens (JWT)

Authentication

POST /signin

Data

nametypenotes
authobjectrequired.
auth.phone_numberstringrequired. (test with: "123-123-123")
auth.passwordstringrequired. (test with: "password")

Request body example

/signin
json
{
"auth": {
"phone_number": "123-123-123",
"password": "password"
}
}

Response

Status 201 Created
json
{
"jwt": "eyJ0eXAiOiJzI1NiJ9.eyJleHAiOjE1MzcwOTc1NDcsInN1YiI.V3WjeYFN1sazil7b28e0FhgD_SQnP9OR4w0eJ3sNfic"
}

Get list of all users

GET /api/v1/users

Headers

namenotes
AuthorizationEx: BEARER {post here JWT string}
Content-Typeapplication/json

Response

Status 200 Ok
json
{
"data": [
{
"id": "1",
"type": "users",
"attributes": {
"phone-number": "123-123-123",
"name": "John Doe"
}
},
{
"id": "2",
"type": "users",
"attributes": {
"phone-number": "321-321-321",
"name": "Fred White"
}
}
]

}

Get a single user

GET /api/v1/users/:user_id

Headers

namenotes
AuthorizationEx: BEARER {post here JWT string}
Content-Typeapplication/json

Response

Status 200 Ok
json
{
"data": {
"id": "1",
"type": "users",
"attributes": {
"phone-number": "123-123-123",
"name": "John Doe"
}
}
}

Create a user

POST /api/v1/users

Headers

namenotes
AuthorizationEx: BEARER {post here JWT string}
Content-Typeapplication/json

Data

nametypenotes
userobjectrequired.
user.phone_numberstringrequired.unique.
user.namestringrequired.
user.passwordstringrequired.4-32 chars

Request body example

/api/v1/users
json
{
"user": {
"phone_number": "111-111-111",
"name": "Fred White",
"password": "password"
}
}

Response

Status 201 Created
json
{
"data": {
"id": "4",
"type": "users",
"attributes": {
"phone-number": "111-111-111",
"name": "Fred White"
}
}
}

Update a user

PATCH /api/v1/users/:user_id

Headers

namenotes
AuthorizationEx: BEARER {post here JWT string}
Content-Typeapplication/json

Data

nametypenotes
phone_numberstringunique.
namestring
passwordstring4-32 chars

Request body example

/api/v1/users/4
json
{
"name": "Updated name",
"password": "updated_password"
}

Response

Status 200 Ok
json
{
"data": {
"id": "4",
"type": "users",
"attributes": {
"phone-number": "111-111-111",
"name": "Updated name"
}
}
}

About

Rails API for a simple user administration system.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages