Create an Investment
curl --request POST \
--url https://cashboard-f5x2.onrender.com/investment/add \
--header 'Content-Type: application/json' \
--data '
{
"desc": "Bitcoin",
"category": "Cryptocurrency",
"account": "662fbf9eac827e370c18d4b9",
"date": "03/21/2024",
"amount": 5000
}
'import requests
url = "https://cashboard-f5x2.onrender.com/investment/add"
payload = {
"desc": "Bitcoin",
"category": "Cryptocurrency",
"account": "662fbf9eac827e370c18d4b9",
"date": "03/21/2024",
"amount": 5000
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
desc: 'Bitcoin',
category: 'Cryptocurrency',
account: '662fbf9eac827e370c18d4b9',
date: '03/21/2024',
amount: 5000
})
};
fetch('https://cashboard-f5x2.onrender.com/investment/add', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cashboard-f5x2.onrender.com/investment/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'desc' => 'Bitcoin',
'category' => 'Cryptocurrency',
'account' => '662fbf9eac827e370c18d4b9',
'date' => '03/21/2024',
'amount' => 5000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cashboard-f5x2.onrender.com/investment/add"
payload := strings.NewReader("{\n \"desc\": \"Bitcoin\",\n \"category\": \"Cryptocurrency\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"03/21/2024\",\n \"amount\": 5000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cashboard-f5x2.onrender.com/investment/add")
.header("Content-Type", "application/json")
.body("{\n \"desc\": \"Bitcoin\",\n \"category\": \"Cryptocurrency\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"03/21/2024\",\n \"amount\": 5000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cashboard-f5x2.onrender.com/investment/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"desc\": \"Bitcoin\",\n \"category\": \"Cryptocurrency\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"03/21/2024\",\n \"amount\": 5000\n}"
response = http.request(request)
puts response.read_body{
"investments": [
{
"desc": "Bitcoin",
"currentAmount": 95000,
"category": "Cryptocurrency",
"_id": "662ff8a5712cd9fd793e1fb7",
"createdAt": "2024-04-29T19:44:37.441Z",
"updatedAt": "2024-04-29T19:44:37.441Z"
},
{
"desc": "Bitcoin",
"currentAmount": 5000,
"category": "Cryptocurrency",
"_id": "662ff9e36e0d87944a3c4cf7",
"createdAt": "2024-04-29T19:49:55.065Z",
"updatedAt": "2024-04-29T19:49:55.065Z"
},
{
"desc": "Bitcoin",
"currentAmount": 5000,
"category": "Cryptocurrency",
"_id": "662ffab8df4fbf42a526c6d5",
"createdAt": "2024-04-29T19:53:28.755Z",
"updatedAt": "2024-04-29T19:53:28.755Z"
}
]
}{
"status": "error",
"message": "Investment could not be added!"
}Investments
Create an Investment
This endpoint is used to create an investment.
Endpoint: https://cashboard-f5x2.onrender.com/investment/add
Query Parameter: User UUID
The request body contains:
- desc (string) - A description of the investment account
- category (string) - Category for the investment
- currentAmount (number) - the investment’s balance
The response body is a JSON object that contains an array of all investments. An individual investment includes:
-
desc (string) - A description of the investment account
-
category (string) - Category for the investment
-
currentAmount (number) - the investment’s balance
-
_id (string) - the unique identifier for the investment
-
createdAt (timestamp) - whenthe investment was created
-
updatedAt (timestamp) - when the investment was last updated
POST
/
investment
/
add
Create an Investment
curl --request POST \
--url https://cashboard-f5x2.onrender.com/investment/add \
--header 'Content-Type: application/json' \
--data '
{
"desc": "Bitcoin",
"category": "Cryptocurrency",
"account": "662fbf9eac827e370c18d4b9",
"date": "03/21/2024",
"amount": 5000
}
'import requests
url = "https://cashboard-f5x2.onrender.com/investment/add"
payload = {
"desc": "Bitcoin",
"category": "Cryptocurrency",
"account": "662fbf9eac827e370c18d4b9",
"date": "03/21/2024",
"amount": 5000
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
desc: 'Bitcoin',
category: 'Cryptocurrency',
account: '662fbf9eac827e370c18d4b9',
date: '03/21/2024',
amount: 5000
})
};
fetch('https://cashboard-f5x2.onrender.com/investment/add', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cashboard-f5x2.onrender.com/investment/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'desc' => 'Bitcoin',
'category' => 'Cryptocurrency',
'account' => '662fbf9eac827e370c18d4b9',
'date' => '03/21/2024',
'amount' => 5000
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cashboard-f5x2.onrender.com/investment/add"
payload := strings.NewReader("{\n \"desc\": \"Bitcoin\",\n \"category\": \"Cryptocurrency\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"03/21/2024\",\n \"amount\": 5000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cashboard-f5x2.onrender.com/investment/add")
.header("Content-Type", "application/json")
.body("{\n \"desc\": \"Bitcoin\",\n \"category\": \"Cryptocurrency\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"03/21/2024\",\n \"amount\": 5000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cashboard-f5x2.onrender.com/investment/add")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"desc\": \"Bitcoin\",\n \"category\": \"Cryptocurrency\",\n \"account\": \"662fbf9eac827e370c18d4b9\",\n \"date\": \"03/21/2024\",\n \"amount\": 5000\n}"
response = http.request(request)
puts response.read_body{
"investments": [
{
"desc": "Bitcoin",
"currentAmount": 95000,
"category": "Cryptocurrency",
"_id": "662ff8a5712cd9fd793e1fb7",
"createdAt": "2024-04-29T19:44:37.441Z",
"updatedAt": "2024-04-29T19:44:37.441Z"
},
{
"desc": "Bitcoin",
"currentAmount": 5000,
"category": "Cryptocurrency",
"_id": "662ff9e36e0d87944a3c4cf7",
"createdAt": "2024-04-29T19:49:55.065Z",
"updatedAt": "2024-04-29T19:49:55.065Z"
},
{
"desc": "Bitcoin",
"currentAmount": 5000,
"category": "Cryptocurrency",
"_id": "662ffab8df4fbf42a526c6d5",
"createdAt": "2024-04-29T19:53:28.755Z",
"updatedAt": "2024-04-29T19:53:28.755Z"
}
]
}{
"status": "error",
"message": "Investment could not be added!"
}Query Parameters
Body
application/json
The body is of type object.
Response
OK
The response is of type object.

