-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: V2 API endpoint create phone call (#16528)
* refactor: V2 API endpoint create phone call * fix: type err * fix: type and build err * chore: change default value * chore: move it to another route * test: for create phone call * chore: undo constant * chore: remove test * fix: make begin_message optional * chore: improvements * chore: begin message * chore: remove unused import * chore: bump platform libraries with handleCreatePhoneCall * chore: improvement --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Benny Joo <sldisek783@gmail.com> Co-authored-by: Morgan Vernay <morgan@cal.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com>
- Loading branch information
1 parent
6e237ae
commit 5f2b4ae
Showing
14 changed files
with
443 additions
and
124 deletions.
There are no files selected for viewing
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
71 changes: 71 additions & 0 deletions
71
apps/api/v2/src/ee/event-types/event-types_2024_06_14/inputs/create-phone-call.input.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,71 @@ | ||
import { ApiProperty as DocsProperty } from "@nestjs/swagger"; | ||
import { Transform } from "class-transformer"; | ||
import { IsString, IsBoolean, IsOptional, IsEnum, Matches } from "class-validator"; | ||
|
||
export enum TemplateType { | ||
CHECK_IN_APPOINTMENT = "CHECK_IN_APPOINTMENT", | ||
CUSTOM_TEMPLATE = "CUSTOM_TEMPLATE", | ||
} | ||
|
||
export class CreatePhoneCallInput { | ||
@IsString() | ||
@Matches(/^\+[1-9]\d{1,14}$/, { | ||
message: | ||
"Invalid phone number format. Expected format: +<CountryCode><PhoneNumber> with no spaces or separators.", | ||
}) | ||
@DocsProperty({ description: "Your phone number" }) | ||
yourPhoneNumber!: string; | ||
|
||
@IsString() | ||
@Matches(/^\+[1-9]\d{1,14}$/, { | ||
message: | ||
"Invalid phone number format. Expected format: +<CountryCode><PhoneNumber> with no spaces or separators.", | ||
}) | ||
@DocsProperty({ description: "Number to call" }) | ||
numberToCall!: string; | ||
|
||
@IsString() | ||
@DocsProperty({ description: "CAL API Key" }) | ||
calApiKey!: string; | ||
|
||
@IsBoolean() | ||
@DocsProperty({ description: "Enabled status", default: true }) | ||
enabled = true; | ||
|
||
@IsEnum(TemplateType) | ||
@DocsProperty({ description: "Template type", enum: TemplateType }) | ||
templateType: TemplateType = TemplateType.CUSTOM_TEMPLATE; | ||
|
||
@IsOptional() | ||
@IsString() | ||
@DocsProperty({ description: "Scheduler name" }) | ||
schedulerName?: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
@Transform(({ value }) => (value ? value : undefined)) | ||
@DocsProperty({ description: "Guest name" }) | ||
guestName?: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
@Transform(({ value }) => (value ? value : undefined)) | ||
@DocsProperty({ description: "Guest email" }) | ||
guestEmail?: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
@Transform(({ value }) => (value ? value : undefined)) | ||
@DocsProperty({ description: "Guest company" }) | ||
guestCompany?: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
@DocsProperty({ description: "Begin message" }) | ||
beginMessage?: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
@DocsProperty({ description: "General prompt" }) | ||
generalPrompt?: string; | ||
} |
28 changes: 28 additions & 0 deletions
28
apps/api/v2/src/ee/event-types/event-types_2024_06_14/outputs/create-phone-call.output.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,28 @@ | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { Type } from "class-transformer"; | ||
import { IsEnum, IsString, ValidateNested } from "class-validator"; | ||
|
||
import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants"; | ||
|
||
class Data { | ||
@IsString() | ||
@ApiProperty() | ||
callId!: string; | ||
|
||
@IsString() | ||
@ApiProperty() | ||
agentId!: string; | ||
} | ||
|
||
export class CreatePhoneCallOutput { | ||
@ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] }) | ||
@IsEnum([SUCCESS_STATUS, ERROR_STATUS]) | ||
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS; | ||
|
||
@ApiProperty({ | ||
type: Data, | ||
}) | ||
@ValidateNested() | ||
@Type(() => Data) | ||
data!: Data; | ||
} |
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
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
Oops, something went wrong.