Skip to content

Latest commit

 

History

History
432 lines (312 loc) · 7.68 KB

user.md

File metadata and controls

432 lines (312 loc) · 7.68 KB
title language_tabs language_clients toc_footers includes search highlight_theme headingLevel
User service v0.0.1
shell
Shell
javascript
JavaScript
shell
javascript
true
darkula
2

User service v0.0.1

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

Because we need users

Base URLs:

License: Apache 2.0

user

users informations and manipulations

getAllUsers

Code samples

# You can also use wget
curl -X GET http://127.0.0.1:3333/users \
  -H 'Accept: application/json'
const headers = {
  'Accept':'application/json'
};

fetch('http://127.0.0.1:3333/users',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /users

List of all users

Example responses

200 Response

[
  {
    "id": 0,
    "username": "string",
    "statut": "string",
    "score": 0,
    "password": "string"
  }
]

Responses

Status Meaning Description Schema
200 OK successful operation Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
anonymous [User] false none [a user]
» user User false none a user
»» id integer(int64) false none id of the user
»» username string(text) false none name of the user
»» statut string false none status of the user
»» score integer(number) false none score of the player
»» password string(text) false none password of the user
This operation does not require authentication

createUser

Code samples

# You can also use wget
curl -X POST http://127.0.0.1:3333/users \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'
const inputBody = '{
  "id": 0,
  "username": "string",
  "statut": "string",
  "score": 0,
  "password": "string"
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json'
};

fetch('http://127.0.0.1:3333/users',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /users

Add a new user

Body parameter

{
  "id": 0,
  "username": "string",
  "statut": "string",
  "score": 0,
  "password": "string"
}

Parameters

Name In Type Required Description
body body User true none

Example responses

201 Response

{
  "id": 0,
  "username": "string",
  "statut": "string",
  "score": 0,
  "password": "string"
}

Responses

Status Meaning Description Schema
201 Created Created User
409 Conflict unsuccessful operation None
This operation does not require authentication

connectUser

Code samples

# You can also use wget
curl -X POST http://127.0.0.1:3333/auth/connect?username=string&password=string \
  -H 'Accept: application/json'
const headers = {
  'Accept':'application/json'
};

fetch('http://127.0.0.1:3333/auth/connect?username=string&password=string',
{
  method: 'POST',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /auth/connect

Connect the user

Parameters

Name In Type Required Description
username query string true none
password query string true none

Example responses

200 Response

"string"

Responses

Status Meaning Description Schema
200 OK Authentificated, return the token string
401 Unauthorized wrong credentials None
This operation does not require authentication

getUserById

Code samples

# You can also use wget
curl -X GET http://127.0.0.1:3333/users/{id} \
  -H 'Accept: application/json'
const headers = {
  'Accept':'application/json'
};

fetch('http://127.0.0.1:3333/users/{id}',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /users/{id}

Retrieves a specific user

Parameters

Name In Type Required Description
id path integer true The user ID

Example responses

200 Response

{
  "id": 0,
  "username": "string",
  "statut": "string",
  "score": 0,
  "password": "string"
}

Responses

Status Meaning Description Schema
200 OK successful operation User
401 Unauthorized invalid credentials None
This operation does not require authentication

internal

incrementUserScore

Code samples

# You can also use wget
curl -X PUT http://127.0.0.1:3333/internal/users/{id}/increment-score \
  -H 'Accept: application/json'
const headers = {
  'Accept':'application/json'
};

fetch('http://127.0.0.1:3333/internal/users/{id}/increment-score',
{
  method: 'PUT',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

PUT /internal/users/{id}/increment-score

Increment the score of a user by 1

Parameters

Name In Type Required Description
id path integer true The user ID

Example responses

200 Response

{
  "id": 0,
  "username": "string",
  "statut": "string",
  "score": 0,
  "password": "string"
}

Responses

Status Meaning Description Schema
200 OK successful operation User
404 Not Found user not found None
This operation does not require authentication

Schemas

User

{
  "id": 0,
  "username": "string",
  "statut": "string",
  "score": 0,
  "password": "string"
}

user

Properties

Name Type Required Restrictions Description
id integer(int64) false none id of the user
username string(text) false none name of the user
statut string false none status of the user
score integer(number) false none score of the player
password string(text) false none password of the user