-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Aircall integration * Add helper tooltip for Aircall connector * Add post connect logic for aircall integration --------- Co-authored-by: Rodrigo Arze Leon <[email protected]>
- Loading branch information
Showing
12 changed files
with
195 additions
and
0 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,33 @@ | ||
import type {ConnectorDef, ConnectorSchemas} from '@openint/cdk' | ||
import {connHelpers, zId} from '@openint/cdk' | ||
import {R, z} from '@openint/util' | ||
|
||
export const AIRCALL_ENTITY_NAMES = ['call', 'contact'] as const | ||
|
||
export const aircallSchema = { | ||
name: z.literal('aircall'), | ||
connectionSettings: z.object({apiId: z.string(), apiToken: z.string()}), | ||
sourceOutputEntities: R.mapToObj(AIRCALL_ENTITY_NAMES, (e) => [ | ||
e, | ||
z.unknown().optional(), | ||
]), | ||
connectOutput: z.object({ | ||
providerConfigKey: zId('ccfg'), | ||
connectionId: zId('conn'), | ||
}), | ||
} satisfies ConnectorSchemas | ||
|
||
export const aircallHelpers = connHelpers(aircallSchema) | ||
|
||
export const aircallDef = { | ||
name: 'aircall', | ||
schemas: aircallSchema, | ||
metadata: { | ||
displayName: 'Aircall', | ||
stage: 'beta', | ||
verticals: ['crm'], | ||
logoUrl: '/_assets/logo-aircall.svg', | ||
}, | ||
} satisfies ConnectorDef<typeof aircallSchema> | ||
|
||
export default aircallDef |
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,4 @@ | ||
// codegen:start {preset: barrel, include: "./{*.{ts,tsx},*/index.{ts,tsx}}", exclude: "./**/*.{d,spec,test,fixture,gen,node}.{ts,tsx}"} | ||
export * from './def' | ||
export * from './server' | ||
// codegen:end |
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,12 @@ | ||
{ | ||
"name": "@openint/connector-aircall", | ||
"version": "0.0.0", | ||
"private": true, | ||
"module": "./index.ts", | ||
"dependencies": { | ||
"@openint/cdk": "workspace:*", | ||
"@openint/util": "workspace:*", | ||
"@opensdks/runtime": "^0.0.19", | ||
"@opensdks/sdk-greenhouse": "^0.0.8" | ||
} | ||
} |
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,65 @@ | ||
import {initGreenhouseSDK, type greenhouseTypes} from '@opensdks/sdk-greenhouse' | ||
import type {ConnectorServer} from '@openint/cdk' | ||
import {type aircallSchema} from './def' | ||
|
||
export type AircallSDK = ReturnType<typeof initGreenhouseSDK> | ||
|
||
export type AircallTypes = greenhouseTypes | ||
|
||
export type AircallObjectType = AircallTypes['components']['schemas'] | ||
|
||
export const aircallServer = { | ||
newInstance: ({settings}) => { | ||
// Aircall auth requires api_id and api_token | ||
const aircall = initGreenhouseSDK({ | ||
auth: { | ||
basic: { | ||
username: `${settings.apiId}:${settings.apiToken}`, | ||
password: '', | ||
}, | ||
}, | ||
}) | ||
return aircall | ||
}, | ||
postConnect: async (connectOutput, _, context) => { | ||
// Encoding credentials: | ||
const apiId = context.connection?.settings.apiId | ||
const apiToken = context.connection?.settings.apiToken | ||
const encodedCredentials = Buffer.from(`${apiId}:${apiToken}`).toString( | ||
'base64', | ||
) | ||
|
||
const headers = { | ||
Authorization: `Basic ${encodedCredentials}`, | ||
} | ||
|
||
try { | ||
const response = await fetch('https://api.aircall.io/v1/ping', { | ||
method: 'GET', | ||
headers, | ||
}) | ||
|
||
// Check if the response was successful | ||
if (!response.ok) { | ||
console.error( | ||
`HTTP error! status: ${response.status} - ${response.statusText}`, | ||
) | ||
} | ||
|
||
const body = await response.text() | ||
console.log('Response from Aircall Ping:', body) | ||
} catch (error) { | ||
console.error('Error during fetch:', error) | ||
} | ||
|
||
return { | ||
connectionExternalId: connectOutput.connectionId, | ||
providerConfigKey: connectOutput.providerConfigKey, | ||
} | ||
}, | ||
} satisfies ConnectorServer< | ||
typeof aircallSchema, | ||
ReturnType<typeof initGreenhouseSDK> | ||
> | ||
|
||
export default aircallServer |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.