Budget
User Budget
STAGING_URL: https://switch-api-staging.herokuapp.com
LIVE_URL: https://switchapi.azurewebsites.netThese requests are not in the current release
Get Budget
GET https://switch-api-staging.herokuapp.com/user/budget
This endpoint returns a user's budget
Headers
auth_token
string
The format for auth_token is Bearer token_string
{
"message": "Budget retrieved successfully",
"data": {
"total_kobo": "10000000.0",
"allocations": [
{
"id": 309,
"name": "my new car",
"category": "transportation",
"amount_kobo": "2500000.0"
},
{
"id": 310,
"name": "next ride",
"category": "transportation",
"amount_kobo": "500000.0"
}
]
}
}Create Budget
POST https://switch-api-staging.herokuapp.com/user/budget
this endpoint helps users create a budget
Headers
auth_token
string
Teh format for auth_token is Bearer token_string
Request Body
allocations_attributes
string
an array of objects that takes in name, category and amount_kobo
e.g [{
name: “me”,
category: “from the list ofbudget categories”, amount_kobo: “us”
},{
name: “me”,
category: “from the list ofbudget categories”, amount_kobo: “us”
}]
total_kobo
string
total budget amount
{
"message": "Budget created successfully",
"data": {
"total_kobo": "0.0",
"allocations": [
{
"id": 309,
"name": "my new car",
"category": "transportation",
"amount_kobo": "2500000.0"
},
{
"id": 310,
"name": "next ride",
"category": "transportation",
"amount_kobo": "500000.0"
}
]
}
}{
"message": "Budget created successfully",
"data": {
"total_kobo": "10000000.0",
"allocations": []
}
}{
"message": "Error creating budget",
"errors": {
"total_kobo": [
"can't be blank"
]
}
}Update User Budget
PATCH https://switch-api-staging.herokuapp.com/user/budget
This endpoint allows user update their budget
Headers
auth_token
string
The format for auth_token is Bearer token_string
Request Body
total_kobo
string
total budget amount
allocations
string
takes in an arrqay of objects that takes in name, category and amount_kobo
{
"message": "Budget updated successfully",
"data": {
"total_kobo": "10000000.0",
"allocations": [
{
"id": 309,
"name": "my new car",
"category": "transportation",
"amount_kobo": "2500000.0"
},
{
"id": 310,
"name": "next ride",
"category": "transportation",
"amount_kobo": "500000.0"
}
]
}
}Update user Budget
PUT https://switch-api-staging.herokuapp.com/user/budget
This endpoint updates a user's budget
Headers
auth_token
string
The format for auth_token is Bearer token_string
Request Body
allocations
string
takes in a array of objects that takes in name, category and amount_kobo
total_kobo
string
total budget amount
{
"message": "Budget updated successfully",
"data": {
"total_kobo": "10000000.0",
"allocations": [
{
"id": 309,
"name": "my new car",
"category": "transportation",
"amount_kobo": "2500000.0"
},
{
"id": 310,
"name": "next ride",
"category": "transportation",
"amount_kobo": "500000.0"
}
]
}
}Delete Budget
DELETE https://switch-api-staging.herokuapp.com/user/budget
This endpoint deletes a user's budget
Headers
auth_token
string
The format for auth_token is Bearer token_string
{
"message": "Budget deleted"
}Last updated
Was this helpful?