##API REST WITH KOTLIN AND SPRING BOOT

GET

Url: http://localhost:8080/customers

Response (Status Code: 200 Ok)

{
    "_embedded": {

        "customers": [
            {
                "firstName": "Felipe",
                "lastName": "Baz",
                "email": "[email protected]",
                "documentNumber": "123",
                "documentType": "CPF",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/customers/1"
                    },
                    "customer": {
                        "href": "http://localhost:8080/customers/1"
                    }
                }
            },
            {
                "firstName": "João",
                "lastName": "Baz",
                "email": "Joã[email protected]",
                "documentNumber": "1234",
                "documentType": "RG",
                "_links": {
                    "self": {
                        "href": "http://localhost:8080/customers/2"
                    },
                    "customer": {
                        "href": "http://localhost:8080/customers/2"
                    }
                }
            }
        ]
    },
    "_links": {
        "self": {
            "href": "http://localhost:8080/customers"
        },
        "profile": {
            "href": "http://localhost:8080/profile/customers"
        }
    },
    "page": {
        "size": 20,
        "totalElements": 2,
        "totalPages": 1,
        "number": 0
    }
}

POST

Url: http://localhost:8080/customers

Body

{
    "firstName": "Henrique",
    "lastName": "Baz",
    "documentNumber": "1234",
    "documentType": "RG",
    "email": "[email protected]"
}

Response (Status Code: 201 Created)

{
    "firstName": "Henrique",
    "lastName": "Baz",
    "email": "[email protected]",
    "documentNumber": "1234",
    "documentType": "RG",
    "_links": {
        "self": {
            "href": "http://localhost:8080/customers/3"
        },
        "customer": {
            "href": "http://localhost:8080/customers/3"
        }
    }
}

PUT

Url: http://localhost:8080/customers/{Id}

Body

{
    "firstName": "João",
    "lastName": "Baz",
    "documentNumber": "1234",
    "documentType": "RG",
    "email": "Joã[email protected]"
}

Response (Status Code: 200 Ok)

{
    "firstName": "João",
    "lastName": "Baz",
    "email": "Joã[email protected]",
    "documentNumber": "1234",
    "documentType": "RG",
    "_links": {
        "self": {
            "href": "http://localhost:8080/customers/2"
        },
        "customer": {
            "href": "http://localhost:8080/customers/2"
        }
    }
}

Delete

Url: http://localhost:8080/customers/{Id}

Response (Status Code: 204 No Content)

GitHub

View Github