Skip to content
Salvatore D'Agositno edited this page Oct 26, 2013 · 4 revisions

Create

This will create a user

POST /users

##Sample Request Arguments(POST):

username : jsnow // Auth
password : test  // Auth
    user => {
        "username"   : "samTest",
        "email"      :"[email protected]",
        "password"   : "test",
        "first_name" : "Hello",
        "last_name"  : "World",
        "dob"        : "1970-07-03"
    }

##Sample Response:

    {
        "error"   : true,
        "message" : "Username taken",
        "data"    : null
    }



    {
        "error"   : false,
        "message" : "User Created",
        "data"    : null
    }

Read User

This function will return a user object to the client

GET /users/:id

##Sample Request Arguments(GET):

username : jsnow // Auth
password : test  // Auth

##Sample Response:

    {
        "error"   : false,
        "message" : "Found User",
        "data"    : [
            {
                "id"           : 1,
                "status"       : "1",
                "username"     : "jsnow",
                "email"        : "[email protected]",
                "first_name"   : "Jon",
                "last_name"    : "Snow",
                "dob"          : "1970-07-03T00:00:00.000Z",
                "date_created" : "2013-09-02T18:47:43.170Z",
                "date_updated" : "2013-09-02T18:47:43.170Z"
            }
        ]
    }

Read Users

This function will return all user objects to the client

GET /users

##Sample Request Arguments(GET):

username : jsnow // Auth
password : test  // Auth
start    : 1     // Optional
limit    : 1     // Optional

##Sample Response:

{
    "error"   : false,
    "message" : "User Listing",
    "data"    : [
        {
            "id"           : 2,
            "status"       : "1",
            "username"     : "edstark",
            "password"     : "$2a$10$/z20j7hc8Clkx0.4v2d5w.VOU7yDBD6nzWsjb5AsbGtCoRt3x4Npy",
            "email"        : "[email protected]",
            "first_name"   : "Eddard",
            "last_name"    : "Stark",
            "dob"          : "1970-07-03T00:00:00.000Z",
            "date_created" : "2013-09-02T18:47:43.173Z",
            "date_updated" : "2013-09-02T18:47:43.173Z"
        },
        {
            "id"           : 3,
            "status"       : "1",
            "username"     : "catstark",
            "password"     : "$2a$10$/z20j7hc8Clkx0.4v2d5w.VOU7yDBD6nzWsjb5AsbGtCoRt3x4Npy",
            "email"        : "[email protected]",
            "first_name"   : "Catelyn",
            "last_name"    : "Stark",
            "dob"          : "1970-07-03T00:00:00.000Z",
            "date_created" : "2013-09-02T18:47:43.178Z",
            "date_updated" : "2013-09-02T18:47:43.178Z"
        }
    ]
}

Update

This function will update a user object details

PUT /users

##Sample Request Arguments(PUT):

username : jsnow // Auth
password : test  // Auth
    user => {
        "username"   : "samTest",
        "email"      :"[email protected]",
        "password"   : "test",
        "first_name" : "Hello",
        "last_name"  : "World",
        "dob"        : "1970-07-03"
    }

##Sample Response:

{
    "error"   : false,
    "message" : "Updated user",
    "data"    : null
}

Delete

This function will delete a user object from the DB

DELETE /user/:id

##Sample Request Arguments(DELETE):

username : jsnow // Auth
password : test  // Auth

##Sample Response:

{
    "error"   : false,
    "message" : "Deleted user",
    "data"    : null
}
Clone this wiki locally