feat(eventbrite): add create event action
This commit is contained in:
@@ -0,0 +1,157 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
import isEmpty from 'lodash/isEmpty.js';
|
||||||
|
import omitBy from 'lodash/omitBy.js';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Create event',
|
||||||
|
key: 'createEvent',
|
||||||
|
description: 'Creates a new event.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Organization',
|
||||||
|
key: 'organizationId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listOrganizations',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Name',
|
||||||
|
key: 'name',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Summary',
|
||||||
|
key: 'summary',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Event Start',
|
||||||
|
key: 'eventStart',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'e.g. 2018-05-12T02:00:00Z',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Event End',
|
||||||
|
key: 'eventEnd',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'e.g. 2018-05-12T02:00:00Z',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Venue',
|
||||||
|
key: 'venueId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listVenues',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.organizationId',
|
||||||
|
value: '{parameters.organizationId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Currency',
|
||||||
|
key: 'currencyId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: 'The ISO 4217 currency code.',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listCurrency',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Listed?',
|
||||||
|
key: 'listed',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: 'Can this event be found on Eventbrite?',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{ label: 'Yes', value: 'true' },
|
||||||
|
{ label: 'No', value: 'false' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const {
|
||||||
|
organizationId,
|
||||||
|
name,
|
||||||
|
summary,
|
||||||
|
eventStart,
|
||||||
|
eventEnd,
|
||||||
|
venueId,
|
||||||
|
currencyId,
|
||||||
|
listed,
|
||||||
|
} = $.step.parameters;
|
||||||
|
|
||||||
|
const fields = {
|
||||||
|
name: {
|
||||||
|
html: name,
|
||||||
|
},
|
||||||
|
summary,
|
||||||
|
start: {
|
||||||
|
timezone: 'UTC',
|
||||||
|
utc: eventStart,
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
timezone: 'UTC',
|
||||||
|
utc: eventEnd,
|
||||||
|
},
|
||||||
|
currency: currencyId,
|
||||||
|
venue_id: venueId,
|
||||||
|
listed,
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredFields = omitBy(fields, isEmpty);
|
||||||
|
|
||||||
|
const { data } = await $.http.post(
|
||||||
|
`/v3/organizations/${organizationId}/events/`,
|
||||||
|
{
|
||||||
|
event: filteredFields,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
3
packages/backend/src/apps/eventbrite/actions/index.js
Normal file
3
packages/backend/src/apps/eventbrite/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import createEvent from './create-event/index.js';
|
||||||
|
|
||||||
|
export default [createEvent];
|
@@ -1,4 +1,5 @@
|
|||||||
import listEvents from './list-events/index.js';
|
import listEvents from './list-events/index.js';
|
||||||
import listOrganizations from './list-organizations/index.js';
|
import listOrganizations from './list-organizations/index.js';
|
||||||
|
import listVenues from './list-venues/index.js';
|
||||||
|
|
||||||
export default [listEvents, listOrganizations];
|
export default [listEvents, listOrganizations, listVenues];
|
||||||
|
@@ -0,0 +1,43 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List venues',
|
||||||
|
key: 'listVenues',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const venues = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
const organizationId = $.step.parameters.organizationId;
|
||||||
|
|
||||||
|
if (!organizationId) {
|
||||||
|
return venues;
|
||||||
|
}
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
continuation: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
do {
|
||||||
|
const { data } = await $.http.get(
|
||||||
|
`/v3/organizations/${organizationId}/venues/`,
|
||||||
|
{
|
||||||
|
params,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.pagination.has_more_items) {
|
||||||
|
params.continuation = data.pagination.continuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.venues) {
|
||||||
|
for (const venue of data.venues) {
|
||||||
|
venues.data.push({
|
||||||
|
value: venue.id,
|
||||||
|
name: venue.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (params.continuation);
|
||||||
|
|
||||||
|
return venues;
|
||||||
|
},
|
||||||
|
};
|
@@ -3,6 +3,7 @@ import addAuthHeader from './common/add-auth-header.js';
|
|||||||
import auth from './auth/index.js';
|
import auth from './auth/index.js';
|
||||||
import dynamicData from './dynamic-data/index.js';
|
import dynamicData from './dynamic-data/index.js';
|
||||||
import triggers from './triggers/index.js';
|
import triggers from './triggers/index.js';
|
||||||
|
import actions from './actions/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Eventbrite',
|
name: 'Eventbrite',
|
||||||
@@ -17,4 +18,5 @@ export default defineApp({
|
|||||||
auth,
|
auth,
|
||||||
dynamicData,
|
dynamicData,
|
||||||
triggers,
|
triggers,
|
||||||
|
actions,
|
||||||
});
|
});
|
||||||
|
@@ -119,6 +119,7 @@ export default defineConfig({
|
|||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
{ text: 'Triggers', link: '/apps/eventbrite/triggers' },
|
{ text: 'Triggers', link: '/apps/eventbrite/triggers' },
|
||||||
|
{ text: 'Actions', link: '/apps/eventbrite/actions' },
|
||||||
{ text: 'Connection', link: '/apps/eventbrite/connection' },
|
{ text: 'Connection', link: '/apps/eventbrite/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
12
packages/docs/pages/apps/eventbrite/actions.md
Normal file
12
packages/docs/pages/apps/eventbrite/actions.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/eventbrite.svg
|
||||||
|
items:
|
||||||
|
- name: Create event
|
||||||
|
desc: Creates a new event.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
Reference in New Issue
Block a user