variations - Hip-Hop-Xpress/hhx-api GitHub Wiki
"Variations" hold data regarding past variations on the Hip Hop Xpress. You can view them on the Hip Hop Xpress website here.
Each variation object holds data in JSON format. All attributes are required in POST requests, but not in PUT requests (see more here).
{
"id": 0,
"name": "B.E.A.T.S. Trailer",
"date": "2012-2018",
"description": [
"With the Airstream trailer no longer available, Dr. Patterson located...",
"This trailer, too, required rental of a vehicle to pull it to various...",
],
"images": [
{
"url": "https://publish.illinois.edu/.../IPoweredTrailer.jpg",
"caption": "The B.E.A.T.S. trailer in action",
"componentImage": true,
},
{
"url": "https://publish.illinois.edu/.../HipHopXpressSideViewTrailer.jpg",
"caption": "A side view of the B.E.A.T.S. trailer",
"componentImage": false,
},
]
}| Name | Type | Restrictions | Description |
|---|---|---|---|
id |
number |
must be unique non-zero integer, cannot be updated once created | unique identifier for variation |
name |
string |
must be non-empty | display name for variation |
date |
string |
must be 4 characters or more | describes the running time of variation |
description |
Array of string
|
must be non-empty | describes the variation |
images |
Array of Image Objects |
must be non-empty, exactly one Image Object must have componentImage set to true
|
lists all display images for variation |
Image description for images array in the variation object. Each field is required when creating new images.
{
"url": "https://publish.illinois.edu/.../IPoweredTrailer.jpg",
"caption": "",
"componentImage": true,
}| Name | Type | Restrictions | Description |
|---|---|---|---|
url |
string |
must be a valid URL | points to image of variation |
caption |
string |
none, can be empty | briefly describes the image |
componentImage |
boolean |
exactly one image must have componentImage set to true
|
describes whether this image is displayed on its component in the mobile app |
A quick overview of all endpoints related to Variations on the Hip Hop Xpress
POST /v1/variations
GET /v1/variations
GET /v1/variations/:id
PUT /v1/variations/:id
DELETE /v1/variations/:id
POST /v1/variations/:id/images
GET /v1/variations/:id/images
POST /v1/variations/:id/description
GET /v1/variations/:id/descriptionAll use cases for the Variations endpoints are listed below.
Collection wide:
Variation specific:
- Retrieve a variation:
GET /v1/variations/:id - Update a variation:
PUT /v1/variations/:id - Delete a variation:
DELETE /v1/variations/:id
Variation data specific:
- Add images for variation:
POST /v1/variations/:id/images - Retrieve images for variation:
GET /v1/variations/:id/images - Add text to variation description:
POST /v1/variations/:id/description - Retrieve variation's description:
GET /v1/variations/:id/description
View the error documentation for what to expect if your request fails.
POST /v1/variations
Creates a variation by including a variation object (JSON) in the request body. All fields are required, and the id must be a unique, non-negative integer.
A valid variation object (JSON) with correct attributes
The variation object as added in the database if successful
GET /v1/variations
Retrieves the data for all variations
None
An array of all variation objects
GET /v1/variations/:id
Retrieves a specific variation through its id
None
The variation object with specified id
PUT /v1/variations/:id
Updates attributes of a specified variation object by id
A variation object containing only the attributes needing change, and their updated values. For example, if you need to change the date attribute, you only need to include the date field in your request: {"date": "some new date"}. However, any updated attributes must follow the attribute restrictions.
The updated variation object
DELETE /v1/variations/:id
Deles a variation object with id
None
The variation object that was deleted
POST /v1/variations/:id/images
Adds images to a specific variation by including the image objects in your request body.
Either a single image object or an array of image objects in the request body. All attributes are required for each image object.
The updated images array
GET /v1/variations/:id/images
Retrieves all the images for a specified variation by id
None
The images array of variation with specified id
POST /v1/variations/:id/description
Adds text to a variation's description by by including the text in the request body
Either a single string or an array of strings in the request body
The updated description (array of strings)t
GET /v1/variations/:id/description
Retrieves all the text in a specific variation's description
None
The description (array of strings)