2052 zapier integration 5 deploy twenty zapier app into the public repository (#2101)
* Add create_company Zap action * Add testing for that action * Core review returns
This commit is contained in:
@ -1,38 +1,12 @@
|
||||
import { Bundle, HttpRequestOptions, ZObject } from 'zapier-platform-core';
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
import requestDb from './utils/requestDb';
|
||||
|
||||
const testAuthentication = async (z: ZObject, bundle: Bundle) => {
|
||||
const options = {
|
||||
url: `${process.env.SERVER_BASE_URL}/graphql`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${bundle.authData.apiKey}`,
|
||||
},
|
||||
body: {
|
||||
query: 'query currentWorkspace {currentWorkspace {id displayName}}',
|
||||
},
|
||||
} satisfies HttpRequestOptions;
|
||||
|
||||
return z
|
||||
.request(options)
|
||||
.then((response) => {
|
||||
const results = response.json;
|
||||
if (results.errors) {
|
||||
throw new z.errors.Error(
|
||||
'The API Key you supplied is incorrect',
|
||||
'AuthenticationError',
|
||||
results.errors,
|
||||
);
|
||||
}
|
||||
response.throwForStatus();
|
||||
return results;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new z.errors.Error(
|
||||
'The API Key you supplied is incorrect',
|
||||
'AuthenticationError',
|
||||
err.message,
|
||||
);
|
||||
});
|
||||
return await requestDb(
|
||||
z,
|
||||
bundle,
|
||||
'query currentWorkspace {currentWorkspace {id displayName}}',
|
||||
);
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user