Skip to content

Commit

Permalink
docs: add archived notification related documentation (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitij-k-osmosys authored Nov 29, 2024
1 parent b972eab commit f3ff22f
Show file tree
Hide file tree
Showing 5 changed files with 333 additions and 2 deletions.
51 changes: 51 additions & 0 deletions apps/api/OsmoX-API.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,57 @@
],
"description": "These API calls are responsible for fetching notifications and related details."
},
{
"name": "Archived Notification",
"item": [
{
"name": "Fetch All Archived Notifications",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{auth-token}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "graphql",
"graphql": {
"query": "query {\r\n archivedNotifications(\r\n options: {\r\n limit: 5\r\n offset: 0\r\n sortBy: \"createdOn\"\r\n sortOrder: DESC\r\n search: \"sender@email.com\"\r\n filters: [{ field: \"applicationId\", operator: \"eq\", value: \"1\" }]\r\n }\r\n ) {\r\n archivedNotifications {\r\n applicationDetails {\r\n applicationId\r\n name\r\n userId\r\n status\r\n createdOn\r\n updatedOn\r\n }\r\n applicationId\r\n channelType\r\n createdBy\r\n createdOn\r\n data\r\n deliveryStatus\r\n id\r\n notificationId\r\n providerDetails {\r\n providerId\r\n name\r\n channelType\r\n isEnabled\r\n configuration\r\n applicationId\r\n userId\r\n status\r\n }\r\n providerId\r\n result\r\n status\r\n updatedBy\r\n updatedOn\r\n }\r\n total,\r\n offset,\r\n limit\r\n }\r\n}",
"variables": ""
}
},
"url": {
"raw": "{{base_url}}/graphql",
"host": [
"{{base_url}}"
],
"path": [
"graphql"
]
},
"description": "Allows successfully fetching all notifications based on the options passed."
},
"response": []
}
]
},
{
"name": "Application",
"item": [
Expand Down
125 changes: 125 additions & 0 deletions apps/api/OsmoX.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -3193,6 +3193,131 @@
],
"description": "Collection of requests pertaining to fetching all notifications."
},
{
"name": "All Archived Notifications",
"item": [
{
"name": "Fetch All Archived Notifications - Success",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Response is valid JSON\", function () {",
" pm.response.to.be.json;",
"});",
"pm.test(\"Response has valid 'data' property\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"data\").to.be.an(\"object\");",
"});",
"pm.test(\"Response contains a valid 'archivedNotifications' object\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.data).to.have.property(\"archivedNotifications\").to.be.an(\"object\");",
"});",
"pm.test(\"Response contains a valid 'archivedNotifications' array\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.data.archivedNotifications).to.have.property(\"archivedNotifications\").to.be.an(\"array\");",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{auth-token}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "graphql",
"graphql": {
"query": "query {\r\n archivedNotifications(\r\n options: {\r\n limit: 5\r\n offset: 0\r\n sortBy: \"createdOn\"\r\n sortOrder: DESC\r\n search: \"sender@email.com\"\r\n filters: [{ field: \"applicationId\", operator: \"eq\", value: \"1\" }]\r\n }\r\n ) {\r\n archivedNotifications{\r\n applicationDetails {\r\n applicationId\r\n name\r\n userId\r\n status\r\n createdOn\r\n updatedOn\r\n }\r\n applicationId\r\n channelType\r\n createdBy\r\n createdOn\r\n data\r\n deliveryStatus\r\n notificationId\r\n providerDetails {\r\n providerId\r\n name\r\n channelType\r\n isEnabled\r\n configuration\r\n applicationId\r\n userId\r\n status\r\n }\r\n providerId\r\n result\r\n status\r\n updatedBy\r\n updatedOn\r\n }\r\n total,\r\n offset,\r\n limit\r\n }\r\n}",
"variables": ""
}
},
"url": {
"raw": "http://localhost:3000/graphql",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"graphql"
]
},
"description": "Allows successfully fetching all notifications based on the options passed."
},
"response": []
},
{
"name": "Fetch All Archived Notifications - Bad request",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Response is valid JSON\", function () {",
" pm.response.to.be.json;",
"});",
"pm.test(\"Response for fetching archivedNotifications with bad request\", function () {",
" pm.expect(pm.response.code).to.equal(400);",
" pm.expect(pm.response.json().errors).to.be.an(\"array\");",
" pm.expect(pm.response.json().errors[0].message).to.be.a(\"string\");",
"});",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{auth-token}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "graphql",
"graphql": {
"query": "query {\r\n archivedNotifications(\r\n options: {\r\n unknownValue: \"Some unknown parameter\"\r\n limit: 5\r\n offset: 0\r\n sortBy: \"createdOn\"\r\n sortOrder: DESC\r\n search: \"sender@email.com\"\r\n filters: [{ field: \"applicationId\", operator: \"eq\", value: \"1\" }]\r\n }\r\n ) {\r\n archivedNotifications {\r\n applicationDetails {\r\n applicationId\r\n name\r\n userId\r\n status\r\n createdOn\r\n updatedOn\r\n }\r\n applicationId\r\n channelType\r\n createdBy\r\n createdOn\r\n data\r\n deliveryStatus\r\n notificationId\r\n providerDetails {\r\n providerId\r\n name\r\n channelType\r\n isEnabled\r\n configuration\r\n applicationId\r\n userId\r\n status\r\n }\r\n providerId\r\n result\r\n status\r\n updatedBy\r\n updatedOn\r\n }\r\n total,\r\n offset,\r\n limit\r\n }\r\n}",
"variables": ""
}
},
"url": {
"raw": "http://localhost:3000/graphql",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"graphql"
]
},
"description": "Allows representing failure when fetching all notifications when using invalid/bad request."
},
"response": []
}
],
"description": "Collection of requests pertaining to fetching all notifications."
},
{
"name": "All Applications",
"item": [
Expand Down
147 changes: 147 additions & 0 deletions apps/api/docs/api-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,153 @@ curl --location 'http://localhost:3000/graphql' \
}
```

## Archived Notifications

This sections lists notification related requests such as fetching all archived notifications.

### Fetch All Archived Notifications

Allows the user to fetch all archived notifications based on the passed query parameters. Requires passing bearer token for authorization.

The different options that can be used while fetching notifications are as follows:

- `limit:` Limit the number of results to the provided value
- `offset:` Offset the result set by the provided value
- `sortBy:` Sort the results by the provided key
- `sortOrder:` Sort the results in either `ASC`ending or `DESC`ending order
- `search:` Search for the provided value in `createdBy`, `data` and `result` and return results matching it
- `filters:` Filter the results based on the provided `field`, `operator` and `value`. Operator can be `eq` (equal), `ne` (not equal), `contains`, `gt` (greater than) or `lt` (less than)

**Endpoint:** `http://localhost:3000/graphql`

**Method:** `POST`

**Body:** `graphql`

```graphql
query {
archivedNotifications(
options: {
limit: 5
offset: 0
sortBy: "createdOn"
sortOrder: DESC
search: "sender@email.com"
filters: [{ field: "applicationId", operator: "eq", value: "1" }]
}
) {
archivedNotifications {
applicationDetails {
applicationId
name
userId
status
createdOn
updatedOn
}
applicationId
channelType
createdBy
createdOn
data
deliveryStatus
id
notificationId
providerDetails {
providerId
name
channelType
isEnabled
configuration
applicationId
userId
status
}
providerId
result
status
updatedBy
updatedOn
}
total,
offset,
limit
}
}
```

**cURL**

```sh
curl --location 'YOUR_BASE_URL/graphql' \
--header 'Authorization: Bearer YOUR_AUTH_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query {\r\n archivedNotifications(\r\n options: {\r\n limit: 5\r\n offset: 0\r\n sortBy: \"createdOn\"\r\n sortOrder: DESC\r\n search: \"sender@email.com\"\r\n filters: [{ field: \"applicationId\", operator: \"eq\", value: \"1\" }]\r\n }\r\n ) {\r\n archivedNotifications {\r\n applicationDetails {\r\n applicationId\r\n name\r\n userId\r\n status\r\n createdOn\r\n updatedOn\r\n }\r\n applicationId\r\n channelType\r\n createdBy\r\n createdOn\r\n data\r\n deliveryStatus\r\n id\r\n notificationId\r\n providerDetails {\r\n providerId\r\n name\r\n channelType\r\n isEnabled\r\n configuration\r\n applicationId\r\n userId\r\n status\r\n }\r\n providerId\r\n result\r\n status\r\n updatedBy\r\n updatedOn\r\n }\r\n total,\r\n offset,\r\n limit\r\n }\r\n}","variables":{}}'
```

**Sample response**

```json
{
"data": {
"archivedNotifications": {
"archivedNotifications": [
{
"applicationDetails": {
"applicationId": 1,
"name": "sampleOsmoXApp",
"userId": 1,
"status": 1,
"createdOn": "2024-04-29T08:06:41.000Z",
"updatedOn": "2024-04-29T08:06:41.000Z"
},
"applicationId": 1,
"channelType": 1,
"createdBy": "sampleOsmoXApp",
"createdOn": "2024-05-07T06:44:39.000Z",
"data": {
"from": "sender@email.com",
"to": "receiver@email.com",
"subject": "Test subject",
"text": "This is a test notification",
"html": "<b>This is a test notification</b>"
},
"deliveryStatus": 6,
"id": 7,
"notificationId": 9,
"providerDetails": {
"providerId": 1,
"name": "smtp",
"channelType": 1,
"isEnabled": 1,
"configuration": {},
"applicationId": 1,
"userId": 1,
"status": 1
},
"providerId": 1,
"result": {
"result": {
"errno": -3008,
"code": "EDNS",
"syscall": "getaddrinfo",
"hostname": "some.smtp.host",
"command": "CONN"
}
},
"status": 1,
"updatedBy": "sampleOsmoXApp",
"updatedOn": "2024-07-03T06:18:08.000Z"
}
],
"total": 1,
"offset": 0,
"limit": 5
}
}
}
```

## Applications

This sections lists application related requests such as creating new application and fetching all applications.
Expand Down
6 changes: 5 additions & 1 deletion apps/api/docs/development-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ sudo systemctl status mariadb
# Notification configuration
MAX_RETRY_COUNT=3 # Max retry count, default is 3
ARCHIVE_LIMIT=1000 # Max notifications to archive, default is 1000
ARCHIVE_INTERVAL=3600 # Interval (in seconds) for archiving notifications, default 3600 (every 1 hour)
# Log Level
# Log configuration
LOG_LEVEL=info # Log level, default is info
COMBINED_LOG_MAX_SIZE=150m # Max file size for combined logs. Set 0 for no size limit, default 150m
ERROR_LOG_MAX_SIZE=20m # Max file size for error logs. Set 0 for no size limit, default 20m
# Database configuration
DB_TYPE=mysql
Expand Down
6 changes: 5 additions & 1 deletion apps/api/docs/production-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ Make sure Redis and MariaDB server are up and running.
# Notification configuration
MAX_RETRY_COUNT=3 # Max retry count, default is 3
ARCHIVE_LIMIT=1000 # Max notifications to archive, default is 1000
ARCHIVE_INTERVAL=3600 # Interval (in seconds) for archiving notifications, default 3600 (every 1 hour)
# Log Level
# Log configuration
LOG_LEVEL=info # Log level, default is info
COMBINED_LOG_MAX_SIZE=150m # Max file size for combined logs. Set 0 for no size limit, default 150m
ERROR_LOG_MAX_SIZE=20m # Max file size for error logs. Set 0 for no size limit, default 20m
# Database configuration
DB_TYPE=mysql
Expand Down

0 comments on commit f3ff22f

Please sign in to comment.