Skip to content

Commit dcb64b4

Browse files
authored
Some dialer fixes (#64)
1 parent 2f203e8 commit dcb64b4

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vesselapi/integrations",
3-
"version": "0.0.49",
3+
"version": "0.0.50",
44
"description": "Vessel integrations",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/platforms/dialpad/client.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const BASE_URL = `${API_DOMAIN}/${API_VERSION}` as HttpsUrl;
1818

1919
const request = makeRequestFactory(async (auth, options) => ({
2020
...options,
21-
url: `${BASE_URL}/${options.url}`,
21+
url: `${BASE_URL}${options.url}`,
2222
headers: {
2323
...options.headers,
2424
Accept: 'application/json',
@@ -74,11 +74,15 @@ const makeClient = (): DialpadClient => {
7474
list: listObject('contacts', listResponseSchema(dialpadContactSchema)),
7575
create: createObject<DialpadContactCreate>(
7676
'contacts',
77-
dialpadContactSchema,
77+
dialpadContactSchema.partial().required({
78+
id: true,
79+
}),
7880
),
7981
update: updateObject<DialpadContactUpdate>(
8082
'contacts',
81-
dialpadContactSchema,
83+
dialpadContactSchema.partial().required({
84+
id: true,
85+
}),
8286
),
8387
},
8488
calls: {

src/platforms/dialpad/schemas.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const dialpadUserSchema = z
3333
license: z.string(),
3434
muted: z.boolean(),
3535
office_id: z.string(),
36-
phone_numbers: z.array(z.string()),
36+
phone_numbers: z.array(custom.formattedPhoneNumber()),
3737
state: z.string(),
3838
timezone: z.string(),
3939
})
@@ -49,9 +49,9 @@ export const dialpadContactSchema = z.object({
4949
extension: z.string(),
5050
job_title: z.string(),
5151
owner_id: z.string(),
52-
phones: z.array(z.string()),
52+
phones: z.array(custom.formattedPhoneNumber()),
5353
primary_email: z.string(),
54-
primary_phone: z.string(),
54+
primary_phone: custom.formattedPhoneNumber(),
5555
type: z.enum(['shared', 'local']),
5656
urls: z.array(z.string()),
5757
});
@@ -119,7 +119,7 @@ const targetSchema = z
119119
email: z.string(),
120120
id: z.string(),
121121
name: z.string(),
122-
phone: z.string(),
122+
phone: custom.formattedPhoneNumber(),
123123
type: z.string(),
124124
})
125125
.passthrough();

src/platforms/ringcentral/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const BASE_URL = `${API_DOMAIN}/${API_VERSION}` as HttpsUrl;
1919

2020
const request = makeRequestFactory(async (auth, options) => ({
2121
...options,
22-
url: `${BASE_URL}/${options.url}`,
22+
url: `${BASE_URL}${options.url}`,
2323
headers: {
2424
...options.headers,
2525
Authorization: `Bearer ${await auth.getToken()}`,

src/platforms/ringcentral/schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const ringcentralContactSchema = z
8787
lastName: z.string(),
8888
company: z.string().optional(),
8989
email: z.string().optional(),
90-
businessPhone: z.string(),
90+
businessPhone: custom.formattedPhoneNumber(),
9191
})
9292
.passthrough();
9393

src/sdk/validators.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const json = () => z.object({}).catchall(z.any()).optional();
1515
export const formattedPhoneNumber = (format?: NumberFormat) =>
1616
z
1717
.string()
18-
.refine((value) => {
18+
.refine((value?) => {
19+
if (!value) return false;
1920
return parsePhoneNumber(value)?.isValid();
2021
})
2122
.transform((value) => {

0 commit comments

Comments
 (0)