Skip to content

Directions

Vadim Sokoltsov edited this page Apr 19, 2017 · 4 revisions

GET /api/v1/users/:user_id/directions

Return list of user's directions

Request parameters

  • user_id - type: integer - id or nickname of user

Response parameters

  • id - type: integer - id of direction
  • title - type: string - Name of direction
  • description - type: text - Direction's description
  • percents_result - type: float - relation between finished and unfinished steps for direction

Response example

"directions": [
    {
      "id": 1600,
      "title": "Another direction",
      "description": "Description for this direction",
      "percents_result": null
    },
    {
      "id": 329,
      "title": "Rails 41",
      "description": "Rails 4 description",
      "percents_result": 0
    },
    {
      "id": 325,
      "title": "adaw",
      "description": "awdawd",
      "percents_result": 0
    },
    ...
]

GET /api/v1/users/:user_id/directions/:id

Return detailed direction information

Request parameters

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

Response parameters

  • id - type: integer - id of direction
  • title - type: string - name of direction
  • description - type: text - direction's description
  • percents_result - type: float - relation between finished and unfinished steps for direction
  • steps - type: array - list of directions steps
  • appointments - type: array - list of directions appointments
  • user - type: json - user information object
  • user.attachment - type: json - user avatar information

Response example

{
  "direction": {
    "id": 1600,
    "title": "Another direction",
    "description": "Description for this direction",
    "percents_result": null,
    "steps": [],
    "appointments": [],
    "user": {
      "id": 22,
      "nick": "vforvad",
      "first_name": "Vadim",
      "last_name": "Sokoltsov",
      "description": "Software Engineer",
      "location": "Saint-Petersburg",
      "attachment": null
      }
    }
  }
}

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

Creates new direction

Request parameters

  • title - type: string - name of direction
  • description - type: text - direction's description

Response parameters

  • id - type: integer - id of direction
  • title - type: string - name of direction
  • description - type: text - direction's description
  • percents_result - type: float - relation between finished and unfinished steps for direction
  • steps - type: array - list of directions steps
  • user - type: json - user information object
  • user.attachment - type: json - user avatar information

Errors

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

Request example

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

Success response example

{
  "direction": {
    "id": 1601,
    "title": "New direction",
    "description": "New direction description",
    "percents_result": null,
    "steps": [],
    "user": {
      "id": 1063,
      "nick": "ololosh",
      "first_name": null,
      "last_name": null,
      "description": null,
      "location": null
    }
  }
}

Failed response example

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

PUT /api/v1/users/:user_id/directions/:direction_id

Update directions information

Request parameters

  • title - type: string - name of direction
  • description - type: text - direction's description

Response parameters

  • id - type: integer - id of direction
  • title - type: string - name of direction
  • description - type: text - direction's description
  • percents_result - type: float - relation between finished and unfinished steps for direction
  • steps - type: array - list of directions steps
  • user - type: json - user information object
  • user.attachment - type: json - user avatar information

Errors

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

Request example

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

Success response example

{
  "direction": {
    "id": 1601,
    "title": "New direction",
    "description": "New direction description",
    "percents_result": null,
    "steps": [],
    "user": {
      "id": 1063,
      "nick": "ololosh",
      "first_name": null,
      "last_name": null,
      "description": null,
      "location": null
    }
  }
}

Failed response example

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

Clone this wiki locally