Skip to content

Commit

Permalink
chore: update openint requests for sync service (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinsandilya authored May 2, 2024
1 parent 38556e1 commit eb7d02b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/backend/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const config = {
BITBUCKET_CLIENT_ID: process.env.BITBUCKET_CLIENT_ID!,
BITBUCKET_CLIENT_SECRET: process.env.BITBUCKET_CLIENT_SECRET!,
OPEN_INT_API_KEY: process.env.OPEN_INT_API_KEY,
OPEN_INT_BASE_API_URL: process.env.OPEN_INT_BASE_API_URL,
TWENTY_ACCOUNT_ID: process.env.TWENTY_ACCOUNT_ID,
};

Expand Down
17 changes: 9 additions & 8 deletions packages/backend/services/custom/twenty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { veniceSdkDef } = require('@opensdks/sdk-venice');
const syncTwentyConnection = async (connection: Connection, connectionAPIKey: string) => {
const connectionId = connection.t_id;
const openIntApiKey = config.OPEN_INT_API_KEY;
const openIntBaseApiUrl = config.OPEN_INT_BASE_API_URL;
if (!config.OPEN_INT_API_KEY || !connectionAPIKey) {
console.log('Credentials absent to make this sync happen for: ', connection.t_id, ' returning early');
return;
Expand All @@ -15,7 +16,7 @@ const syncTwentyConnection = async (connection: Connection, connectionAPIKey: st
...veniceSdkDef,
oasMeta: {
...veniceSdkDef.oasMeta,
// servers: [{ url: 'http://localhost:4000/api/v0' }],
servers: [{ url: `${openIntBaseApiUrl}/api/v0` }],
},
},
{
Expand Down Expand Up @@ -117,6 +118,7 @@ const syncTwentyConnection = async (connection: Connection, connectionAPIKey: st
id: `pipe_${connectionId}`,
sourceId: revertResource?.data.id,
destinationId: twentyResource?.data.id,
streams: { contact: {}, company: {}, deal: {} },
},
});
syncPipeline.data = [createdPipeline.data];
Expand All @@ -125,17 +127,16 @@ const syncTwentyConnection = async (connection: Connection, connectionAPIKey: st

console.log('PIPELINE', syncPipeline?.data[0]);

void venice
await venice
.POST(`/core/pipeline/${syncPipeline?.data[0]?.id}/_sync`, {
params: {
async: true,
path: { id: syncPipeline?.data[0]?.id },
},
body: {
async: false,
},
})
.then()
.catch((e: Error) => console.log('Error', e))
.finally(() => {
console.log('TRIGGERED');
});
.catch(() => console.log('TRIGGERED'));
};

export { syncTwentyConnection };

0 comments on commit eb7d02b

Please sign in to comment.