From bb848e0e93fbcc248ff247ebe370db3d9144e334 Mon Sep 17 00:00:00 2001
From: paranarimasu <33796518+paranarimasu@users.noreply.github.com>
Date: Wed, 8 Jun 2022 00:17:19 -0500
Subject: [PATCH] feat: adding balance write endpoints (#28)
---
docs/.vuepress/config.js | 20 +++++++++-
docs/balance/README.md | 20 +++++++++-
docs/balance/destroy/README.md | 57 +++++++++++++++++++++++++++
docs/balance/forceDelete/README.md | 47 ++++++++++++++++++++++
docs/balance/store/README.md | 63 ++++++++++++++++++++++++++++++
docs/balance/update/README.md | 63 ++++++++++++++++++++++++++++++
package-lock.json | 16 ++++----
7 files changed, 274 insertions(+), 12 deletions(-)
create mode 100644 docs/balance/destroy/README.md
create mode 100644 docs/balance/forceDelete/README.md
create mode 100644 docs/balance/store/README.md
create mode 100644 docs/balance/update/README.md
diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js
index 4493ba3..576d726 100644
--- a/docs/.vuepress/config.js
+++ b/docs/.vuepress/config.js
@@ -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/',
}
]
},
diff --git a/docs/balance/README.md b/docs/balance/README.md
index 8bcf1d8..d006c66 100644
--- a/docs/balance/README.md
+++ b/docs/balance/README.md
@@ -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.
\ No newline at end of file
+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.
\ No newline at end of file
diff --git a/docs/balance/destroy/README.md b/docs/balance/destroy/README.md
new file mode 100644
index 0000000..8b09170
--- /dev/null
+++ b/docs/balance/destroy/README.md
@@ -0,0 +1,57 @@
+---
+title: Balance Destroy
+---
+
+
+
+# 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"
+ }
+}
+```
+
+
+
+
+```bash
+curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/balance/1
+```
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/balance/forceDelete/README.md b/docs/balance/forceDelete/README.md
new file mode 100644
index 0000000..03f1c0f
--- /dev/null
+++ b/docs/balance/forceDelete/README.md
@@ -0,0 +1,47 @@
+---
+title: Balance Force Delete
+---
+
+
+
+# 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.",
+}
+```
+
+
+
+
+```bash
+curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/forceDelete/balance/1
+```
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/balance/store/README.md b/docs/balance/store/README.md
new file mode 100644
index 0000000..b393dd6
--- /dev/null
+++ b/docs/balance/store/README.md
@@ -0,0 +1,63 @@
+---
+title: Balance Store
+---
+
+
+
+# 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"
+ }
+}
+```
+
+
+
+
+```bash
+curl -X POST -H "Authorization: Bearer {token}" https://api.animethemes.moe/balance/
+```
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/balance/update/README.md b/docs/balance/update/README.md
new file mode 100644
index 0000000..dcfb9b4
--- /dev/null
+++ b/docs/balance/update/README.md
@@ -0,0 +1,63 @@
+---
+title: Balance Update
+---
+
+
+
+# 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"
+ }
+}
+```
+
+
+
+
+```bash
+curl -X PATCH -H "Authorization: Bearer {token}" https://api.animethemes.moe/balance/1
+```
+
+
+
+
+
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 2686b59..6b0227b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -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": {