Skip to content

Latest commit

 

History

History
842 lines (665 loc) · 13.8 KB

matchmaking.md

File metadata and controls

842 lines (665 loc) · 13.8 KB
title language_tabs language_clients toc_footers includes search highlight_theme headingLevel
Matchmaking service v0.0.1
shell
Shell
javascript
JavaScript
shell
javascript
true
darkula
2

Matchmaking 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 machmatking

Base URLs:

License: Apache 2.0

Authentication

  • HTTP Authentication, scheme: bearer

matches

Everything related to a match

getAllMatches

Code samples

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

fetch('http://127.0.0.1:3334/matchs',
{
  method: 'GET',

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

GET /matchs

Get all matches

Example responses

200 Response

[
  "string"
]

Responses

Status Meaning Description Schema
200 OK successful operation Inline

Response Schema

Status Code 200

Array of matches id

Name Type Required Restrictions Description
This operation does not require authentication

createMatch

Code samples

# You can also use wget
curl -X PUT http://127.0.0.1:3334/matchs \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
const inputBody = '{
  "opponentId": 0,
  "deck": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ]
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

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

PUT /matchs

Create a match

Body parameter

{
  "opponentId": 0,
  "deck": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ]
}

Parameters

Name In Type Required Description
body body CreateMatchDto false Match to create

Example responses

200 Response

{
  "id": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "authorPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "opponentPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "authorId": 0,
  "opponentId": 0,
  "status": "waitingInvite",
  "winnerId": null
}

Responses

Status Meaning Description Schema
200 OK successful operation MatchDto
400 Bad Request An error caused by the client Inline

Response Schema

Status Code 400

Name Type Required Restrictions Description
anonymous [AppError] false none none
» code integer(int32) true none Error code
» message string true none Error message
To perform this operation, you must be authenticated by means of one of the following methods: bearerAuth

getMatchById

Code samples

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

fetch('http://127.0.0.1:3334/matchs/{id}',
{
  method: 'GET',

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

GET /matchs/{id}

Get a match by id

Parameters

Name In Type Required Description
id path integer true Id of the match

Example responses

200 Response

{
  "id": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "authorPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "opponentPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "authorId": 0,
  "opponentId": 0,
  "status": "waitingInvite",
  "winnerId": null
}

Responses

Status Meaning Description Schema
200 OK successful operation MatchDto
This operation does not require authentication

getAllMatchesWaitingForInvitation

Code samples

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

fetch('http://127.0.0.1:3334/matchs/invitation',
{
  method: 'GET',

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

GET /matchs/invitation

Get all matches that are waiting for an invitation for the connected player

Example responses

200 Response

[
  {
    "id": 0,
    "authorId": "string"
  }
]

Responses

Status Meaning Description Schema
200 OK successful operation Inline

Response Schema

Status Code 200

Array of awaiting matches

Name Type Required Restrictions Description
» id integer true none The id of the match
» authorId string false none The id of the player opponent
This operation does not require authentication

joinMatch

Code samples

# You can also use wget
curl -X POST http://127.0.0.1:3334/matchs/{id}/join \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
const inputBody = '[
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
]';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

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

POST /matchs/{id}/join

Join a match

Body parameter

[
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
]

Parameters

Name In Type Required Description
id path integer true Id of the match
body body DeckDto false Deck

Example responses

200 Response

{
  "id": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "authorPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "opponentPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "authorId": 0,
  "opponentId": 0,
  "status": "waitingInvite",
  "winnerId": null
}

Responses

Status Meaning Description Schema
200 OK successful operation MatchDto
400 Bad Request An error caused by the client Inline

Response Schema

Status Code 400

Name Type Required Restrictions Description
anonymous [AppError] false none none
» code integer(int32) true none Error code
» message string true none Error message
To perform this operation, you must be authenticated by means of one of the following methods: bearerAuth

internal

For internal communication

closeMatch

Code samples

# You can also use wget
curl -X POST http://127.0.0.1:3334/internal/matches/{id}/close \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'
const inputBody = '{
  "winnerId": 0
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json'
};

fetch('http://127.0.0.1:3334/internal/matches/{id}/close',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /internal/matches/{id}/close

Close a match

Body parameter

{
  "winnerId": 0
}

Parameters

Name In Type Required Description
id path integer true Id of the match
body body any false Post match winner and close it

Example responses

200 Response

{
  "id": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "authorPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "opponentPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "authorId": 0,
  "opponentId": 0,
  "status": "waitingInvite",
  "winnerId": null
}

Responses

Status Meaning Description Schema
200 OK successful operation MatchDto
400 Bad Request An error caused by the client Inline

Response Schema

Status Code 400

Name Type Required Restrictions Description
anonymous [AppError] false none none
» code integer(int32) true none Error code
» message string true none Error message
This operation does not require authentication

Schemas

DeckDto

[
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
]

Deck of the player

Properties

Name Type Required Restrictions Description
anonymous [PokemonID] false none Deck of the player

CreateMatchDto

{
  "opponentId": 0,
  "deck": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ]
}

Properties

Name Type Required Restrictions Description
opponentId integer true none Id of the opponent
deck [PokemonID] false none Deck of the player

MatchDto

{
  "id": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "authorPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "opponentPokemons": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ],
  "authorId": 0,
  "opponentId": 0,
  "status": "waitingInvite",
  "winnerId": null
}

Properties

Name Type Required Restrictions Description
id integer true none The id of the match
createdAt string(date-time) true none The date of the creation
updatedAt string(date-time) true none The date of the last update
authorPokemons [integer] true none The pokemons ids of the author
opponentPokemons [integer] false none The pokemons ids of the opponent
authorId integer true none The id of the author
opponentId integer true none The id of the opponent
status string true none The status of the match
winnerId integer false none The id of the winner. If the winner is a draw, the winnerId is null and the match status is set to finished

Enumerated Values

Property Value
status waitingInvite
status started
status finished

PokemonID

0

Properties

Name Type Required Restrictions Description
anonymous integer false none none

AppError

{
  "code": 0,
  "message": "Internal error"
}

Properties

Name Type Required Restrictions Description
code integer(int32) true none Error code
message string true none Error message