forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecurring-billing.controller.ts
More file actions
36 lines (32 loc) · 1.1 KB
/
Copy pathrecurring-billing.controller.ts
File metadata and controls
36 lines (32 loc) · 1.1 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
import { Body, Controller, Delete, Get, Param, Post } from "@nestjs/common";
import { Auth, CurrentUser } from "../auth/guard/auth.guard";
import { User } from "../users/user.entity";
import { RecurringBillingService } from "./recurring-billing.service";
import { CreateScheduleDto } from "./dto/create-schedule.dto";
/**
* Recurring billing controller — lets merchants define, list, and cancel
* recurring invoice rules for their customers.
*/
@Controller("recurring-schedules")
export class RecurringBillingController {
constructor(private readonly recurringBillingService: RecurringBillingService) {}
@Auth()
@Post()
create(@CurrentUser() user: User, @Body() dto: CreateScheduleDto) {
return this.recurringBillingService.createSchedule(
user.merchantId,
user.id,
dto,
);
}
@Auth()
@Get()
list(@CurrentUser() user: User) {
return this.recurringBillingService.listSchedules(user.merchantId);
}
@Auth()
@Delete(":id")
cancel(@CurrentUser() user: User, @Param("id") id: string) {
return this.recurringBillingService.cancelSchedule(user.merchantId, id);
}
}