Introduction
+API documentation for Coderockr backend test project
+ +This documentation aims to provide all the information you need to work with our API.
+ + +Authenticating requests
+This API is not authenticated.
+ +Endpoints
+ + + +Display a listing of the resource.
+ ++
+ + + + +Example request:+ + +
curl --request GET \
+ --get "http://localhost:8100/api/v1/persons" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/persons"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "GET",
+ headers,
+}).then(response => response.json());
++Example response (200):
+
+ Show headers +
+cache-control: no-cache, private
+content-type: application/json
+x-ratelimit-limit: 60
+x-ratelimit-remaining: 59
+access-control-allow-origin: *
+
+
+{
+ "data": [
+ {
+ "id": 1,
+ "first_name": "Daniel",
+ "last_name": "Soares",
+ "ssn": "123456",
+ "email": "danielcarlossoares@gmail.com",
+ "created_at": "2022-11-22T14:54:52.000000Z",
+ "updated_at": "2022-11-22T14:54:52.000000Z",
+ "links": {
+ "view": "http://localhost:8100/api/v1/persons/1"
+ }
+ }
+ ]
+}
+
+
+
+ Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Store a newly created resource in storage.
+ ++
+ + + + +Example request:+ + +
curl --request POST \
+ "http://localhost:8100/api/v1/persons" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json" \
+ --data "{
+ \"first_name\": \"nisi\",
+ \"last_name\": \"est\",
+ \"ssn\": \"32\",
+ \"email\": \"glen67@example.com\"
+}"
+
const url = new URL(
+ "http://localhost:8100/api/v1/persons"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+let body = {
+ "first_name": "nisi",
+ "last_name": "est",
+ "ssn": "32",
+ "email": "glen67@example.com"
+};
+
+fetch(url, {
+ method: "POST",
+ headers,
+ body: JSON.stringify(body),
+}).then(response => response.json());
Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Display the specified resource.
+ ++
+ + + + +Example request:+ + +
curl --request GET \
+ --get "http://localhost:8100/api/v1/persons/1" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/persons/1"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "GET",
+ headers,
+}).then(response => response.json());
++Example response (200):
+
+ Show headers +
+cache-control: no-cache, private
+content-type: application/json
+x-ratelimit-limit: 60
+x-ratelimit-remaining: 58
+access-control-allow-origin: *
+
+
+{
+ "data": {
+ "id": 1,
+ "first_name": "Daniel",
+ "last_name": "Soares",
+ "ssn": "123456",
+ "email": "danielcarlossoares@gmail.com",
+ "created_at": "2022-11-22T14:54:52.000000Z",
+ "updated_at": "2022-11-22T14:54:52.000000Z",
+ "links": {
+ "view": "http://localhost:8100/api/v1/persons/1"
+ },
+ "investments": [
+ {
+ "id": 1,
+ "description": "Default Investment",
+ "created_at": "2022-03-10T16:15:00.000000Z",
+ "withdrawn_at": "2022-11-22T10:50:00.000000Z",
+ "is_withdrawn": 1,
+ "initial_investment": "13000.00",
+ "balance": 550.75,
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/1",
+ "movements": "http://localhost:8100/api/v1/investments/1/movements"
+ }
+ },
+ {
+ "id": 2,
+ "description": "Default Investment",
+ "created_at": "2022-11-10T16:15:00.000000Z",
+ "withdrawn_at": null,
+ "is_withdrawn": 0,
+ "initial_investment": "3000.00",
+ "balance": 3000,
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/2",
+ "movements": "http://localhost:8100/api/v1/investments/2/movements"
+ }
+ }
+ ]
+ }
+}
+
+
+
+ Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Update the specified resource in storage.
+ ++
+ + + + +Example request:+ + +
curl --request PUT \
+ "http://localhost:8100/api/v1/persons/1" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json" \
+ --data "{
+ \"ssn\": \"1146777\",
+ \"email\": \"anderson.mikel@example.com\"
+}"
+
const url = new URL(
+ "http://localhost:8100/api/v1/persons/1"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+let body = {
+ "ssn": "1146777",
+ "email": "anderson.mikel@example.com"
+};
+
+fetch(url, {
+ method: "PUT",
+ headers,
+ body: JSON.stringify(body),
+}).then(response => response.json());
Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Remove the specified resource from storage.
+ ++
+ + + + +Example request:+ + +
curl --request DELETE \
+ "http://localhost:8100/api/v1/persons/1" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/persons/1"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "DELETE",
+ headers,
+}).then(response => response.json());
Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ GET api/v1/persons/{id}/investments
+ ++
+ + + + +Example request:+ + +
curl --request GET \
+ --get "http://localhost:8100/api/v1/persons/1/investments" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/persons/1/investments"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "GET",
+ headers,
+}).then(response => response.json());
++Example response (200):
+
+ Show headers +
+cache-control: no-cache, private
+content-type: application/json
+x-ratelimit-limit: 60
+x-ratelimit-remaining: 57
+access-control-allow-origin: *
+
+
+[
+ {
+ "data": [
+ {
+ "id": 1,
+ "description": "Default Investment",
+ "created_at": "2022-03-10T16:15:00.000000Z",
+ "withdrawn_at": "2022-11-22T10:50:00.000000Z",
+ "is_withdrawn": 1,
+ "initial_investment": "13000.00",
+ "balance": 550.75,
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/1",
+ "movements": "http://localhost:8100/api/v1/investments/1/movements"
+ }
+ },
+ {
+ "id": 2,
+ "description": "Default Investment",
+ "created_at": "2022-11-10T16:15:00.000000Z",
+ "withdrawn_at": null,
+ "is_withdrawn": 0,
+ "initial_investment": "3000.00",
+ "balance": 3000,
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/2",
+ "movements": "http://localhost:8100/api/v1/investments/2/movements"
+ }
+ }
+ ],
+ "links": {
+ "first": "http://localhost:8100/api/v1/persons/1/investments?page=1",
+ "last": "http://localhost:8100/api/v1/persons/1/investments?page=1",
+ "prev": null,
+ "next": null
+ },
+ "meta": {
+ "current_page": 1,
+ "from": 1,
+ "last_page": 1,
+ "links": [
+ {
+ "url": null,
+ "label": "pagination.previous",
+ "active": false
+ },
+ {
+ "url": "http://localhost:8100/api/v1/persons/1/investments?page=1",
+ "label": "1",
+ "active": true
+ },
+ {
+ "url": null,
+ "label": "pagination.next",
+ "active": false
+ }
+ ],
+ "path": "http://localhost:8100/api/v1/persons/1/investments",
+ "per_page": 5,
+ "to": 2,
+ "total": 2
+ }
+ }
+]
+
+
+
+ Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Display a listing of the resource.
+ ++
+ + + + +Example request:+ + +
curl --request GET \
+ --get "http://localhost:8100/api/v1/investments" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/investments"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "GET",
+ headers,
+}).then(response => response.json());
++Example response (200):
+
+ Show headers +
+cache-control: no-cache, private
+content-type: application/json
+x-ratelimit-limit: 60
+x-ratelimit-remaining: 56
+access-control-allow-origin: *
+
+
+{
+ "investments": [
+ {
+ "id": 1,
+ "description": "Default Investment",
+ "created_at": "2022-03-10T16:15:00.000000Z",
+ "withdrawn_at": "2022-11-22T10:50:00.000000Z",
+ "is_withdrawn": 1,
+ "initial_investment": "13000.00",
+ "balance": 550.75,
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/1",
+ "movements": "http://localhost:8100/api/v1/investments/1/movements"
+ }
+ },
+ {
+ "id": 2,
+ "description": "Default Investment",
+ "created_at": "2022-11-10T16:15:00.000000Z",
+ "withdrawn_at": null,
+ "is_withdrawn": 0,
+ "initial_investment": "3000.00",
+ "balance": 3000,
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/2",
+ "movements": "http://localhost:8100/api/v1/investments/2/movements"
+ }
+ }
+ ]
+}
+
+
+
+ Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Store a newly created resource in storage.
+ ++
+ + + + +Example request:+ + +
curl --request POST \
+ "http://localhost:8100/api/v1/investments" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json" \
+ --data "{
+ \"person_id\": \"unde\",
+ \"description\": \"qui\",
+ \"gain\": \"soluta\",
+ \"created_at\": \"1998-02-04\",
+ \"initial_investment\": 9.6449357
+}"
+
const url = new URL(
+ "http://localhost:8100/api/v1/investments"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+let body = {
+ "person_id": "unde",
+ "description": "qui",
+ "gain": "soluta",
+ "created_at": "1998-02-04",
+ "initial_investment": 9.6449357
+};
+
+fetch(url, {
+ method: "POST",
+ headers,
+ body: JSON.stringify(body),
+}).then(response => response.json());
Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Display the specified resource.
+ ++
+ + + + +Example request:+ + +
curl --request GET \
+ --get "http://localhost:8100/api/v1/investments/1" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/investments/1"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "GET",
+ headers,
+}).then(response => response.json());
++Example response (200):
+
+ Show headers +
+cache-control: no-cache, private
+content-type: application/json
+x-ratelimit-limit: 60
+x-ratelimit-remaining: 55
+access-control-allow-origin: *
+
+
+{
+ "data": {
+ "id": 1,
+ "description": "Default Investment",
+ "created_at": "2022-03-10T16:15:00.000000Z",
+ "withdrawn_at": "2022-11-22T10:50:00.000000Z",
+ "is_withdrawn": 1,
+ "initial_investment": "13000.00",
+ "balance": 550.75,
+ "owner": {
+ "id": 1,
+ "first_name": "Daniel",
+ "last_name": "Soares",
+ "ssn": "123456",
+ "email": "danielcarlossoares@gmail.com",
+ "created_at": "2022-11-22T14:54:52.000000Z",
+ "updated_at": "2022-11-22T14:54:52.000000Z",
+ "links": {
+ "view": "http://localhost:8100/api/v1/persons/1"
+ }
+ },
+ "movements": [
+ {
+ "id": 10,
+ "investment_id": 1,
+ "description": "Initial Investment Amount",
+ "value": "13000.00",
+ "type": "1"
+ },
+ {
+ "id": 11,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "67.60",
+ "type": "2"
+ },
+ {
+ "id": 12,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "67.95",
+ "type": "2"
+ },
+ {
+ "id": 13,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "68.30",
+ "type": "2"
+ },
+ {
+ "id": 14,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "68.66",
+ "type": "2"
+ },
+ {
+ "id": 15,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "69.02",
+ "type": "2"
+ },
+ {
+ "id": 16,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "69.38",
+ "type": "2"
+ },
+ {
+ "id": 17,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "69.74",
+ "type": "2"
+ },
+ {
+ "id": 18,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "70.10",
+ "type": "2"
+ },
+ {
+ "id": 19,
+ "investment_id": 1,
+ "description": "Withdrawn Taxes",
+ "value": "123.92",
+ "type": "3"
+ },
+ {
+ "id": 20,
+ "investment_id": 1,
+ "description": "Withdrawn",
+ "value": "13426.83",
+ "type": "4"
+ }
+ ],
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/1",
+ "movements": "http://localhost:8100/api/v1/investments/1/movements"
+ }
+ }
+}
+
+
+
+ Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Update the specified resource in storage.
+ ++
+ + + + +Example request:+ + +
curl --request PUT \
+ "http://localhost:8100/api/v1/investments/1" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json" \
+ --data "{
+ \"created_at\": \"2010-10-12\",
+ \"initial_investment\": 482.4504598
+}"
+
const url = new URL(
+ "http://localhost:8100/api/v1/investments/1"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+let body = {
+ "created_at": "2010-10-12",
+ "initial_investment": 482.4504598
+};
+
+fetch(url, {
+ method: "PUT",
+ headers,
+ body: JSON.stringify(body),
+}).then(response => response.json());
Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Remove the specified resource from storage.
+ ++
+ + + + +Example request:+ + +
curl --request DELETE \
+ "http://localhost:8100/api/v1/investments/1" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/investments/1"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "DELETE",
+ headers,
+}).then(response => response.json());
Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ Display a listing of the resource.
+ ++
+ + + + +Example request:+ + +
curl --request GET \
+ --get "http://localhost:8100/api/v1/investments/1/movements" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json"
const url = new URL(
+ "http://localhost:8100/api/v1/investments/1/movements"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+fetch(url, {
+ method: "GET",
+ headers,
+}).then(response => response.json());
++Example response (200):
+
+ Show headers +
+cache-control: no-cache, private
+content-type: application/json
+x-ratelimit-limit: 60
+x-ratelimit-remaining: 54
+access-control-allow-origin: *
+
+
+{
+ "investment": {
+ "id": 1,
+ "description": "Default Investment",
+ "created_at": "2022-03-10T16:15:00.000000Z",
+ "withdrawn_at": "2022-11-22T10:50:00.000000Z",
+ "is_withdrawn": 1,
+ "initial_investment": "13000.00",
+ "balance": 550.75,
+ "links": {
+ "view": "http://localhost:8100/api/v1/investments/1",
+ "movements": "http://localhost:8100/api/v1/investments/1/movements"
+ }
+ },
+ "movements": [
+ {
+ "id": 10,
+ "investment_id": 1,
+ "description": "Initial Investment Amount",
+ "value": "13000.00",
+ "type": "1"
+ },
+ {
+ "id": 11,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "67.60",
+ "type": "2"
+ },
+ {
+ "id": 12,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "67.95",
+ "type": "2"
+ },
+ {
+ "id": 13,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "68.30",
+ "type": "2"
+ },
+ {
+ "id": 14,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "68.66",
+ "type": "2"
+ },
+ {
+ "id": 15,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "69.02",
+ "type": "2"
+ },
+ {
+ "id": 16,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "69.38",
+ "type": "2"
+ },
+ {
+ "id": 17,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "69.74",
+ "type": "2"
+ },
+ {
+ "id": 18,
+ "investment_id": 1,
+ "description": "Investment Gain",
+ "value": "70.10",
+ "type": "2"
+ },
+ {
+ "id": 19,
+ "investment_id": 1,
+ "description": "Withdrawn Taxes",
+ "value": "123.92",
+ "type": "3"
+ },
+ {
+ "id": 20,
+ "investment_id": 1,
+ "description": "Withdrawn",
+ "value": "13426.83",
+ "type": "4"
+ }
+ ]
+}
+
+
+
+ Received response: ++
+
+
+ Request failed with error:+
+
+
+
+ PATCH api/v1/investments/{id}/withdrawn
+ ++
+ + + + +Example request:+ + +
curl --request PATCH \
+ "http://localhost:8100/api/v1/investments/1/withdrawn" \
+ --header "Content-Type: application/json" \
+ --header "Accept: application/json" \
+ --data "{
+ \"withdrawn_at\": \"2022-11-22 21:17:55\"
+}"
+
const url = new URL(
+ "http://localhost:8100/api/v1/investments/1/withdrawn"
+);
+
+const headers = {
+ "Content-Type": "application/json",
+ "Accept": "application/json",
+};
+
+let body = {
+ "withdrawn_at": "2022-11-22 21:17:55"
+};
+
+fetch(url, {
+ method: "PATCH",
+ headers,
+ body: JSON.stringify(body),
+}).then(response => response.json());
Received response: ++
+
+
+ Request failed with error:+
+
+
+
+
+
+
+