-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.yaml
More file actions
792 lines (770 loc) · 23.4 KB
/
swagger.yaml
File metadata and controls
792 lines (770 loc) · 23.4 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
openapi: 3.0.4
info:
title: MudraVault API
description: It is a virtual wallet API which is made to run basic transaction operations. The main aim is to make a secure wallet which can be used for transfers and payments.
version: 1.1.0
servers:
- url: https://virtual-wallet-api.onrender.com/api
description: Production server (Render)
- url: http://localhost:3000/api
description: Local development server
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
paths:
/otp/mobile:
post:
tags:
- OTP
summary: Send OTP to Indian mobile number
description: |
Generates a 6-digit OTP and sends it via SMS to the provided Indian mobile number.
The OTP is also stored in Redis with a 5-minute expiry for later verification.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- mobile
properties:
mobile:
type: string
description: A valid 10-digit Indian mobile number (starts with 6-9)
example: "9876543210"
responses:
'200':
description: OTP sent successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: OTP sent to mobile number
'400':
description: Invalid mobile number format
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Invalid Indian mobile number
'500':
description: Server error or SMS gateway failure
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Internal server error
/otp/verify-mobile:
post:
tags:
- OTP
summary: Verify OTP sent to mobile number
description: |
Verifies the OTP for the given mobile number using the stored Redis key.
If the OTP is valid, the entry is deleted from Redis and a short-lived verification flag is set.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- key
- otp
properties:
key:
type: string
description: The mobile number used to receive the OTP
example: "9876543210"
otp:
type: string
description: The 6-digit OTP sent to the user
example: "123456"
responses:
'200':
description: OTP verified successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: OTP verified successfully
'400':
description: Missing input or invalid OTP
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Invalid OTP
'500':
description: Server error or Redis failure
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Internal server error
/otp/email:
post:
tags:
- OTP
summary: Send OTP to email address
description: |
Sends a 6-digit OTP to the specified email address using HTML-formatted content.
The OTP is stored temporarily in Redis for 5 minutes for verification.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
properties:
email:
type: string
format: email
description: Valid email address to receive OTP
example: user@example.com
responses:
'200':
description: OTP sent successfully to email
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: OTP sent to email
'500':
description: Server error (email service or Redis failure)
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Internal server error
/otp/verify-email:
post:
tags:
- OTP
summary: Verify email OTP and send wallet credentials
description: |
Verifies the OTP sent to the user's email. If correct:
- Marks the user's profile as email verified.
- Hashes and sets a new password.
- Sends email with login credentials and wallet details.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- otp
properties:
email:
type: string
format: email
description: Email address used to receive OTP
example: user@example.com
otp:
type: string
description: The 6-digit OTP sent to the email
example: "123456"
responses:
'200':
description: OTP verified and credentials sent via email
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Email verified successfully. Credentials have been sent to your email.
'400':
description: Invalid OTP or email
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Invalid OTP
'404':
description: User or profile not found
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: User not found
'500':
description: Internal server or email error
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Internal server error
/auth/signup:
post:
tags:
- Authentication
summary: Create a new user account
description: |
Registers a new user after verifying that the mobile number was previously verified via OTP.
Also creates a wallet and profile entry for the user. Requires that the mobile number was verified using Redis.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- firstName
- lastName
- email
- contact
- gender
- dob
properties:
firstName:
type: string
example: John
lastName:
type: string
example: Doe
email:
type: string
format: email
example: johndoe@example.com
contact:
type: string
example: "9876543210"
gender:
type: string
enum: [Male, Female, Other]
example: Male
dob:
type: string
format: date
example: 1995-07-10
responses:
'200':
description: User created successfully, email verification pending
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: User created successfully . Please verify your emailId to Login
'400':
description: Validation error or mobile number not verified
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Mobile number not verified
'500':
description: Internal server error during signup
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Internal server error
/auth/login:
post:
tags:
- Authentication
summary: Login with email and password
description: |
Authenticates a user using email and password. Both mobile and email must be verified.
Returns a JWT token on successful login.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- password
properties:
email:
type: string
format: email
example: johndoe@example.com
password:
type: string
format: password
example: SecurePass123
responses:
'200':
description: Login successful, JWT token returned
content:
application/json:
schema:
type: object
properties:
token:
type: string
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
'401':
description: Invalid credentials
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Invalid credentials
'403':
description: Email or mobile not verified
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Please verify email and mobile first
'500':
description: Internal server error during login
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Internal server error
/wallet/balance:
get:
summary: Get wallet balance and account number
tags:
- Wallet
security:
- bearerAuth: []
responses:
200:
description: Wallet balance retrieved successfully
content:
application/json:
schema:
type: object
properties:
balance:
type: number
example: 1500
accountNumber:
type: string
example: "ACC1234567890"
401:
description: Unauthorized – Invalid or missing JWT
500:
description: Internal server error
/wallet/transfer:
post:
summary: Transfer funds internally to another user
description: Requires authentication and valid transaction PIN
tags:
- Wallet
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- contact
- amount
properties:
contact:
type: string
example: "9876543210"
amount:
type: number
example: 500
responses:
200:
description: Transfer successful
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Transfer successful
groupId:
type: string
example: txn_1729924238412_456
400:
description: Bad request (invalid input, insufficient funds, or self-transfer)
401:
description: Unauthorized – Invalid or missing JWT
403:
description: Forbidden – Invalid or missing transaction PIN
404:
description: User or wallet not found
500:
description: Internal server error during transfer
/transactions/history:
get:
summary: Get filtered and paginated transaction history
tags:
- Transactions
security:
- bearerAuth: []
parameters:
- name: type
in: query
schema:
type: string
enum: [DEBIT, CREDIT]
description: Filter by transaction type
- name: status
in: query
schema:
type: string
description: Filter by transaction status
- name: payGateway
in: query
schema:
type: string
description: Filter by payment gateway (e.g., razorpay, wallet-internal)
- name: referenceId
in: query
schema:
type: string
description: Filter by transaction reference ID
- name: groupId
in: query
schema:
type: string
description: Filter by transaction group ID
- name: from
in: query
schema:
type: string
format: date-time
description: Filter transactions created after this date
- name: to
in: query
schema:
type: string
format: date-time
description: Filter transactions created before this date
- name: minAmount
in: query
schema:
type: number
description: Minimum transaction amount
- name: maxAmount
in: query
schema:
type: number
description: Maximum transaction amount
- name: contact
in: query
schema:
type: string
description: Filter transactions involving a user with this contact
- name: sortBy
in: query
schema:
type: string
description: Sort field (e.g., createdOn)
- name: order
in: query
schema:
type: string
enum: [asc, desc]
description: Sort order (asc or desc)
- name: page
in: query
schema:
type: integer
default: 1
- name: limit
in: query
schema:
type: integer
default: 10
responses:
200:
description: Paginated and filtered transaction list
content:
application/json:
schema:
type: object
properties:
total:
type: integer
example: 50
page:
type: integer
example: 1
limit:
type: integer
example: 10
totalPages:
type: integer
example: 5
transactions:
type: array
items:
type: object
properties:
referenceId:
type: string
example: txn_1729924238412_456_DEBIT
type:
type: string
example: DEBIT
amount:
type: number
example: 100
status:
type: string
example: success
createdOn:
type: string
format: date-time
example: "2025-06-30T09:00:00.000Z"
sender:
type: object
properties:
firstname:
type: string
lastname:
type: string
contact:
type: string
receiver:
type: object
properties:
firstname:
type: string
lastname:
type: string
contact:
type: string
401:
description: Unauthorized – Invalid or missing JWT
404:
description: No user found with provided contact
500:
description: Failed to fetch transaction history
/transactions/pdf:
get:
summary: Export all transactions as PDF
tags:
- Transactions
security:
- bearerAuth: []
responses:
200:
description: PDF download of transaction history
content:
application/pdf:
schema:
type: string
format: binary
401:
description: Unauthorized – Invalid or missing JWT
500:
description: Failed to export PDF
/payments/topup:
post:
tags:
- Payments
summary: Create Razorpay order and payment link for wallet top-up
description: |
Creates a Razorpay order, logs a pending wallet top-up transaction in the database,
and generates a Razorpay payment link that the user can use to complete the payment.
Requires authentication.
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- amount
properties:
amount:
type: number
example: 500
description: Amount to top-up in INR
responses:
'200':
description: Razorpay order and payment link created successfully
content:
application/json:
schema:
type: object
properties:
orderId:
type: string
example: order_Ky7wYrMDCjfkxZ
description: Razorpay order ID
amount:
type: number
example: 500
description: Top-up amount in INR
paymentLink:
type: string
format: uri
example: https://rzp.io/l/SamplePaymentLink123
description: Razorpay payment link for completing the transaction
'400':
description: Bad request - invalid amount
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Amount must be greater than 0
'500':
description: Internal server error
/user/changePassword:
post:
tags:
- User
summary: Change user account password
description: |
Allows an authenticated user to change their password by providing the current password
and the new password. Requires authentication.
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- currentPassword
- newPassword
properties:
currentPassword:
type: string
example: oldPassword123
description: Current password of the user
newPassword:
type: string
example: newPassword456
description: New password to be set
responses:
'200':
description: Password updated successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Password changed successfully
'400':
description: Missing required fields
'401':
description: Current password is incorrect
'404':
description: User not found
'500':
description: Internal server error
/user/changePin:
post:
tags:
- User
summary: Change wallet PIN
description: |
Allows an authenticated user to change their wallet PIN by providing the current PIN
and the new PIN. Requires authentication.
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- currentPin
- newPin
properties:
currentPin:
type: string
example: "1234"
description: Current wallet PIN
newPin:
type: string
example: "5678"
description: New wallet PIN
responses:
'200':
description: Wallet PIN updated successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: PIN changed successfully
'400':
description: Missing required fields
'401':
description: Current PIN is incorrect
'404':
description: Wallet not found
'500':
description: Internal server error