Skip to content

Latest commit

 

History

History
319 lines (244 loc) · 4.43 KB

users.md

File metadata and controls

319 lines (244 loc) · 4.43 KB

Users

Any "x-access-token" should be added to the header of the token not the body

Any "public_id" can be retrieved from the route, you don't have to put it inside the payload


Retrieve all users

api.ayat.com/v1/users GET

Header:
{
    "x-access-token": "65416584846465644546"
}
Success Response:

code : 200

{
    
  "users": [
    {
      "birth_date": "Sat, 16 May 2015 00:00:00 GMT",
      "country_name": "example",
      "email": "ex1pleamssdasd",
      "gender": false,
      "is_activated": false,
      "phone_number": "612s1211",
      "profile_picture": "2d",
      "public_id": "40dd1b7a-96c2-4f73-9e1c-dc22bdbb3e56",
      "registeration_date": "Sat, 16 May 2015 00:00:00 GMT",
      "type": "staff"
    },
    {
      "birth_date": "Sat, 16 May 2015 00:00:00 GMT",
      "country_name": "example",
      "email": "examplsdfeasdasd",
      "gender": false,
      "is_activated": false,
      "phone_number": "611211",
      "profile_picture": "2d",
      "public_id": "0758ef45-bde5-41f6-b80e-6188b8022183",
      "registeration_date": "Sat, 16 May 2015 00:00:00 GMT",
      "type": "staff"
    },
      
  ]

}
Error Response:

code: 403

{
  "message": "user is unauthorized"
}

Retrieve a user

api.ayat.com/v1/users/{id} GET

Header:
{
    "x-access-token": "65416584846465644546"
}
Success Response:

code : 200

{
   "user": {
    "birth_date": "Sat, 16 May 2015 00:00:00 GMT",
    "country_name": "example",
    "email": "examplsdfeasdasd",
    "gender": false,
    "is_activated": false,
    "phone_number": "611211",
    "profile_picture": "2d",
    "public_id": "0758ef45-bde5-41f6-b80e-6188b8022183",
    "registeration_date": "Sat, 16 May 2015 00:00:00 GMT",
    "type": "staff"
  }
}
Error Response:

code: 403

{
  "message": "user is unauthorized"
}

Login

api.ayat.com/v1/users POST

Payload:
{
    "action":   "login",
    "email": "example@gmail.com",
    "password": "123456",
}
Success Response:

code : 200

{
  "birth_date": "Sat, 16 May 2015 00:00:00 GMT",
  "country_name": "example",
  "email": "explsaddfeasdasd",
  "gender": false,
  "name": "example",
  "phone_number": "123",
  "profile_picture": "2d",
  "public_id": "735b3f64-afcf-4b42-b255-14bf8b3a5bc0",
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"
}
Error Response:

code: 403

{
  "message": "user is unauthorized"
}

or code: 404

{
  "message": "user not found"
}

or code: 404

{
  "message": "invalid password"
}

Create a new (inactive) user

api.ayat.com/v1/users POST

Payload:
{
    "action":   "register_student",
    "full_name":  "example",
    "email":  "explsaddfeasdasd",
    "country":  "example",
    "phone":  123,
    "profile_pic": "2d",
    "birth_date":   "2015-05-16",
	"gender": false,
    "password":   "464468",
    "registeration_date":   "2015-05-16"
}

or

{
    "action":   "register_staff",
    "full_name":  "example",
    "email":  "explsaddfeasdasd",
    "country":  "example",
    "phone":  123,
    "profile_pic": "2d",
    "birth_date":   "2015-05-16",
	"gender": false,
    "password":   "464468",
    "registeration_date":   "2015-05-16"
}
Success Response:

code : 200

{
    "status":  "created",
    "public_id": "example"
}

or

{
    "status":  "1"
}

or

{
    "status":  "2"
}

Update user data

api.ayat.com/v1/users/{id} PUT

Payload:
{
    "x-access-token": "65416584846465644546",
    "full_name":  "exaaklsfmple",
    "email":  "edlsdfdkfdfeasdasd",
    "country":  "exsdkf123ample",
    "phone":  "3211kd23",
    "profile_pic": "https://ayatsource.com/default.png",
    "birth_date":   "2015-05-16",
    "password":   "464468"
}
Success Response:

code 200

{
    "status":  "updated"
}

or

{
    "status":  "1"
}

or

{
    "status":  "2"
}

Delete a user

api.ayat.com/v1/users/{id} DELETE

Payload:
{
    "x-access-token":   "ffff"
}
Success Response:

code 200

{
    "status":  "deleted"
}

or

    {"status": "user is unauthorized"}

or

    {"status": "no user found"}