Skip to content

Commit 0288102

Browse files
authored
HubSpot disposition action (#108)
* HubSpot disposition action * moving to client
1 parent bef44cb commit 0288102

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
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.75",
3+
"version": "0.0.76",
44
"description": "Vessel integrations",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { action } from '@/sdk';
2+
import { z } from 'zod';
3+
import client from '../../client';
4+
5+
export default action(
6+
'calls-dispositions',
7+
{
8+
operation: 'dispositions',
9+
resource: 'calls',
10+
mutation: false,
11+
schema: z.object({}),
12+
scopes: [],
13+
},
14+
async ({ auth }) => {
15+
const result = await client.calls.dispositions(auth, {});
16+
return {
17+
result: {
18+
dispositions: result.data.map((disposition) => ({
19+
id: disposition.id,
20+
label: disposition.label,
21+
})),
22+
},
23+
$native: result.$native,
24+
};
25+
},
26+
);

src/platforms/hubspot/client.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as z from 'zod';
55
import { API_VERSION, BASE_URL, HUBSPOT_MAX_PAGE_SIZE } from './constants';
66
import {
77
BatchReadObjectInput,
8+
callDispositionsSchema,
89
callProperties,
910
companyProperties,
1011
contactProperties,
@@ -241,11 +242,18 @@ const makeClient = () => {
241242
hubspotEmailSchema,
242243
emailProperties,
243244
),
244-
calls: crud<HubspotCallCreate, HubspotCallUpdate, HubspotCall>(
245-
'objects/calls',
246-
hubspotCallSchema,
247-
callProperties,
248-
),
245+
calls: {
246+
...crud<HubspotCallCreate, HubspotCallUpdate, HubspotCall>(
247+
'objects/calls',
248+
hubspotCallSchema,
249+
callProperties,
250+
),
251+
dispositions: request(({}) => ({
252+
url: `/calling/v1/dispositions`,
253+
method: 'GET',
254+
schema: callDispositionsSchema,
255+
})),
256+
},
249257
// HubSpot only has support for contact lists in v1 of the API
250258
contactLists: {
251259
find: request(({ id }: { id: string }) => ({

src/platforms/hubspot/schemas.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ export type HubspotEmailUpdate = z.infer<typeof hubspotEmailUpdateSchema> & {
410410
// -
411411
// Calls
412412
// -
413+
export const callDispositionsSchema = z.array(
414+
z.object({
415+
label: z.string(),
416+
id: z.string(),
417+
}),
418+
);
419+
413420
const callPropertiesSchema = z
414421
.object({
415422
hs_call_disposition: z.string(),

0 commit comments

Comments
 (0)