Skip to content

Commit 3a7588b

Browse files
authored
New Components - eventzilla (#16838)
* new components * pnpm-lock.yaml
1 parent a2f00a6 commit 3a7588b

File tree

10 files changed

+345
-7
lines changed

10 files changed

+345
-7
lines changed
Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,106 @@
1+
import { axios } from "@pipedream/platform";
2+
const DEFAULT_LIMIT = 20;
3+
const MAX_LIMIT = 100;
4+
15
export default {
26
type: "app",
37
app: "eventzilla",
4-
propDefinitions: {},
8+
propDefinitions: {
9+
eventId: {
10+
type: "string",
11+
label: "Event ID",
12+
description: "The ID of the event",
13+
async options({ page }) {
14+
const { events } = await this.listEvents({
15+
params: {
16+
limit: DEFAULT_LIMIT,
17+
offset: page * DEFAULT_LIMIT,
18+
},
19+
});
20+
if (!events?.length) {
21+
return [];
22+
}
23+
return events.map((event) => ({
24+
label: event.title,
25+
value: event.id,
26+
}));
27+
},
28+
},
29+
},
530
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
31+
_baseUrl() {
32+
return "https://www.eventzillaapi.net/api/v2";
33+
},
34+
_makeRequest({
35+
$ = this, path, ...opts
36+
}) {
37+
return axios($, {
38+
url: `${this._baseUrl()}${path}`,
39+
headers: {
40+
"x-api-key": `${this.$auth.api_key}`,
41+
},
42+
...opts,
43+
});
44+
},
45+
listEvents(opts = {}) {
46+
return this._makeRequest({
47+
path: "/events",
48+
...opts,
49+
});
50+
},
51+
listAttendees({
52+
eventId, ...opts
53+
}) {
54+
return this._makeRequest({
55+
path: `/events/${eventId}/attendees`,
56+
...opts,
57+
});
58+
},
59+
listEventTransactions({
60+
eventId, ...opts
61+
}) {
62+
return this._makeRequest({
63+
path: `/events/${eventId}/transactions`,
64+
...opts,
65+
});
66+
},
67+
async *paginate({
68+
fn, args, resourceKey, max,
69+
}) {
70+
args = {
71+
...args,
72+
params: {
73+
...args?.params,
74+
limit: MAX_LIMIT,
75+
offset: 0,
76+
},
77+
};
78+
let total, count = 0;
79+
do {
80+
const response = await fn(args);
81+
const items = resourceKey
82+
? response[resourceKey]
83+
: response;
84+
if (!items?.length) {
85+
return;
86+
}
87+
for (const item of items) {
88+
yield item;
89+
if (max && ++count >= max) {
90+
return;
91+
}
92+
}
93+
args.params.offset += args.params.limit;
94+
total = items?.length;
95+
} while (total === args.params.limit);
96+
},
97+
async getPaginatedResources(opts = {}) {
98+
const items = [];
99+
const results = this.paginate(opts);
100+
for await (const item of results) {
101+
items.push(item);
102+
}
103+
return items;
9104
},
10105
},
11106
};

components/eventzilla/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/eventzilla",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Pipedream eventzilla Components",
55
"main": "eventzilla.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.0"
16+
"@pipedream/platform": "^3.0.3"
1717
}
1818
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import eventzilla from "../../eventzilla.app.mjs";
2+
import {
3+
ConfigurationError, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
4+
} from "@pipedream/platform";
5+
6+
export default {
7+
props: {
8+
eventzilla,
9+
db: "$.service.db",
10+
timer: {
11+
type: "$.interface.timer",
12+
default: {
13+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
14+
},
15+
},
16+
},
17+
methods: {
18+
getArgs() {
19+
return {};
20+
},
21+
getResourceKey() {
22+
return;
23+
},
24+
generateMeta(item) {
25+
return {
26+
id: item.id,
27+
summary: this.getSummary(item),
28+
ts: Date.now(),
29+
};
30+
},
31+
getResourceFn() {
32+
throw new ConfigurationError("getResourceFn is not implemented");
33+
},
34+
getSummary() {
35+
throw new ConfigurationError("getSummary is not implemented");
36+
},
37+
},
38+
async run() {
39+
const fn = this.getResourceFn();
40+
const args = this.getArgs();
41+
const resourceKey = this.getResourceKey();
42+
43+
try {
44+
let items = await this.eventzilla.getPaginatedResources({
45+
fn,
46+
args,
47+
resourceKey,
48+
});
49+
50+
if (!items?.length) {
51+
return;
52+
}
53+
54+
for (const item of items) {
55+
const meta = this.generateMeta(item);
56+
this.$emit(item, meta);
57+
}
58+
} catch (error) {
59+
if (error.message) {
60+
console.log(JSON.parse(error.message).message);
61+
} else {
62+
throw new ConfigurationError(error);
63+
}
64+
}
65+
},
66+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "eventzilla-new-attendee-added",
7+
name: "New Attendee Added",
8+
description: "Emit new event when a new attendee is added to an event in Eventzilla. [See the documentation](https://developer.eventzilla.net/docs/)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
props: {
13+
...common.props,
14+
eventId: {
15+
propDefinition: [
16+
common.props.eventzilla,
17+
"eventId",
18+
],
19+
},
20+
},
21+
methods: {
22+
...common.methods,
23+
getResourceFn() {
24+
return this.eventzilla.listAttendees;
25+
},
26+
getArgs() {
27+
return {
28+
eventId: this.eventId,
29+
};
30+
},
31+
getResourceKey() {
32+
return "attendees";
33+
},
34+
getSummary(item) {
35+
return `New Attendee ID: ${item.id}`;
36+
},
37+
},
38+
sampleEmit,
39+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default {
2+
"first_name": "Test",
3+
"last_name": "User",
4+
"ticket_type": "ticket type",
5+
"bar_code": "486608160870031397",
6+
"is_attended": "No",
7+
"questions": [],
8+
"refno": "20255486608-9518980",
9+
"id": 2145905812,
10+
"event_date": "2025-05-29T09:00:00",
11+
"event_id": 2138658701,
12+
"transaction_date": "2025-05-27T16:27:56",
13+
"transaction_amount": 0,
14+
"transaction_status": "Confirmed",
15+
"email": "",
16+
"buyer_first_name": "Test",
17+
"buyer_last_name": "User",
18+
"payment_type": "Free"
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "eventzilla-new-event-created",
7+
name: "New Event Created",
8+
description: "Emit new event when a new event is created in Eventzilla. [See the documentation](https://developer.eventzilla.net/docs/)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getResourceFn() {
15+
return this.eventzilla.listEvents;
16+
},
17+
getResourceKey() {
18+
return "events";
19+
},
20+
getSummary(item) {
21+
return `New Event ID: ${item.id}`;
22+
},
23+
},
24+
sampleEmit,
25+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export default {
2+
"id": 2138658701,
3+
"title": "event1",
4+
"description": "test event",
5+
"currency": "$",
6+
"start_date": "2025-05-29T00:00:00",
7+
"start_time": "09:00",
8+
"end_date": "2025-05-29T00:00:00",
9+
"end_time": "17:00",
10+
"time_zone": "(GMT-0500) United States (New York) Time",
11+
"tickets_sold": 0,
12+
"tickets_total": 100,
13+
"status": "Live",
14+
"show_remaining": false,
15+
"twitter_hashtag": "",
16+
"utc_offset": "-04:00",
17+
"invite_code": "",
18+
"url": "https://events.eventzilla.net/e/event1-2138658701",
19+
"logo_url": "",
20+
"bgimage_url": "https://ucarecdn.com/30c1b4e6-c63b-496a-af64-e29456aaaa1f/-/crop/1200x401/0,113/-/preview/",
21+
"venue": "virtual event",
22+
"dateid": 2138283242,
23+
"categories": "Virtual Event",
24+
"language": "en",
25+
"description_html": "<p>test event</p>",
26+
"timezone_code": "EDT"
27+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "eventzilla-new-event-transaction",
7+
name: "New Event Transaction",
8+
description: "Emit new event when a new transaction occurs for an event in Eventzilla. [See the documentation](https://developer.eventzilla.net/docs/)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
props: {
13+
...common.props,
14+
eventId: {
15+
propDefinition: [
16+
common.props.eventzilla,
17+
"eventId",
18+
],
19+
},
20+
},
21+
methods: {
22+
...common.methods,
23+
getResourceFn() {
24+
return this.eventzilla.listEventTransactions;
25+
},
26+
getArgs() {
27+
return {
28+
eventId: this.eventId,
29+
};
30+
},
31+
getResourceKey() {
32+
return "transactions";
33+
},
34+
getSummary(item) {
35+
return `New Event Transaction ID: ${item.checkout_id}`;
36+
},
37+
generateMeta(item) {
38+
return {
39+
id: item.checkout_id,
40+
summary: this.getSummary(item),
41+
ts: Date.now(),
42+
};
43+
},
44+
},
45+
sampleEmit,
46+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export default {
2+
"refno": "20255486608-9518980",
3+
"checkout_id": 2146370777,
4+
"transaction_date": "2025-05-27T16:27:56",
5+
"transaction_amount": 0,
6+
"tickets_in_transaction": 1,
7+
"event_date": "2025-05-29T14:00:00",
8+
"transaction_status": "Confirmed",
9+
"user_id": 2135013619,
10+
"event_id": 486608,
11+
"title": "event1",
12+
"email": "",
13+
"buyer_first_name": "Test",
14+
"buyer_last_name": "User",
15+
"promo_code": "",
16+
"payment_type": "Free",
17+
"comments": "",
18+
"transaction_tax": 0,
19+
"transaction_discount": 0,
20+
"eventzilla_fee": 0
21+
}

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)