feat: adding balance write endpoints (#28)

This commit is contained in:
paranarimasu authored and GitHub committed 2022-06-08 00:17:19 -05:00
1 parent 737142671d
commit bb848e0e93
7 files changed
+274 -12

No files matched your search

+18 -2
View File
@@ -157,12 +157,28 @@ module.exports = {
to: '/balance',
children: [
{
title: 'Show',
to: '/balance/show/',
title: 'Destroy',
to: '/balance/destroy/'
},
{
title: 'Force Delete',
to: '/balance/forceDelete/'
},
{
title: 'Index',
to: '/balance/index/'
},
{
title: 'Show',
to: '/balance/show/',
},
{
title: 'Store',
to: '/balance/store/',
},
{
title: 'Update',
to: '/balance/update/',
}
]
},
+18 -2
View File
@@ -28,10 +28,26 @@ None
### Endpoints
**[Balance Destroy](/balance/destroy/)**
The balance destroy endpoint soft deletes a balance and returns the deleted balance resource.
**[Balance Force Delete](/balance/forceDelete/)**
The balance force delete endpoint hard deletes a balance and returns a confirmation message.
**[Balance Index](/balance/index/)**
The balance index endpoint displays a listing of balance resources.
**[Balance Show](/balance/show/)**
The balance show endpoint returns a balance resource.
**[Balance Index](/balance/index/)**
**[Balance Store](/balance/store/)**
The balance index endpoint displays a listing of balance resources.
The balance store endpoint creates a new balance and returns the new balance resource.
**[Balance Update](/balance/update/)**
The balance update endpoint updates a balance and returns the updated balance resource.
+57
View File
@@ -0,0 +1,57 @@
---
title: Balance Destroy
---
<Block>
# Balance Destroy Endpoint
The balance destroy endpoint soft deletes a balance and returns the deleted balance resource.
For example, the `/api/balance/1` endpoint will soft delete the balance of id '1' and return the deleted balance resource.
## URL
```sh
DELETE /api/balance/{id}
```
## Authentication
**Required Permission**: delete balance
**Roles with Permission**: Admin
## Parameters
None
## Response
```json
{
balance: {
id: id,
date: "date",
service: "service",
frequency: "frequency",
usage: usage,
month_to_date_balance: month_to_date_balance,
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
}
}
```
<Example>
<CURL>
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/balance/1
```
</CURL>
</Example>
</Block>
+47
View File
@@ -0,0 +1,47 @@
---
title: Balance Force Delete
---
<Block>
# Balance Force Delete Endpoint
The balance force delete endpoint hard deletes a balance and returns a confirmation message.
For example, the `/api/forceDelete/balance/1` endpoint will hard delete the balance of id '1' and return a confirmation message.
## URL
```sh
DELETE /api/forceDelete/balance/{id}
```
## Authentication
**Required Permission**: force delete balance
**Roles with Permission**: Admin
## Parameters
None
## Response
```json
{
message: "The Balance 'AWS 2022-06-01' was deleted.",
}
```
<Example>
<CURL>
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/forceDelete/balance/1
```
</CURL>
</Example>
</Block>
+63
View File
@@ -0,0 +1,63 @@
---
title: Balance Store
---
<Block>
# Balance Store Endpoint
The balance store endpoint creates a new balance and returns the new balance resource.
For example, the `/api/balance?date=2022-06-01&service=AWS&frequency=Monthly&usage=10.00&month_to_date_balance=50.00` endpoint will create a new balance and return the new balance resource.
## URL
```sh
POST /api/balance
```
## Authentication
**Required Permission**: create balance
**Roles with Permission**: Admin
## Parameters
| Name | Required | Rules |
| :-------------------: | :------: | :--------------------------------------------------------- |
| date | Yes | date_format:Y-m-d |
| service | Yes | EnumValue {Other, DigitalOcean, AWS, Hover, WalkerServers} |
| frequency | Yes | EnumValue {Once, Annually, Biannually, Quarterly, Monthly} |
| usage | Yes | regex:/^\-?\d+(\.\d{1,2})?$/ |
| month_to_date_balance | Yes | regex:/^\-?\d+(\.\d{1,2})?$/ |
## Response
```json
{
balance: {
id: id,
date: "date",
service: "service",
frequency: "frequency",
usage: usage,
month_to_date_balance: month_to_date_balance,
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
}
}
```
<Example>
<CURL>
```bash
curl -X POST -H "Authorization: Bearer {token}" https://api.animethemes.moe/balance/
```
</CURL>
</Example>
</Block>
+63
View File
@@ -0,0 +1,63 @@
---
title: Balance Update
---
<Block>
# Balance Update Endpoint
The balance update endpoint updates a balance and returns the updated balance resource.
For example, the `/api/balance/1?usage=10.00` endpoint will update the balance usage attribute and return the updated balance resource.
## URL
```sh
PUT|PATCH /api/balance/{id}
```
## Authentication
**Required Permission**: update balance
**Roles with Permission**: Admin
## Parameters
| Name | Required | Rules |
| :-------------------: | :------: | :--------------------------------------------------------- |
| date | No | date_format:Y-m-d |
| service | No | EnumValue {Other, DigitalOcean, AWS, Hover, WalkerServers} |
| frequency | No | EnumValue {Once, Annually, Biannually, Quarterly, Monthly} |
| usage | No | regex:/^\-?\d+(\.\d{1,2})?$/ |
| month_to_date_balance | No | regex:/^\-?\d+(\.\d{1,2})?$/ |
## Response
```json
{
balance: {
id: id,
date: "date",
service: "service",
frequency: "frequency",
usage: usage,
month_to_date_balance: month_to_date_balance,
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at"
}
}
```
<Example>
<CURL>
```bash
curl -X PATCH -H "Authorization: Bearer {token}" https://api.animethemes.moe/balance/1
```
</CURL>
</Example>
</Block>
+8 -8
View File
@@ -5703,9 +5703,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.4.147",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.147.tgz",
"integrity": "sha512-czclPqxLMPqPMkahKcske4TaS5lcznsc26ByBlEFDU8grTBVK9C5W6K9I6oEEhm4Ai4jTihGnys90xY1yjXcRg==",
"version": "1.4.148",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.148.tgz",
"integrity": "sha512-8MJk1bcQUAYkuvCyWZxaldiwoDG0E0AMzBGA6cv3WfuvJySiPgfidEPBFCRRH3cZm6SVZwo/oRlK1ehi1QNEIQ==",
"dev": true
},
"node_modules/elliptic": {
@@ -11745,7 +11745,7 @@
"node_modules/select-hose": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
"integrity": "sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=",
"integrity": "sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg==",
"dev": true
},
"node_modules/selfsigned": {
@@ -19496,9 +19496,9 @@
"dev": true
},
"electron-to-chromium": {
"version": "1.4.147",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.147.tgz",
"integrity": "sha512-czclPqxLMPqPMkahKcske4TaS5lcznsc26ByBlEFDU8grTBVK9C5W6K9I6oEEhm4Ai4jTihGnys90xY1yjXcRg==",
"version": "1.4.148",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.148.tgz",
"integrity": "sha512-8MJk1bcQUAYkuvCyWZxaldiwoDG0E0AMzBGA6cv3WfuvJySiPgfidEPBFCRRH3cZm6SVZwo/oRlK1ehi1QNEIQ==",
"dev": true
},
"elliptic": {
@@ -24286,7 +24286,7 @@
"select-hose": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
"integrity": "sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=",
"integrity": "sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg==",
"dev": true
},
"selfsigned": {