API Schemes

From The Travis van der Font Wiki
Jump to: navigation, search

Actions

Verb Noun (item) Method Name
List User ListUser
Get User GetUser
Create User CreateUser
Update User UpdateUser
Rename User RenameUser
Delete User DeleteUser

Nouns are ALWAYS singular. This scheme should also match database tables and fields.

(inside DB resources here)

Successful

{
  "success": true,
  "code": 200,
  "message": null, /* optional success message */
  "data": /* application-specific data would go here */
  {
    "id": 123,
    "name": "Testing Test"
  }
}

Simplistic form:

Version 1 (boolean) Version 2 (with data)
"true"
{
  "data": "test123"
}

Failure

{
  "success": false,
  "code": 200,
  "message": null,
  "errors": [
    {
      "error_code": "BAD_VALIDATION",
      "message": [
        "ERROR: Testing Test Error"
      ]
    }
  ]
}

Simplistic form:

Version 1 (boolean) Version 2 (with data)
"false"
{
  "data": null
}

References