Updates - Hip-Hop-Xpress/hhx-api GitHub Wiki

Updates endpoint

The Hip Hop Xpress App will send users updates about events, courses, and other news regarding the Hip Hop Xpress and related organizations. This endpoint serves as a way for app clients to receive new updates.

Guide

The Update object

{
  "id": 0,
  "title": "Double Dutch Boom Bus Playlists",
  "dateCreated": "Thu May 14 2020 12:00:00 GMT-0500 (Central Daylight Time)",
  "lastUpdated": null,
  "author": "Hip Hop Xpress Admin",
  "body": [
    "As UIUC students wrap up their final exams of the semester, we want...",
    "Check them out on our Instagram! @uiuchhx"
  ],
}

Attributes

These attributes are to be included in POST and PUT request bodies.

Name Type Restrictions Description
id number must be unique non-zero integer, cannot be updated once created unique identifier for update
title string must be non-empty title of the update
author string must be non-empty the author of the update
body Array of string must be non-empty body text of the update

These attributes are automatically created, immutable, and should not be included in your POST and PUT request bodies (doing so will result in errors)

Name Type Restrictions Description
dateCreated string date format follows the toString() method of the Date JavaScript Object type the date the update was created or released
lastUpdated string or null follows same format as dateCreated if not null the date the update was last updated, or null if never updated

Endpoints

Overview

A quick overview of all endpoints related to our updates:

   POST /v1/updates
    GET /v1/updates

    GET /v1/updates/:id
    PUT /v1/updates/:id
 DELETE /v1/updates/:id

   POST /v1/updates/:id/body
    GET /v1/updates/:id/body

Usage

All use cases for the updates endpoints are listed below.

Collection wide:

Update specific:

Update data specific:

View the error documentation for what to expect if your request fails.


Create Update

POST /v1/updates

Creates an update by including an update object (JSON) in the request body. All fields are required, and the id must be a unique, non-negative integer.

Parameters

A valid update object (JSON) with correct attributes

Returns

The update object as added in the database


Retrieve all updates

GET /v1/updates

Retrieves the data for all updates

Parameters

None

Returns

An array of all update objects


Retrieve update

GET /v1/updates/:id

Retrieves a specific update through its id, with :id being the desired update's id field.

Parameters

None

Returns

The update object with specified id


Update update

PUT /v1/updates/:id

Updates specific attributes of an update object with id

Parameters

An object containing only the attributes needing change, and their updated values. For example, if you need to change the title attribute, you only need to include the title field in your request: {"title": "some new title"}. However, any updated attributes must follow the attribute restrictions.

Returns

The updated update object


Delete update

DELETE /v1/updates/:id

Deletes a specific update from the database by its id

Parameters

None

Returns

The update object that was deleted


Add to body

POST /v1/updates/:id/body

Adds text to a update's body by including the desired text in the request body.

Parameters

Either a single string or an array of strings in the request body

Returns

The updated body (array of strings)


Retrieve body

GET /v1/updates/:id/body

Retrieves all the text in a specific update's body

Parameters

None

Returns

The body (array of strings)

Back to top