-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13e673e
commit 562d5be
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
apps/api/v2/src/modules/organizations/controllers/dwd/dwd.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { API_VERSIONS_VALUES } from "@/lib/api-versions"; | ||
import { PlatformPlan } from "@/modules/auth/decorators/billing/platform-plan.decorator"; | ||
import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator"; | ||
import { Roles } from "@/modules/auth/decorators/roles/roles.decorator"; | ||
import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard"; | ||
import { PlatformPlanGuard } from "@/modules/auth/guards/billing/platform-plan.guard"; | ||
import { IsMembershipInOrg } from "@/modules/auth/guards/memberships/is-membership-in-org.guard"; | ||
import { IsAdminAPIEnabledGuard } from "@/modules/auth/guards/organizations/is-admin-api-enabled.guard"; | ||
import { IsOrgGuard } from "@/modules/auth/guards/organizations/is-org.guard"; | ||
import { RolesGuard } from "@/modules/auth/guards/roles/roles.guard"; | ||
import { CreateOrgMembershipDto } from "@/modules/organizations/inputs/create-organization-membership.input"; | ||
import { UpdateOrgMembershipDto } from "@/modules/organizations/inputs/update-organization-membership.input"; | ||
import { CreateOrgMembershipOutput } from "@/modules/organizations/outputs/organization-membership/create-membership.output"; | ||
import { DeleteOrgMembership } from "@/modules/organizations/outputs/organization-membership/delete-membership.output"; | ||
import { GetAllOrgMemberships } from "@/modules/organizations/outputs/organization-membership/get-all-memberships.output"; | ||
import { GetOrgMembership } from "@/modules/organizations/outputs/organization-membership/get-membership.output"; | ||
import { OrgMembershipOutputDto } from "@/modules/organizations/outputs/organization-membership/membership.output"; | ||
import { UpdateOrgMembership } from "@/modules/organizations/outputs/organization-membership/update-membership.output"; | ||
import { OrganizationsMembershipService } from "@/modules/organizations/services/organizations-membership.service"; | ||
import { | ||
Controller, | ||
UseGuards, | ||
Get, | ||
Param, | ||
ParseIntPipe, | ||
Query, | ||
Delete, | ||
Patch, | ||
Post, | ||
Body, | ||
HttpCode, | ||
HttpStatus, | ||
} from "@nestjs/common"; | ||
import { ApiOperation, ApiTags as DocsTags } from "@nestjs/swagger"; | ||
import { User } from "@prisma/client"; | ||
import { plainToClass } from "class-transformer"; | ||
|
||
import { SUCCESS_STATUS } from "@calcom/platform-constants"; | ||
import { addDwd } from "@calcom/platform-libraries"; | ||
|
||
@Controller({ | ||
path: "/v2/organizations/:orgId/dwd", | ||
version: API_VERSIONS_VALUES, | ||
}) | ||
@UseGuards(ApiAuthGuard, IsOrgGuard, RolesGuard, PlatformPlanGuard, IsAdminAPIEnabledGuard) | ||
@DocsTags("Orgs / dwd") | ||
export class OrganizationsDWDController { | ||
@Post("/") | ||
@HttpCode(HttpStatus.CREATED) | ||
@Roles("ORG_ADMIN") | ||
@PlatformPlan("ESSENTIALS") | ||
@ApiOperation({ summary: "Create a dwd" }) | ||
async createDwd( | ||
@Param("orgId", ParseIntPipe) orgId: number, | ||
@GetUser() user: User, | ||
@Body() | ||
body: { | ||
workspacePlatformSlug: string; | ||
domain: string; | ||
serviceAccountKey: { | ||
private_key: string; | ||
client_email: string; | ||
client_id: string; | ||
}; | ||
} | ||
): Promise<string> { | ||
console.log( | ||
"BODY", | ||
body?.domain, | ||
body?.workspacePlatformSlug, | ||
typeof body?.serviceAccountKey, | ||
typeof body?.serviceAccountKey | ||
); | ||
const res = await addDwd({ input: body, ctx: { user: { id: user.id, organizationId: orgId } } }); | ||
console.log("ADDED DWD", res); | ||
return "success"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters