Skip to content

Commit ffb46d5

Browse files
authored
Merge pull request #165 from Real-Dev-Squad/api-contract/notify
Api contract/notify
2 parents 142116a + 44cdfe7 commit ffb46d5

File tree

2 files changed

+209
-0
lines changed

2 files changed

+209
-0
lines changed

fcm-token/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Collection - fcmTokens
2+
3+
## API Endpoints
4+
5+
| Route | Description |
6+
| :---------------------------------: | :------------------------------------------------: |
7+
| [POST /v1/fcm-tokens](#post-notify) | Saves FCM token to uniquely identified the device. |
8+
| |
9+
10+
## POST /v1/fcm-tokens
11+
12+
Creates a new fcm-token document.
13+
14+
- **Params**
15+
None
16+
- **Query**
17+
None
18+
- **Body**
19+
20+
- Attributes
21+
- **fcmToken** (required, string): Specifies the fcm token for the document which will uniquely identified the device.
22+
23+
- **Headers**
24+
- Content-Type: application/json
25+
- **Cookie**
26+
None
27+
- **Success Response:**
28+
29+
- **Code:** 201
30+
31+
- **Content:**
32+
33+
```json
34+
{
35+
"status": 201,
36+
"message": "Device registered successfully"
37+
}
38+
```
39+
40+
- **Error Response:**
41+
42+
- **Code:** 400
43+
44+
- **Content:**
45+
46+
```json
47+
{
48+
"statusCode": 400,
49+
"error": "Bad Request",
50+
"message": "\"fcmToken\" is required"
51+
}
52+
```
53+
54+
- **Code:** 409
55+
56+
- **Content:**
57+
58+
```json
59+
{
60+
"status": 409,
61+
"message": "Device Already Registered"
62+
}
63+
```
64+
65+
- **Code:** 500
66+
67+
- **Content:**
68+
69+
```json
70+
{
71+
"message": "The server has encountered an unexpected error. Please contact the administrator for more information."
72+
}
73+
```
74+
75+
- **Example for device fcm-token document creation request:**
76+
POST /v1/fcm-tokens<br/>
77+
Content-Type: application/json<br/>
78+
Request-Body:<br/>
79+
80+
```json
81+
{
82+
"fcmToken": "jkshdsadlksajdl"
83+
}
84+
```
85+
86+
Response :
87+
Status 201<br/>
88+
Content-Type: application/json<br/>
89+
90+
```json
91+
{
92+
"status": 201,
93+
"message": "Device registered successfully"
94+
}
95+
```

notify/README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Collection - no collection for now
2+
3+
## API Endpoints
4+
5+
| Route | Description |
6+
| :-------------------------------------------: | :-------------------------------------------: |
7+
| [POST /v1/notifications](#post-notifications) | send notification to your specified fcm token |
8+
| |
9+
10+
## POST /v1/notifications
11+
12+
Send notification to your specified device.
13+
14+
- **Params**
15+
None
16+
- **Query**
17+
None
18+
- **Body**
19+
20+
- Attributes
21+
- **title** (required, string): notification title
22+
- **body** (required, string): notification message
23+
- **userId** (optional, string): user who is assigning
24+
- **groupRoleId** (optional, string) : group to whom the notification will be broadcasted
25+
26+
- **Headers**
27+
- Content-Type: application/json
28+
- **Cookie**
29+
None
30+
- **Success Response:**
31+
- **Code:** 200
32+
- **Content:**
33+
```json
34+
{
35+
"status": 200,
36+
"message": "User notified successfully"
37+
}
38+
```
39+
- **Error Response:**
40+
41+
- **Code:** 400
42+
43+
- **Content:**
44+
45+
```json
46+
{
47+
"statusCode": 400,
48+
"error": "Bad Request",
49+
"message": "\"value\" must contain at least one of [userId, groupRoleId]"
50+
}
51+
```
52+
53+
- **Code:** 401
54+
55+
- **Content:**
56+
```json
57+
{
58+
"statusCode": 406,
59+
"error": "Bad Request",
60+
"message": "Message length exceeds"
61+
}
62+
```
63+
64+
- **Code:** 500
65+
- **Content:**
66+
```json
67+
{
68+
"statusCode": 500,
69+
"message": "The server has encountered an unexpected error. Please contact the administrator for more information."
70+
}
71+
```
72+
73+
- **Example for device fcm-token document creation request:**
74+
POST /v1/notifications<br/>
75+
Content-Type: application/json<br/>
76+
Request-Body:<br/>
77+
78+
```json
79+
{
80+
"title": "testing",
81+
"body": "Helloo world",
82+
"userId": "feJ49TjqHVG4O0luUDlz"
83+
}
84+
```
85+
86+
Response :
87+
Status 200<br/>
88+
Content-Type: application/json<br/>
89+
90+
```json
91+
{
92+
"status": 200,
93+
"message": "User notified successfully"
94+
}
95+
```
96+
97+
```json
98+
{
99+
"title": "testing",
100+
"body": "Helloo world",
101+
"groupRoleId": "1147354535342383104"
102+
}
103+
```
104+
105+
Response :
106+
Status 200<br/>
107+
Content-Type: application/json<br/>
108+
109+
```json
110+
{
111+
"status": 200,
112+
"message": "User notified successfully"
113+
}
114+
```

0 commit comments

Comments
 (0)