---
# System prepended metadata

title: MeApunto endpoints

---

# MeApunto endpoints

### POST /login


##### Request
```
{
    username: 'asdf',
    password: 'asdf',
}
```

##### Response
```
{
    refresh: '12asdf',
    access: 'qwasdf',
}
```

### POST /register

##### Request
```
{
    picture: '',
    firstName: '',
    lastName: '',
    username: '',
    email: '',
    phone: '',
    password: '',
    positions: ['DEF', 'ARQ'],
    gender: 'M',
    leg: 'D'
}
```

##### Response
```
{
    refresh: '12asdf',
    access: 'qwasdf',
}
```

### GET /statics


##### Response
```
{ 
    legs: [
        { id: 1, description: "izquierda" } 
    ],
    players: [
        { id: 1, description: "11-11", formationId: 1 }
    ],
    hours: [
        { id: 1, description: "8:00" }
    ], 
    minPrice: 0,
    maxPrice: 200,
    positions: [
        { id: 1, description: "Delantero" }
    ],
    hoursRange: [
        {id: 1, description: '8:00 - 9:00'}
    ],
    genders: [
        {id: 1, 'Solo hombres'},
        {id: 2, 'Solo mujeres'},
        {id: 3, 'Mixto'}
    ],
    formations: [
        {
        id: 1,
        //del arco hacia el medio campo
        formation: [1, 4, 4, 2]
            //un arquero, 4 defensas, 4 mediocampo, 2 delanteros
        }
    ]
}
```

### GET /business/{businessId}

##### Response

```
{ 
    id: 1, 
    address: 'asdf', 
    images: [ 'imageUrl1', 'imageUrl2'], 
    name: 'name', 
    description: 'asdf', 
    liked: false, 
    stadiums: [ 
        { 
            id: 2, 
            name: 'name1', 
            playersId: 1, 
            price: 120,
        }
    ]
}
```

### GET /friends

##### Request
URL params
```
?cursor={cursor}&first={pageSize}&query={query}&gender={genderId}
```

##### Response
```
{
    pageInfo: {
        hasNextPage: true, 
        endCursor: 11
    },
    results:[
        { id: 1, firstName: 'juan carlos', lastName: 'jara', positionId: 1, picture: ''}
    ] 
}

```

### GET /groups

#### Request
URL params
```
?cursor={cursor}&first={pageSize}&query={query}
```

#### Response

```
{
    pageInfo: {
        hasNextPage: true, 
        endCursor: 11
    },
    results:[
        { 
            id: 1, 
            name: 'group name',
            //user ids
            members: [
                { id: 1},
                { id: 2},
            ] 
        }
    ] 
}
```

### GET /users
all users but me

#### Request
URL params
```
?cursor={cursor}&first={pageSize}&query={query}&gender={genderId}
```

#### Response
```
{
    pageInfo: {
        hasNextPage: true, 
        endCursor: 11
    },
    results:[
        { 
            id: 1, 
            firstName: 'juan carlos', 
            lastName: 'jara', 
            positionId: 1, 
            picture: '', 
            isFriend: false | true
        }
    ] 
}
```

### GET /me

#### Response
```
{
    username: 'juancjara',
    firstName: 'Juan Carlos',
    lastName: 'Jara Loayza',
    gender: 'M',
    positions: [1, 2],
    age: 30 | undefined,
    phone: 123123 | undefined,
    email: 'juanc.jara@pucp.pe',
    picture: 'url picture',
    leg: 1,
    coins: 0,
    providerId: 123 | undefined, //Facebook id
    defaultCard: {
        id: 'asdfasdfa123asdf',
        brand: 'Visa',
        lastFour: '0001'
    } | undefined
}
```

### POST /customGame
Game without stadium

https://xd.adobe.com/view/edc14cf1-038a-4e73-4131-1f76f6a50bc1-9bf0/screen/1d8f62e4-af0b-4c87-a667-c81fb54b9f1d/iPhone-X-XS-30

#### Request

```
{
    name: '',
    address: '',
    //hour ids
    hours: [1, 2, 3],
    gender: 1,//gender id (solo hombres/ solo mujeres)
    date: '12-05-2019',
    playerId: 1,
    position: '2,1', //segunda fila primer jugador (defensa izquierdo)
    //arquero seria 0,0
    team: 1 //1 o 2 team 1 es el de arriba y team 2 el de abajo,
    inviteUsers: [1, 2, 3 ], //user ids
    inviteGroups: [1 ,2, 3] // group ids,
    openGame: true
}
```

### POST /reservation

#### Request
```
{
    date: "25-04-2019",
    hours: [1, 2],
    stadiumId: 1,
    coupon: 'ASDF' | null,
    useCoins: true | false,
    cardId: '1234'
}
````

### POST /organizeMatch (segundo flujo)

```
if goalkeeperPaysHalf is true -> payment is half
```

#### Request
```
{
    date: "25-04-2019",
    hours: [1, 2],
    stadiumId: 1,
    coupon: 'ASDF' | null,
    useCoins: true | false,
    cardId: '1234',
    gender: 'O',
    goalkeeperPaysHalf: true | false,
    position: {
        team: 1 | 2,
        x: 0,
        y: 0,
    },
    splitPayment: true | false,   
    inviteUsers: [1, 2, 3 ], //user ids
    inviteGroups: [1 ,2, 3] // group ids,
    openGame: true
}
```

### POST /cards

#### Request
```
{
    cardNumber: '0111',
    ccv: '123',
    expirationMonth: '08',
    expirationYear: '2020',
    firstName: 'jc',
    lastName: 'jara',
    phone: 123123123,
    address: '',
    addressCity: '',
    email: '',
}
```
#### Response 
```
{
    id: 'asf123',
    brand: 'Visa',
    lastFour: '0001'
}
```


### DELETE /cards/{CARD_ID}

### GET /cards

#### Response
```
[
    {
        lastFour: '1111',
        brand: 'Visa',
        id: 'a123af123'
    }
]
```

### PUT /cards/${CARD_ID}/default

setea el card como default para el usuario logeado

### GET /token/{REFRESH_TOKEN}

#### Response

```
{
    access: 'access token',
    refresh: 'refresh token'
}
```

### PUT /users

#### Request
```
{
    gender: 'M',
    age: 30,
    phone: '12313',
    positions: [1, 2],
    picture: 'url picture',
    leg: 1,
    newPassword: '******' | undefined
}
```

#### Response

```
{
    gender: 'M',
    positions: [1, 2],
    age: 30 | undefined,
    phone: 123123 | undefined,
    email: 'juanc.jara@pucp.pe',
    picture: 'url picture',
    leg: 1,
    ...
}
```

### GET /notifications/unread

#### Response

```
{
    count: 1,
}
```

### GET /notifications

#### Request

URL params
```
?cursor={cursor}&first={pageSize}&query={query}
```


#### Response

```
pageInfo: {
    hasNextPage: false,
    endCursor: 1,
},
results: 
[
    { 
        id: 1, 
        user: { 
            id: 1, 
            firstName: 'Juan Carlos',
            lastName: 'Jara'
        },
        read: false,
        type: 'GAME_INVITE',
        data: {
            gameId: '1'
        },
        dateTime: '2019-09-29 17:54:04'
    },
    { 
        id: 1, 
        user: {  // usuario creador del partido
            id: 1, 
            firstName: 'Juan Carlos',
            lastName: 'Jara'
        },
        read: false,
        type: 'CANCELED_GAME',
        data: { //datos del partido cancelado
            name: "Cancha numero 1",
            hours: [
                {id: 1,description: '8:00-9:00'},
                {id: 2,description: '9:00-10:00'}
            ],
            date: '19-09-2019', //fecha del partido

        },
        dateTime: '2019-09-29 17:54:04'
    },
    { 
        id: 1, 
        user: {  // usuario creador del partido
            id: 1, 
            firstName: 'Juan Carlos',
            lastName: 'Jara'
        },
        read: false,
        type: 'REFUNDED_GAME',
        data: { //datos del partido cancelado
            name: "Cancha numero 1",
            hours: [
                {id: 1,description: '8:00-9:00'},
                {id: 2,description: '9:00-10:00'}
            ],
            date: '19-09-2019',
            coins: 30, //monedas retornadas

        },
        dateTime: '2019-09-29 17:54:04'
    }
]
```

### PUT /notifications/{NOTIFICATION_ID}/read

### DELETE /notifications/{NOTIFICATION_ID}


### POST /coins/recharge

#### Request
```
{
    coins: 20,
    cardId: '1231',
}
```

#### Response
```
{
    coins: 100
}
```

### POST /coins/transfer

#### Request
```
{
    coins: 10,
    to: '213' // user Id
}
```
#### Response
```
{
    coins: 100
}
```

### POST /friends
#### Request
```
    {
        userId: '123'
    }
```

### DELETE /friends/{userId}

### POST /groups

#### Request 
```
{
    name: 'nombre del grupo',
    users: [1, 2] //user ids
}
```

#### Response
```
{
    id: 1, 
    name: 'group name',
    //user ids
    members: [
        { id: 1},
        { id: 2},
    ]
}
```

### PUT /groups/{groupId}
```
{
    name: 'nombre actualizado',
    users: [1, 2] //user ids
}
```

### POST /account/forgotPassword

envia correo
#### Request

```
{
    email: 'test@gmail.com'
}
```

### POST /account/forgotPassword/validate

#### Request
```
{
    code: '12314',
    email: 'test@gmail.com'
}
```

### POST /account/password

#### Request
```
{
    code: '1234',
    email: 'asdf@asf.com',
    password: 'asdfasdf'
}
```

#### Response
```
{
    access: 'access token',
    refresh: 'refresh token'
}
```

### GET /games

##### Request
URL params
```
?cursor={cursor}&first={pageSize}&query={query}&gender={genderId}&players={players}&minPrice={minPrice}&maxPrice={maxPrice}&total={true|false}
```

total = true

##### Response
```
{
    total: 33
}
```

total = false

##### Response
```
{
    results: [
        {
            id: 1,
            goalkeeperPaysHalf: true,
            name: 'cancha 1',
            picture: 'url image',
            price: 23.4,
            date: '18-09-2019',
            latitude: 34.5,
            longitude: 72.5,
            hours: [
                {id: 1, price: 14, description: '8:00-9:00'},
                {id: 2, price: 20, description: '9:00-10:00'}
            ],
            dueTime: '18-09-2019 13:40', //hora en la q se cierra el pago
            players: 1, //playersId
            availableSpots: 4 //espacios libres
        }
    ],
    pageInfo: {
        hasNextPage: false,
        endCursor: 1,
    },
}
```

### GET games/{gameId}

##### Response

```
{
    id: 1,
    stadiumId: null | 1, //id nulo si es custom game
    name: "Cancha numero 1",
    address: 'av ...',
    playersId: 1, //palyer id
    hours: [
        {id: 1, price: 14, description: '8:00-9:00'},
        {id: 2, price: 20, description: '9:00-10:00'}
    ],
    images: [ 'imageUrl1', 'imageUrl2'],
    liked: false,
    dueTime: '19-09-2019 13:40',
    date: '19-09-2019',
    availableSpots: 4,
    price: 12.4,
    goalkeeperPaysHalf: true,
    splitPayment: true,
    players: [
        {
            x: 0,
            y: 1,
            team: 1,
            user: { 
                id: 1, 
                picture: 'url', 
                username: 'user', 
                firstName: 'Juan Carlos', 
                lastName: 'Jara'
            }
        }
    ],
    team1: {
        color: 'blue',
        name: 'team A'
    },
    team2: {
        color: 'red',
        name: 'teamB'
    },
    
}
```

### POST /organizeMatch/{match_Id}/payment

#### Request
```
{
    coupon: 'ASDF' | null,
    useCoins: true | false,
    cardId: '1234',
    position: {
        team: 1 | 2,
        x: 0,
        y: 0,
    },
}
```

### GET /mygames/favorites

### GET /mygames/pending 

### GET /mygames/history

##### Request

URL params
```
?cursor={cursor}&first={pageSize}
```


##### Response
```
{
    results: [
        {
            owner: { //user que creo el partido
                id: 1,
                firstName: 'juan carlos',
                lastName: 'jara loayza'
            },
            status: 'PENDING' | 'ACCEPTED' | 'OWNER' | 'RESERVED' | 'PAID' | 'DECLINED',
            id: 1,
            goalkeeperPaysHalf: true,
            name: 'cancha 1',
            picture: 'url image',
            price: 23.4, //Precio que pague
            date: '18-09-2019',
            hours: [
                {id: 1, price: 14, description: '8:00-9:00'},
                {id: 2, price: 20, description: '9:00-10:00'}
            ],
            dueTime: '18-09-2019 13:40', //hora en la q se cierra el pago
            players: 1, //playersId
            availableSpots: 4 //espacios libres,
            canceled: true //cancelado o no
        },
    ],
    pageInfo: {
        hasNextPage: false,
        endCursor: 1,
    },
}
```

### GET mygames/{gameId}

##### Response

```
{
    openGame: true | false,
    status: 'PENDING' | 'ACCEPTED' | 'OWNER' | 'PAID' | 
'DECLINED'| 'RESERVED',
    id: 1,
    name: "Cancha numero 1",
    address: 'av ...',
    playersId: 1, //palyer id
    hours: [
        {id: 1, price: 14, description: '8:00-9:00'},
        {id: 2, price: 20, description: '9:00-10:00'}
    ],
    images: [ 'imageUrl1', 'imageUrl2'],
    liked: false,
    dueTime: '19-09-2019 13:40',
    date: '19-09-2019',
    availableSpots: 4,
    price: 12.4, //precio que se pago
    goalkeeperPaysHalf: true,
    splitPayment: true,
    players: [
        {
            x: 0,
            y: 1,
            team: 1,
            user: { 
                id: 1, 
                picture: 'url', 
                username: 'user', 
                firstName: 'Juan Carlos', 
                lastName: 'Jara'
            }
        }
    ],
    usersInvited: [1, 2,3, 4], userIds,
    groupsInvited: [{
        id: 1,
        members: [1,2,3,4]
    }]
    team1: {
        color: 'blue',
        name: 'team A'
    },
    team2: {
        color: 'red',
        name: 'teamB'
    },
    gender: 'M',
    remainingPayment: 40 //lo que falta pagar
    allPaid: true, //se pago todo o no
}
```

### POST /mygames/{gameId}/accept

### POST /mygames/{gameId}/decline

### PUT /mygames/{gameId}/invitations

```
{
    inviteUsers: [1, 2, 3 ], //user ids
    inviteGroups: [1 ,2, 3] // group ids,
    openGame: true | false
}
```


### PUT /games/{gameId}/like

##### Request
```
{
    liked: true/false
}
```


### PUT /games/{gameId}/soccerfield

##### Request

```
{
    team1: {
        color: '#FAFAFA',
        name: 'Team A'
    },
    team2: {
        color: '#BABABA',
        name: 'Team B'
    }
}
```

### POST /games/{gameId}/payAll

##### Request
```
{
    useCoins: true | false,
    cardId: '1234',
}
```


### POST /games/{gameId}/cancel

//puede retornar error si no se puede cancelar el juego