-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRideExpress-Stats.postman_collection.json
More file actions
193 lines (193 loc) · 6.24 KB
/
RideExpress-Stats.postman_collection.json
File metadata and controls
193 lines (193 loc) · 6.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
{
"info": {
"name": "RideExpress Statistics API",
"description": "Comprehensive statistics and analytics endpoints for the RideExpress ride-sharing application. All endpoints require ADMIN or SUPER_ADMIN authentication.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{adminToken}}",
"type": "string"
}
]
},
"variable": [
{
"key": "baseUrl",
"value": "http://localhost:5000/api",
"type": "string"
},
{
"key": "adminToken",
"value": "YOUR_ADMIN_TOKEN_HERE",
"type": "string",
"description": "JWT token obtained after logging in as admin"
}
],
"item": [
{
"name": "Authentication",
"item": [
{
"name": "Login as Admin",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"admin@rideexpress.com\",\n \"password\": \"adminpassword\"\n}"
},
"url": {
"raw": "{{baseUrl}}/auth/login",
"host": ["{{baseUrl}}"],
"path": ["auth", "login"]
},
"description": "Login to get admin authentication token. Copy the accessToken from response and set it as adminToken variable."
}
}
]
},
{
"name": "Dashboard Statistics",
"item": [
{
"name": "Get Dashboard Overview",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/stats/dashboard",
"host": ["{{baseUrl}}"],
"path": ["stats", "dashboard"]
},
"description": "Get an overview of all key metrics in a single request. Returns total users, rides, drivers, revenue, active rides, completed rides today, new users and drivers this week."
}
}
]
},
{
"name": "Ride Statistics",
"item": [
{
"name": "Get Ride Statistics",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/stats/rides",
"host": ["{{baseUrl}}"],
"path": ["stats", "rides"]
},
"description": "Get comprehensive ride analytics including counts, status distribution, performance metrics, distance analysis, fare analysis, time-based trends, popular locations, and ride duration statistics."
}
}
]
},
{
"name": "User Statistics",
"item": [
{
"name": "Get User Statistics",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/stats/users",
"host": ["{{baseUrl}}"],
"path": ["stats", "users"]
},
"description": "Get user analytics including role distribution, status counts, growth metrics, verification status, and user activity patterns."
}
}
]
},
{
"name": "Driver Statistics",
"item": [
{
"name": "Get Driver Statistics",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/stats/drivers",
"host": ["{{baseUrl}}"],
"path": ["stats", "drivers"]
},
"description": "Get driver analytics including approval status, availability patterns, earnings distribution, performance metrics, and top earning drivers."
}
}
]
},
{
"name": "Revenue Statistics",
"item": [
{
"name": "Get Revenue Statistics",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/stats/revenue",
"host": ["{{baseUrl}}"],
"path": ["stats", "revenue"]
},
"description": "Get financial analytics including revenue trends, earnings by vehicle type, revenue by location, cancellation impact, and pending revenue analysis."
}
}
]
}
],
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Test script to validate statistics responses",
"if (pm.response.code === 200) {",
" const response = pm.response.json();",
" ",
" // Check if response has required structure",
" pm.test(\"Response has success property\", function () {",
" pm.expect(response).to.have.property('success');",
" pm.expect(response.success).to.be.true;",
" });",
" ",
" pm.test(\"Response has message property\", function () {",
" pm.expect(response).to.have.property('message');",
" pm.expect(response.message).to.be.a('string');",
" });",
" ",
" pm.test(\"Response has data property\", function () {",
" pm.expect(response).to.have.property('data');",
" pm.expect(response.data).to.be.an('object');",
" });",
" ",
" // Store admin token if this is a login request",
" if (pm.request.url.path.includes('/auth/login') && response.data && response.data.accessToken) {",
" pm.collectionVariables.set('adminToken', response.data.accessToken);",
" console.log('Admin token stored successfully');",
" }",
"} else if (pm.response.code === 401) {",
" pm.test(\"Unauthorized access\", function () {",
" pm.expect(pm.response.code).to.equal(401);",
" });",
"} else if (pm.response.code === 403) {",
" pm.test(\"Forbidden access\", function () {",
" pm.expect(pm.response.code).to.equal(403);",
" });",
"}"
],
"type": "text/javascript"
}
}
]
}