APIs for the board page

First of all, let's see the APIs that we will need to implement:

  • The API to get a board
  • The API to add a board member
  • The API to add a card list
  • The API to change the positions of card lists
  • The API to add a card
  • The API to change card positions

Let's take a look at each one of them, as follows:

  • Get board API: This will be a GET request sent to /api/boards/{boardId}. Through this API, we will return the board information, as well as the board members, card lists, and its cards. If this is a team board, we will also need to return the team information. The following is how the response will look:
{
"team": {
"name": "Sales & Markerting"
},
"board": {
"name": "Ongoing Campaigns",
"personal": false,
"id": 1
},
"members": [{
"userId": 1,
"shortName": "JY"
}],
"cardLists": [{
"id": 1,
"name": "Todo",
"position": 1,
"cards": [{
"id": 1,
"title": "Come up with a marketing strategy",
"position": 1
}]
}]
}
  • Add board member API: This will be a POST request sent to /api/boards/{boardId}/members with the username as the payload:
{ "usernameOrEmailAddress": "sunny" }

Or, we can use an email address like in the following:

{ "usernameOrEmailAddress": "[email protected]" }

The API response will look like the following:

{ "id": 3, "shortName": "SH" }
  • Add card list API: This will be a POST request sent to /api/card-lists with a payload similar to the following:
{
"boardId": 1,
"name": "Todo",
"position": 1
}

The API response will look like the following:

{
"id": 2,
"name": "Todo"
}

As you can see, in the response, the server will send back the newly created card list.

  • Change card list positions API: This will be a POST request sent to /api/card-lists/positions with a payload similar to the following:
{
"boardId": 6,
"cardListPositions": [
{ "cardListId": 1, "position": 1 },
{ "cardListId": 2, "position": 3 },
{ "cardListId": 3, "position": 2 }
]
}

As you can see, in the request we send the positions of all of the card lists to the server. When the request succeeds, the server will simply return an HTTP status of 200 with no response body.

  • Add card API: This will be a POST request sent to /api/cards with a payload similar to the following:
{
"boardId": 1,
"cardListId": 1,
"title": "Come up with a marketing strategy",
"position": 1
}

The API response will look similar to the following when it succeeds:

{
"id": 1,
"position": 1,
"title": "Come up with a marketing strategy"
}

As you can see, in the response, the server will send back the newly created card.

  • Change card positions API: This will be a POST request sent to /api/cards/positions with a payload similar to the following:
{
"boardId": 6,
"cardPositions": [
{ "cardListId": "1", "cardId": 2, "position": 1 },
{ "cardListId": "1", "cardId": 3, "position": 2 },
{ "cardListId": "2", "cardId": 1, "position": 1 },
{ "cardListId": "2", "cardId": 4, "position": 2 }
]
}

When a card is simply moved up and down in the same card list, in the cardPositions array, we will only send the positions of all of the cards in that list. When a card is moved from one list to another, we will send the positions of all of the cards in both lists. When the request succeeds, the server will simply return an HTTP status of 200 with no response body.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.51.153