Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5263e774d2 |
@@ -0,0 +1,3 @@
|
||||
import listOrganizations from './list-organizations/index.js';
|
||||
|
||||
export default [listOrganizations];
|
@@ -0,0 +1,35 @@
|
||||
export default {
|
||||
name: 'List organizations',
|
||||
key: 'listOrganizations',
|
||||
|
||||
async run($) {
|
||||
const organizations = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
continuation: undefined,
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get('/v3/users/me/organizations', {
|
||||
params,
|
||||
});
|
||||
|
||||
if (data.pagination.has_more_items) {
|
||||
params.continuation = data.pagination.continuation;
|
||||
}
|
||||
|
||||
if (data.organizations) {
|
||||
for (const organization of data.organizations) {
|
||||
organizations.data.push({
|
||||
value: organization.id,
|
||||
name: organization.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.continuation);
|
||||
|
||||
return organizations;
|
||||
},
|
||||
};
|
@@ -1,6 +1,8 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Eventbrite',
|
||||
@@ -13,4 +15,6 @@ export default defineApp({
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
dynamicData,
|
||||
triggers,
|
||||
});
|
||||
|
3
packages/backend/src/apps/eventbrite/triggers/index.js
Normal file
3
packages/backend/src/apps/eventbrite/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import newEvents from './new-events/index.js';
|
||||
|
||||
export default [newEvents];
|
@@ -0,0 +1,98 @@
|
||||
import Crypto from 'crypto';
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New events',
|
||||
key: 'newEvents',
|
||||
type: 'webhook',
|
||||
description:
|
||||
'Triggers when a new event is published and live within an organization.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listOrganizations',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const dataItem = {
|
||||
raw: $.request.body,
|
||||
meta: {
|
||||
internalId: Crypto.randomUUID(),
|
||||
},
|
||||
};
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
},
|
||||
|
||||
async testRun($) {
|
||||
const organizationId = $.step.parameters.organizationId;
|
||||
|
||||
const params = {
|
||||
orderBy: 'created_desc',
|
||||
status: 'all',
|
||||
};
|
||||
|
||||
const {
|
||||
data: { events },
|
||||
} = await $.http.get(`/v3/organizations/${organizationId}/events/`, params);
|
||||
|
||||
if (events.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const computedWebhookEvent = {
|
||||
config: {
|
||||
action: 'event.published',
|
||||
user_id: events[0].organization_id,
|
||||
webhook_id: '11111111',
|
||||
endpoint_url: $.webhookUrl,
|
||||
},
|
||||
api_url: events[0].resource_uri,
|
||||
};
|
||||
|
||||
const dataItem = {
|
||||
raw: computedWebhookEvent,
|
||||
meta: {
|
||||
internalId: computedWebhookEvent.user_id,
|
||||
},
|
||||
};
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
},
|
||||
|
||||
async registerHook($) {
|
||||
const organizationId = $.step.parameters.organizationId;
|
||||
|
||||
const payload = {
|
||||
endpoint_url: $.webhookUrl,
|
||||
actions: 'event.published',
|
||||
event_id: '',
|
||||
};
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`/v3/organizations/${organizationId}/webhooks/`,
|
||||
payload
|
||||
);
|
||||
|
||||
await $.flow.setRemoteWebhookId(data.id);
|
||||
},
|
||||
|
||||
async unregisterHook($) {
|
||||
await $.http.delete(`/v3/webhooks/${$.flow.remoteWebhookId}/`);
|
||||
},
|
||||
});
|
@@ -117,7 +117,10 @@ export default defineConfig({
|
||||
text: 'Eventbrite',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/eventbrite/connection' }],
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/eventbrite/triggers' },
|
||||
{ text: 'Connection', link: '/apps/eventbrite/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Filter',
|
||||
|
12
packages/docs/pages/apps/eventbrite/triggers.md
Normal file
12
packages/docs/pages/apps/eventbrite/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/eventbrite.svg
|
||||
items:
|
||||
- name: New events
|
||||
desc: Triggers when a new event is published and live within an organization.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -11,6 +11,7 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Discord](/apps/discord/actions)
|
||||
- [Disqus](/apps/disqus/triggers)
|
||||
- [Dropbox](/apps/dropbox/actions)
|
||||
- [Eventbrite](/apps/eventbrite/triggers)
|
||||
- [Filter](/apps/filter/actions)
|
||||
- [Flickr](/apps/flickr/triggers)
|
||||
- [Formatter](/apps/formatter/actions)
|
||||
|
Reference in New Issue
Block a user