Skip to content
Vadim Sokoltsov edited this page Nov 13, 2016 · 1 revision

GET /api/v1/users/:id

Show users information

Request parameters

  • id - type: integer - user's id or nick

Response parameters

  • id - type: integer - id or slug of direction
  • nick - type: string - user's nickname in system
  • first_name - type: string - user's first name
  • last_name - type: string - user's last name
  • description - type: text - user's own description
  • location - type: string - user's location information
  • finished_directions - type: array - user's finished directions
  • new_directions - type: array - user's new directions
  • recent_actions - type: array - last logged user actions
  • attachment - type: json - user's avatar

Response example

{
  "user": {
    "id": 22,
    "nick": "vforvad",
    "first_name": "Vadim",
    "last_name": "Sokoltsov",
    "description": "Software Engineer",
    "location": "Saint-Petersburg",
    "finished_directions": [],
    "new_directions": [
      {
        "id": 329,
        "title": "Rails 41",
        "description": "Rails 4 description",
        "created_at": "2016-10-23T14:33:00.543Z",
        "updated_at": "2016-10-23T14:38:03.599Z",
        "user_id": 22,
        "slug": "rails_41"
      },
      ...
    ],
    "recent_actions": {
      "2016-11-13": [
        {
          "id": 430,
          "user_id": 22,
          "operation": "create",
          "data": {
            "klass": "Step",
            "attributes": {
              "id": 2054,
              "title": "Step 3",
              "is_done": null,
              "created_at": "2016-11-13T12:47:08.504Z",
              "updated_at": "2016-11-13T12:47:08.504Z",
              "description": "Step 3 descripion",
              "direction_id": 329
            }
          },
          "created_at": "2016-11-13T12:47:08.509Z",
          "updated_at": "2016-11-13T12:47:08.509Z"
        },
        ...
      ]
    },
    "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
      },
      {
        "id": 320,
        "title": "Ansible",
        "description": "Ansible description",
        "percents_result": 66
      },
      {
        "id": 319,
        "title": "Docker",
        "description": "Docker description",
        "percents_result": null
      },
      {
        "id": 318,
        "title": "Javascript",
        "description": "Javascript description",
        "percents_result": null
      }
    ],
    "attachment": {
      "id": 28,
      "attachable_id": 22,
      "attachable_type": "User",
      "created_at": "2016-10-20T20:31:02.781Z",
      "url": "https://uprogres.s3-us-west-1.amazonaws.com/uploads/8lySnANAXps.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJDWCSTWFAGL6DRVA%2F20161113%2Fus-west-1%2Fs3%2Faws4_request&X-Amz-Date=20161113T210140Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=ed0410cac07a6227d6edd956ea29a99aa2aeb4ccbaef4b52ee78f11503657d0a"
    }
  }
}

GET /api/v1/users/:id/statistics

Request parameters

  • id - type: integer - user's id or nick

Response parameters

  • directions - type: array - list of directions available values
  • steps - type: array - list of steps available values
  • direction_steps - type: array - list of direction_steps available values

Example response

{
  "statistics": {
    "directions": [
      {
        "label": "In progress",
        "value": 33.33333333333333,
        "color": "#3366CC"
      },
      {
        "label": "New directions",
        "value": 50,
        "color": "#DC3912"
      },
      {
        "label": "Finished directions",
        "value": 0,
        "color": "#FF9900"
      }
    ],
    "steps": [
      {
        "label": "In progress",
        "color": "#FF9900",
        "value": 33.33
      },
      {
        "label": "Cancelled",
        "color": "#DC3912",
        "value": 33.33
      },
      {
        "label": "Finished",
        "color": "#3366CC",
        "value": 33.33
      }
    ],
    "directions_steps": [
      {
        "label": "Another direction",
        "color": "#16d260",
        "value": 0
      },
      {
        "label": "Rails 41",
        "color": "#401098",
        "value": 33.33
      },
      {
        "label": "adaw",
        "color": "#6e4bd0",
        "value": 16.67
      },
      {
        "label": "Ansible",
        "color": "#97b386",
        "value": 50
      },
      {
        "label": "Docker",
        "color": "#6bae8e",
        "value": 0
      },
      {
        "label": "Javascript",
        "color": "#10053c",
        "value": 0
      }
    ]
  }
}

PUT /api/v1/users/:id

Updates user information

Request parameters

  • id - type: integer - user's id or nick
  • nick - type: string - user's nickname in system
  • first_name - type: string - user's first name
  • last_name - type: string - user's last name
  • description - type: text - user's own description
  • location - type: string - user's location information
  • attachment - type: json - user's avatar

Response parameters

  • id - type: integer - id or slug of direction
  • nick - type: string - user's nickname in system
  • first_name - type: string - user's first name
  • last_name - type: string - user's last name
  • description - type: text - user's own description
  • location - type: string - user's location information
  • finished_directions - type: array - user's finished directions
  • new_directions - type: array - user's new directions
  • recent_actions - type: array - last logged user actions
  • attachment - type: json - user's avatar

Errors

  • empty user object - Something gone wrong. Please, try again later
  • email - can't be blank
  • first_name - can't be blank
  • last_name - can't be blank

Success response example

{
  "current_user": {
    "id": 1,
    "email": "batman@superman.com",
    "nick": "Tanya",
    "first_name": "1",
    "last_name": "2",
    "description": null,
    "location": null,
    "attachment": null
  }
}

Failed response example

{
  "errors": {
    "email": [
      "can't be blank"
    ],
    "first_name": [
      "can't be blank"
    ],
    "last_name": [
      "can't be blank"
    ]
  }
}

Clone this wiki locally