Skip to content

Commit 11446b8

Browse files
luancazarinecoderabbitai[bot]michelle0927
authored
12502 components ticket source (#19006)
* Update Ticket Source component to version 0.1.0, adding new actions for creating customers, retrieving events, bookings, and listing customers and events. Introduced pagination for customer and event retrieval, and added constants for limiting results. * pnpm update * Update components/ticket_source/actions/list-bookings-for-date/list-bookings-for-date.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update pagination logic in ticket source component to increment page number by 1 for event, event dates, and bookings retrieval. * Refactor summary message formatting in list-bookings-for-date action for improved readability. * Add maxResults parameter to list-bookings-for-date action for pagination control * Update components/ticket_source/actions/list-bookings-for-date/list-bookings-for-date.mjs * pnpm update --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
1 parent e7b4610 commit 11446b8

File tree

10 files changed

+540
-15
lines changed

10 files changed

+540
-15
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import ticketSource from "../../ticket_source.app.mjs";
2+
3+
export default {
4+
key: "ticket_source-create-customer",
5+
name: "Create Customer",
6+
description: "Creates a new customer. [See the documentation](https://reference.ticketsource.io/#/operations/post-customer)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
ticketSource,
16+
firstName: {
17+
type: "string",
18+
label: "First Name",
19+
description: "The first name of the customer",
20+
optional: true,
21+
},
22+
lastName: {
23+
type: "string",
24+
label: "Last Name",
25+
description: "The last name of the customer",
26+
optional: true,
27+
},
28+
addressLine1: {
29+
type: "string",
30+
label: "Address Line 1",
31+
description: "The first line of the customer's address",
32+
optional: true,
33+
},
34+
addressLine2: {
35+
type: "string",
36+
label: "Address Line 2",
37+
description: "The second line of the customer's address",
38+
optional: true,
39+
},
40+
addressLine3: {
41+
type: "string",
42+
label: "Address Line 3",
43+
description: "The third line of the customer's address",
44+
optional: true,
45+
},
46+
addressLine4: {
47+
type: "string",
48+
label: "Address Line 4",
49+
description: "The fourth line of the customer's address",
50+
optional: true,
51+
},
52+
addressPostcode: {
53+
type: "string",
54+
label: "Address Postcode",
55+
description: "The postcode of the customer's address",
56+
optional: true,
57+
},
58+
telephone: {
59+
type: "string",
60+
label: "Telephone",
61+
description: "The telephone number of the customer",
62+
optional: true,
63+
},
64+
email: {
65+
type: "string",
66+
label: "Email",
67+
description: "The email address of the customer",
68+
},
69+
membershipIdentifier: {
70+
type: "string",
71+
label: "Membership Identifier",
72+
description: "The identifier of the customer's membership",
73+
optional: true,
74+
},
75+
membershipStartDate: {
76+
type: "string",
77+
label: "Membership Start Date",
78+
description: "The start date of the customer's membership. **Format: YYYY-MM-DD**",
79+
optional: true,
80+
},
81+
membershipEndDate: {
82+
type: "string",
83+
label: "Membership End Date",
84+
description: "The end date of the customer's membership. **Format: YYYY-MM-DD**",
85+
optional: true,
86+
},
87+
emailConsent: {
88+
type: "boolean",
89+
label: "Email Consent",
90+
description: "Whether the customer consents to receive email marketing",
91+
optional: true,
92+
},
93+
smsConsent: {
94+
type: "boolean",
95+
label: "SMS Consent",
96+
description: "Whether the customer consents to receive SMS marketing",
97+
optional: true,
98+
},
99+
postConsent: {
100+
type: "boolean",
101+
label: "Post Consent",
102+
description: "Whether the customer consents to receive postal marketing",
103+
optional: true,
104+
},
105+
},
106+
async run({ $ }) {
107+
const { data: response } = await this.ticketSource.createCustomer({
108+
$,
109+
data: {
110+
data: {
111+
type: "customer",
112+
attributes: {
113+
first_name: this.firstName,
114+
last_name: this.lastName,
115+
address: {
116+
line_1: this.addressLine1,
117+
line_2: this.addressLine2,
118+
line_3: this.addressLine3,
119+
line_4: this.addressLine4,
120+
postcode: this.addressPostcode,
121+
},
122+
telephone: this.telephone,
123+
email: this.email,
124+
membership: {
125+
identifier: this.membershipIdentifier,
126+
start_date: this.membershipStartDate,
127+
end_date: this.membershipEndDate,
128+
},
129+
consent: {
130+
email: this.emailConsent,
131+
sms: this.smsConsent,
132+
post: this.postConsent,
133+
},
134+
},
135+
},
136+
},
137+
});
138+
$.export("$summary", `Successfully created customer: ${response.id}`);
139+
return response;
140+
},
141+
};
142+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import ticketSource from "../../ticket_source.app.mjs";
2+
3+
export default {
4+
key: "ticket_source-get-booking",
5+
name: "Get Booking",
6+
description: "Retrieves details of a specific booking. [See the documentation](https://reference.ticketsource.io/#/operations/get-booking)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
ticketSource,
16+
eventId: {
17+
propDefinition: [
18+
ticketSource,
19+
"eventId",
20+
],
21+
},
22+
eventDate: {
23+
propDefinition: [
24+
ticketSource,
25+
"eventDate",
26+
({ eventId }) => ({
27+
eventId,
28+
}),
29+
],
30+
},
31+
bookingId: {
32+
propDefinition: [
33+
ticketSource,
34+
"bookingId",
35+
({ eventDate }) => ({
36+
eventDate,
37+
}),
38+
],
39+
},
40+
},
41+
async run({ $ }) {
42+
const { data: response } = await this.ticketSource.getBooking({
43+
$,
44+
bookingId: this.bookingId,
45+
});
46+
47+
$.export("$summary", `Successfully retrieved booking with ID ${this.bookingId}`);
48+
return response;
49+
},
50+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import ticketSource from "../../ticket_source.app.mjs";
2+
3+
export default {
4+
key: "ticket_source-get-event",
5+
name: "Get Event",
6+
description: "Retrieves details of a specific event. [See the documentation](https://reference.ticketsource.io/)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
ticketSource,
16+
eventId: {
17+
propDefinition: [
18+
ticketSource,
19+
"eventId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const { data: response } = await this.ticketSource.getEvent({
25+
$,
26+
eventId: this.eventId,
27+
});
28+
$.export("$summary", `Successfully retrieved event with ID ${this.eventId}`);
29+
return response;
30+
},
31+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import ticketSource from "../../ticket_source.app.mjs";
2+
3+
export default {
4+
key: "ticket_source-list-bookings-for-date",
5+
name: "List Bookings for Date",
6+
description: "Retrieves all bookings for a specific event date. [See the documentation](https://reference.ticketsource.io/#/operations/get-date-bookings)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
ticketSource,
16+
eventId: {
17+
propDefinition: [
18+
ticketSource,
19+
"eventId",
20+
],
21+
},
22+
eventDate: {
23+
propDefinition: [
24+
ticketSource,
25+
"eventDate",
26+
({ eventId }) => ({
27+
eventId,
28+
}),
29+
],
30+
},
31+
maxResults: {
32+
type: "integer",
33+
label: "Max Results",
34+
description: "The maximum number of results to return",
35+
default: 100,
36+
},
37+
},
38+
async run({ $ }) {
39+
const response = this.ticketSource.paginate({
40+
$,
41+
fn: this.ticketSource.listBookingsForDate,
42+
eventDate: this.eventDate,
43+
maxResults: this.maxResults,
44+
});
45+
46+
let responseArray = [];
47+
for await (const item of response) {
48+
responseArray.push(item);
49+
}
50+
51+
$.export("$summary", `Successfully retrieved ${responseArray.length} booking${responseArray.length === 1
52+
? ""
53+
: "s"} for date with ID ${this.eventDate}`);
54+
return responseArray;
55+
},
56+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import ticketSource from "../../ticket_source.app.mjs";
2+
3+
export default {
4+
key: "ticket_source-list-customers",
5+
name: "List Customers",
6+
description: "Retrieves a list of all customers. [See the documentation](https://reference.ticketsource.io/#/operations/get-customers)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
ticketSource,
16+
maxResults: {
17+
type: "integer",
18+
label: "Max Results",
19+
description: "Optionally limit the maximum number of customers to return. Leave blank to retrieve all customers.",
20+
optional: true,
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = this.ticketSource.paginate({
25+
$,
26+
fn: this.ticketSource.listCustomers,
27+
maxResults: this.maxResults,
28+
});
29+
30+
const customers = [];
31+
for await (const customer of response) {
32+
customers.push(customer);
33+
}
34+
35+
$.export("$summary", `Successfully retrieved ${customers.length} customer${customers.length === 1
36+
? ""
37+
: "s"}`);
38+
return customers;
39+
},
40+
};
41+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import ticketSource from "../../ticket_source.app.mjs";
2+
3+
export default {
4+
key: "ticket_source-list-events",
5+
name: "List Events",
6+
description: "Retrieves a list of all events. [See the documentation](https://reference.ticketsource.io/#/operations/get-events/)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
ticketSource,
16+
maxResults: {
17+
type: "integer",
18+
label: "Max Results",
19+
description: "Optionally limit the maximum number of events to return. Leave blank to retrieve all events.",
20+
optional: true,
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = this.ticketSource.paginate({
25+
$,
26+
fn: this.ticketSource.listEvents,
27+
maxResults: this.maxResults,
28+
});
29+
30+
const events = [];
31+
for await (const event of response) {
32+
events.push(event);
33+
}
34+
35+
$.export("$summary", `Successfully retrieved ${events.length} event${events.length === 1
36+
? ""
37+
: "s"}`);
38+
return events;
39+
},
40+
};
41+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const LIMIT = 100;

components/ticket_source/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/ticket_source",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Ticket Source Components",
55
"main": "ticket_source.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.1"
1417
}
1518
}

0 commit comments

Comments
 (0)