Skip to content
Vadim Sokoltsov edited this page Nov 13, 2016 · 2 revisions

POST /api/v1/users/:user_id/directions/:id/steps

Create new step for direction

Request parameters

  • user_id - type: integer - id or nickname of user
  • id - type: integer - id or slug of direction
  • title - type: string - name of step
  • description - type: text - step's description

Response parameters

  • id - type: integer - id or slug of direction
  • title - type: string - name of direction
  • description - type: text - direction's description
  • is_done - type: boolean - flag shows us is the step completed or not
  • direction_id - type: integer - id of related direction
  • direction - type: json - object of related direction

Errors

  • title - can't be blank
  • description - can't be blank

Request example

{
  "step": {
    "title": "New direction",
    "description": "New direction description"
  }
}

Success response example

{
  "step": {
    "id": 2056,
    "title": "New direction",
    "description": "New direction description",
    "is_done": null,
    "direction_id": 1602,
    "direction": {
      "id": 1602,
      "title": "New direction",
      "description": "New direction description",
      "percents_result": 0,
      "steps": [
        ...
      ],
      "user": {
        "id": 1063,
        "nick": "ololosh",
        "first_name": null,
        "last_name": null,
        "description": null,
        "location": null
      }
    }
  }
}

Failed respons example

{
  "errors": {
    "title": [
      "can't be blank"
    ],
    "description": [
      "can't be blank"
    ]
  }
}

PUT /api/v1/users/:userId/directions/:directionId/steps/:id

Update directions information

Request parameters

  • user_id - type: integer - id or nickname of user
  • direction_id - type: integer - id or slug of direction
  • id - type: integer - id of step
  • title - type: string - name of step
  • description - type: text - step's description

Response parameters

  • id - type: integer - id or slug of direction
  • title - type: string - name of direction
  • description - type: text - direction's description
  • is_done - type: boolean - flag shows us is the step completed or not
  • direction_id - type: integer - id of related direction
  • direction - type: json - object of related direction

Errors

  • title - can't be blank
  • description - can't be blank

Request example

{
  "step": {
    "title": "New direction",
    "description": "New direction description"
  }
}

Success response example

{
  "step": {
    "id": 2056,
    "title": "New direction",
    "description": "New direction description",
    "is_done": null,
    "direction_id": 1602,
    "direction": {
      "id": 1602,
      "title": "New direction",
      "description": "New direction description",
      "percents_result": 0,
      "steps": [
        ...
      ],
      "user": {
        "id": 1063,
        "nick": "ololosh",
        "first_name": null,
        "last_name": null,
        "description": null,
        "location": null
      }
    }
  }
}

Failed respons example

{
  "errors": {
    "title": [
      "can't be blank"
    ],
    "description": [
      "can't be blank"
    ]
  }
}

DELETE /api/v1/users/:userId/directions/:directionId/steps/:id

Delete directions step

Request parameters

  • user_id - type: integer - id or nickname of user
  • direction_id - type: integer - id or slug of direction
  • id - type: integer - id of step

Response parameters

  • id - type: integer - id or slug of direction
  • title - type: string - name of direction
  • description - type: text - direction's description
  • is_done - type: boolean - flag shows us is the step completed or not
  • direction_id - type: integer - id of related direction
  • direction - type: json - object of related direction

Example response

{
  "step": {
    "id": 2056,
    "title": "New direction",
    "description": "New direction description",
    "is_done": null,
    "direction_id": 1602,
    "direction": {
      "id": 1602,
      "title": "New direction",
      "description": "New direction description",
      "percents_result": 0,
      "steps": [
        {
          "id": 2055,
          "title": "New direction",
          "description": "New direction description",
          "is_done": null,
          "direction_id": 1602
        }
      ],
      "user": {
        "id": 1063,
        "nick": "ololosh",
        "first_name": null,
        "last_name": null,
        "description": null,
        "location": null
      }
    }
  }
}

Clone this wiki locally