Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Add rent multiple items endpoint
Browse files Browse the repository at this point in the history
- Fix "delete rental" endpoint
This endpoint would delete all rentals for an organization when used because it was configured incorrectly.
- Add friendly messages when creating and deleting rentals
- Add API version parameter to all endpoints
- Increment API version to 2.0.0 because the "create rental" endpoint had a breaking change
  • Loading branch information
AdamVig committed Sep 12, 2017
1 parent 7bbbbe1 commit f5f7bca
Show file tree
Hide file tree
Showing 16 changed files with 275 additions and 4 deletions.
4 changes: 4 additions & 0 deletions controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ auth.mount = app => {
* @api {post} /auth Authenticate a user
* @apiName Authenticate
* @apiGroup Authentication
* @apiVersion 2.0.0
*
* @apiDescription Log a user in and receive an access token to use in further
* requests (`token` in the response). Provides a `refreshToken` to use to
Expand All @@ -60,6 +61,7 @@ auth.mount = app => {
* @api {post} /auth/refresh Refresh access token
* @apiName Refresh
* @apiGroup Authentication
* @apiVersion 2.0.0
*
* @apiDescription When an access token expires, it is necessary to get a
* new access token in order to continue making requests.
Expand All @@ -75,6 +77,7 @@ auth.mount = app => {
* @api {post} /auth/register Register a user
* @apiName Register
* @apiGroup Authentication
* @apiVersion 2.0.0
*
* @apiDescription See the guide on authentication at the top of these docs
* for an explanation of the registration and authentication process.
Expand Down Expand Up @@ -102,6 +105,7 @@ auth.mount = app => {
* @api {head} /auth/verify Verify authentication
* @apiName Verify
* @apiGroup Authentication
* @apiVersion 2.0.0
*
* @apiDescription This endpoint is for checking whether a token is valid.
* Since it uses the `HEAD` method, it cannot take a body or parameters and
Expand Down
5 changes: 5 additions & 0 deletions controllers/brand.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ brand.mount = app => {
* @apiName GetBrands
* @apiGroup Brand
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse Pagination
*
Expand All @@ -64,6 +65,7 @@ brand.mount = app => {
* @apiName GetBrand
* @apiGroup Brand
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse BrandResponse
*/
Expand All @@ -73,6 +75,7 @@ brand.mount = app => {
* @apiName CreateBrand
* @apiGroup Brand
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription A brand represents a real-world brand like Apple or Canon.
* Each model must be associated with a brand.
Expand All @@ -88,6 +91,7 @@ brand.mount = app => {
* @apiName UpdateBrand
* @apiGroup Brand
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiParam {String{0...255}} [name] Name of brand
*
Expand All @@ -100,6 +104,7 @@ brand.mount = app => {
* @apiName DeleteBrand
* @apiGroup Brand
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse EndpointDelete
* @apiUse InvalidSubscriptionResponse
Expand Down
5 changes: 5 additions & 0 deletions controllers/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ category.mount = app => {
* @api {get} /category Get all categories
* @apiName GetCategories
* @apiGroup Category
* @apiVersion 2.0.0
*
* @apiUse Pagination
*
Expand All @@ -62,6 +63,7 @@ category.mount = app => {
* @api {get} /category/:categoryID Get category
* @apiName GetCategory
* @apiGroup Category
* @apiVersion 2.0.0
*
* @apiUse CategoryResponse
*/
Expand All @@ -70,6 +72,7 @@ category.mount = app => {
* @api {put} /category Create a category
* @apiName CreateCategory
* @apiGroup Category
* @apiVersion 2.0.0
*
* @apiDescription Each item must belong to a category. Categories can be used
* to group items that are similar. Custom fields can be assigned to
Expand All @@ -85,6 +88,7 @@ category.mount = app => {
* @api {put} /category/:categoryID Update a category
* @apiName UpdateCategory
* @apiGroup Category
* @apiVersion 2.0.0
*
* @apiParam {String{0...255}} [name] Name of category
*
Expand All @@ -96,6 +100,7 @@ category.mount = app => {
* @api {delete} /category/:categoryID Delete a category
* @apiName DeleteCategory
* @apiGroup Category
* @apiVersion 2.0.0
*
* @apiUse EndpointDelete
* @apiUse InvalidSubscriptionResponse
Expand Down
7 changes: 7 additions & 0 deletions controllers/custom-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ customField.mount = app => {
* @apiName GetCustomFields
* @apiGroup CustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse Pagination
*
Expand All @@ -113,6 +114,7 @@ customField.mount = app => {
* @apiName GetCustomField
* @apiGroup CustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse CustomFieldResponse
*/
Expand All @@ -122,6 +124,7 @@ customField.mount = app => {
* @apiName CreateCustomField
* @apiGroup CustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription A custom field can be used to add custom data to all items
* (or specific categories of items) beyond the data that the application
Expand All @@ -143,6 +146,7 @@ customField.mount = app => {
* @apiName UpdateCustomField
* @apiGroup CustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiParam {String{0...255}} [name] Name of custom field
* @apiParam {Number} [organizationID] ID of organization (automatically taken
Expand All @@ -157,6 +161,7 @@ customField.mount = app => {
* @apiName DeleteCustomField
* @apiGroup CustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription Deleting a custom field will also delete all values
* associated with this field across all items in the organization.
Expand All @@ -170,6 +175,7 @@ customField.mount = app => {
* @apiName GetCustomFieldCategories
* @apiGroup CustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiExample {json} Response Format
* {
Expand All @@ -190,6 +196,7 @@ customField.mount = app => {
* @apiName UpdateCustomFieldCategories
* @apiGroup CustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiParam {Object[]} [categories] List of category entities that this field belongs in. The field will only apply
* to items in this category
Expand Down
5 changes: 5 additions & 0 deletions controllers/external-renter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ externalRenter.mount = app => {
* @api {get} /external-renter Get all external renters
* @apiName GetCategories
* @apiGroup ExternalRenter
* @apiVersion 2.0.0
*
* @apiExample {json} Response Format
* {
Expand All @@ -49,6 +50,7 @@ externalRenter.mount = app => {
* @api {get} /external-renter/:externalRenterID Get external renter
* @apiName GetExternalRenter
* @apiGroup ExternalRenter
* @apiVersion 2.0.0
*
* @apiUse ExternalRenterResponse
*/
Expand All @@ -57,6 +59,7 @@ externalRenter.mount = app => {
* @api {put} /external-renter Create an external renter
* @apiName CreateExternalRenter
* @apiGroup ExternalRenter
* @apiVersion 2.0.0
*
* @apiDescription An external renter is a person or organization from outside
* the organization using Stockpile that rents items. These renters are
Expand All @@ -80,6 +83,7 @@ externalRenter.mount = app => {
* @api {put} /external-renter/:externalRenterID Update an external renter
* @apiName UpdateExternalRenter
* @apiGroup ExternalRenter
* @apiVersion 2.0.0
*
* @apiParam {String{0..255}} [name] Name of company or individual
* @apiParam {String{0..255}} [email] Email address
Expand All @@ -96,6 +100,7 @@ externalRenter.mount = app => {
* @api {delete} /external-renter/:externalRenterID Delete an external renter
* @apiName DeleteExternalRenter
* @apiGroup ExternalRenter
* @apiVersion 2.0.0
*
* @apiUse EndpointDelete
* @apiUse InvalidSubscriptionResponse
Expand Down
11 changes: 11 additions & 0 deletions controllers/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ item.mount = app => {
* @apiName GetItems
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription This endpoint can be filtered using the query parameters
* specified below. Any of the filters can be applied at the same time in
Expand Down Expand Up @@ -152,6 +153,7 @@ item.mount = app => {
* @apiName GetItem
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse ItemResponse
*/
Expand All @@ -161,6 +163,7 @@ item.mount = app => {
* @apiName CreateItem
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription An item represents a physical object owned by the
* organization. Items must have physical barcodes in order for the
Expand All @@ -180,6 +183,7 @@ item.mount = app => {
* @apiName UpdateItem
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiParam {Number} [modelID] ID of model
* @apiParam {Number} [categoryID] ID of category
Expand All @@ -195,6 +199,7 @@ item.mount = app => {
* @apiName DeleteItem
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse EndpointDelete
* @apiUse InvalidSubscriptionResponse
Expand All @@ -205,6 +210,7 @@ item.mount = app => {
* @apiName GetItemRentals
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse Pagination
*
Expand All @@ -229,6 +235,7 @@ item.mount = app => {
* @apiName GetItemActiveRental
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiExample {json} Response Format
* {
Expand All @@ -251,6 +258,7 @@ item.mount = app => {
* @apiName GetItemStatus
* @apiGroup Item
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription An item's status is either available or unavailable. In the
* response from this endpoint, the `available` property will equal either
Expand All @@ -273,6 +281,7 @@ item.mount = app => {
* @apiName GetItemCustomFieldValues
* @apiGroup ItemCustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription Custom field values are automatically initialized to empty
* strings when a new custom field is created, so empty strings will be
Expand All @@ -298,6 +307,7 @@ item.mount = app => {
* @apiName GetItemCustomFieldValue
* @apiGroup ItemCustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiExample {json} Response Format
* {
Expand All @@ -315,6 +325,7 @@ item.mount = app => {
* @apiName UpdateItemCustomFieldValue
* @apiGroup ItemCustomField
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription Custom fields can be created with *create custom field*. To
* "delete" a custom field value, set the value to an empty string.
Expand Down
9 changes: 9 additions & 0 deletions controllers/kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ kit.mount = app => {
* @apiName GetAllKits
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiExample {json} Response Format
* {
Expand All @@ -99,6 +100,7 @@ kit.mount = app => {
* @apiName GetKit
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse KitResponse
*/
Expand All @@ -108,6 +110,7 @@ kit.mount = app => {
* @apiName CreateKit
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiDescription Kits are collections of models that a user would like to
* rent together. Kits consist of models, not items, to retain flexibility
Expand All @@ -128,6 +131,7 @@ kit.mount = app => {
* @apiName UpdateKit
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiParam {String{0..255}} [name] Name of kit
*
Expand All @@ -140,6 +144,7 @@ kit.mount = app => {
* @apiName DeleteKit
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse EndpointDelete
* @apiUse InvalidSubscriptionResponse
Expand All @@ -150,6 +155,7 @@ kit.mount = app => {
* @apiName GetAllKitModels
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiExample {json} Response Format
* {
Expand All @@ -171,6 +177,7 @@ kit.mount = app => {
* @apiName CreateKitModel
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiParam {Number} modelID ID of model
* @apiParam {Number} [quantity=1] How many of the model belong in the kit
Expand All @@ -184,6 +191,7 @@ kit.mount = app => {
* @apiName UpdateKitModel
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiParam {Number} quantity How many of the model belong in the kit
*
Expand All @@ -197,6 +205,7 @@ kit.mount = app => {
* @apiName DeleteKitModel
* @apiGroup Kit
* @apiPermission User
* @apiVersion 2.0.0
*
* @apiUse EndpointDelete
* @apiUse InvalidSubscriptionResponse
Expand Down
1 change: 1 addition & 0 deletions controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ main.mount = app => {
* @apiName GetMain
* @apiGroup Main
* @apiPermission Public
* @apiVersion 2.0.0
*
* @apiDescription This is the entry point for the API. Using HAL relations,
* the client can navigate the whole API based on the response from this
Expand Down

0 comments on commit f5f7bca

Please sign in to comment.