pseudocms/app-api — pull request #10 by pseudomuto (2014-07-29 00:28:07+00:00)
Title: Sites API

Simple CRUD endpoints for managing sites.

# The Model

Each site defines a site owner (`User`) that owns the site. Currently, the only special permission the owner has is the ability to delete the site. This will probably change over time...

There is also a many-to-many relationship between `Site` and `User` (via `has_and_belongs_to_many`) so that users can be "associated" with many sites, allowing them to update and view site details.

# Endpoints

endpoint | verb | description | required_permission
---- | ---- | ---- | --------
`/sites` | `GET` | Gets a paginated list of sites. All sites if `blessed_app?`, otherwise sites the current user is associates with | user or blessed app
`/sites` | `POST` | Creates a new site with current user as the owner. If `blessed_app?`, uses a pseudo-parameter on site called `owner_id` (stripped unless blessed_app) | user or blessed app
`/sites/:id` | `GET` | Gets the site by id. Unless `blessed_app?` the user must be associated with the specified site | user or blessed app
`/sites/:id` | `PATCH` | Updates a site. Unless `blessed_app?` the user must be associated with the specified site | user or blessed app
`/sites/:id` | `DELETE` | Deletes the specified site. Unless `blessed_app?` the user must be the site owner to destroy a site. | owner or blessed app