Skip to content

Commit 434f7dc

Browse files
authored
New Components - teach_n_go (#14331)
* teach_n_go init * [Components] teach_n_go #14312 Sources - New Class Created - New Student Registration Actions - Create Prospect - Create Student * pnpm update
1 parent 6da9785 commit 434f7dc

File tree

12 files changed

+663
-7
lines changed

12 files changed

+663
-7
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import app from "../../teach_n_go.app.mjs";
2+
3+
export default {
4+
key: "teach_n_go-create-prospect",
5+
name: "Create Prospect",
6+
description: "Creates a new prospect inside Teach 'n Go. [See the documentation](https://intercom.help/teach-n-go/en/articles/5750592-prospect-registration-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
firstName: {
12+
propDefinition: [
13+
app,
14+
"firstName",
15+
],
16+
},
17+
lastName: {
18+
propDefinition: [
19+
app,
20+
"lastName",
21+
],
22+
},
23+
mobilePhone: {
24+
type: "integer",
25+
label: "Mobile Phone",
26+
description: "The prospect's contact number.",
27+
optional: true,
28+
},
29+
emailAddress: {
30+
propDefinition: [
31+
app,
32+
"emailAddress",
33+
],
34+
optional: true,
35+
},
36+
description: {
37+
type: "string",
38+
label: "Description",
39+
description: "General information you wish to capture.",
40+
optional: true,
41+
},
42+
gender: {
43+
propDefinition: [
44+
app,
45+
"gender",
46+
],
47+
optional: true,
48+
},
49+
dateOfBirth: {
50+
propDefinition: [
51+
app,
52+
"dateOfBirth",
53+
],
54+
optional: true,
55+
},
56+
courseSubject: {
57+
type: "string",
58+
label: "Course Subject",
59+
description: "The students chosen subject.",
60+
optional: true,
61+
},
62+
courseLevel: {
63+
type: "string",
64+
label: "Course Level",
65+
description: "The students chosen level.",
66+
optional: true,
67+
},
68+
},
69+
async run({ $ }) {
70+
const response = await this.app.createProspect({
71+
$,
72+
data: {
73+
"fname": this.firstName,
74+
"lname": this.lastName,
75+
"mobile_phone": this.mobilePhone,
76+
"email_address": this.emailAddress,
77+
"description": this.description,
78+
"gender": this.gender,
79+
"date_of_birth": this.dateOfBirth,
80+
"course_subject": this.courseSubject,
81+
"course_level": this.courseLevel,
82+
},
83+
});
84+
$.export("$summary", `Successfully created prospect with ID: ${response.data.id}`);
85+
return response;
86+
},
87+
};
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
import { PAYMENT_METHOD_OPTIONS } from "../../common/constants.mjs";
2+
import app from "../../teach_n_go.app.mjs";
3+
4+
export default {
5+
key: "teach_n_go-create-student",
6+
name: "Create Student",
7+
description: "Registers a new student in Teach 'n Go. [See the documentation](https://intercom.help/teach-n-go/en/articles/6807235-new-student-and-class-registration-api)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
firstName: {
13+
propDefinition: [
14+
app,
15+
"firstName",
16+
],
17+
description: "The student's first name.",
18+
},
19+
lastName: {
20+
propDefinition: [
21+
app,
22+
"lastName",
23+
],
24+
description: "The student's last name.",
25+
},
26+
gender: {
27+
propDefinition: [
28+
app,
29+
"gender",
30+
],
31+
description: "The student's gender.",
32+
optional: true,
33+
},
34+
registrationDate: {
35+
type: "string",
36+
label: "Registration Date",
37+
description: "The student's registration date. **Format: YYYY-MM-DD**",
38+
optional: true,
39+
},
40+
dateOfBirth: {
41+
propDefinition: [
42+
app,
43+
"dateOfBirth",
44+
],
45+
description: "The student's date of birth. **Format: YYYY-MM-DD**",
46+
optional: true,
47+
},
48+
identificationNumber: {
49+
type: "string",
50+
label: "Identification Number",
51+
description: "The external number to identify the student.",
52+
optional: true,
53+
},
54+
preferredPaymentMethod: {
55+
type: "integer",
56+
label: "Preferred Payment Method",
57+
description: "The payment method the student want to use.",
58+
options: PAYMENT_METHOD_OPTIONS,
59+
optional: true,
60+
},
61+
discountPercentage: {
62+
type: "string",
63+
label: "Discount Percentage",
64+
description: "The discount percentage on the payment amount.",
65+
optional: true,
66+
},
67+
mobilePhoneCode: {
68+
type: "integer",
69+
label: "Mobile Phone Code",
70+
description: "The region code of the mobile phone. Min length: 2, Max length: 4",
71+
optional: true,
72+
},
73+
mobilePhone: {
74+
type: "integer",
75+
label: "Mobile Phone",
76+
description: "The student's mobile phone",
77+
optional: true,
78+
},
79+
homePhoneCode: {
80+
type: "integer",
81+
label: "Home Phone Code",
82+
description: "The region code of the home phone. Min length: 2, Max length: 4",
83+
optional: true,
84+
},
85+
homePhone: {
86+
type: "integer",
87+
label: "Home Phone",
88+
description: "The student's home phone",
89+
optional: true,
90+
},
91+
emailAddress: {
92+
propDefinition: [
93+
app,
94+
"emailAddress",
95+
],
96+
description: "The student's email address.",
97+
optional: true,
98+
},
99+
streetNameAndNumber: {
100+
type: "string",
101+
label: "Street Name And Number",
102+
description: "The student's full address.",
103+
optional: true,
104+
},
105+
flatFloor: {
106+
type: "string",
107+
label: "Flat Floor",
108+
description: "The student's address flat floor if it exists.",
109+
optional: true,
110+
},
111+
area: {
112+
type: "string",
113+
label: "Area",
114+
description: "The student's address area.",
115+
optional: true,
116+
},
117+
city: {
118+
type: "string",
119+
label: "City",
120+
description: "The student's city.",
121+
optional: true,
122+
},
123+
postcode: {
124+
type: "string",
125+
label: "Postcode",
126+
description: "The student's postcode.",
127+
optional: true,
128+
},
129+
countryCode: {
130+
type: "string",
131+
label: "Country Code",
132+
description: "The student's ISO 2 letter country code, e.g. (US, UK, IN).",
133+
optional: true,
134+
},
135+
generalNotes: {
136+
type: "string",
137+
label: "General Notes",
138+
description: "Some student's additional notes.",
139+
optional: true,
140+
},
141+
medicalNotes: {
142+
type: "string",
143+
label: "Medical Notes",
144+
description: "Some student's additional medical notes.",
145+
optional: true,
146+
},
147+
courses: {
148+
propDefinition: [
149+
app,
150+
"courses",
151+
],
152+
optional: true,
153+
},
154+
enrolmentDate: {
155+
type: "string",
156+
label: "Enrolment Date",
157+
description: "The date of the student's enrolment.",
158+
optional: true,
159+
},
160+
},
161+
async run({ $ }) {
162+
const response = await this.app.registerStudent({
163+
$,
164+
data: {
165+
fname: this.firstName,
166+
lname: this.lastName,
167+
gender: this.gender,
168+
registration_date: this.registrationDate,
169+
date_of_birth: this.dateOfBirth,
170+
identification_number: this.identificationNumber,
171+
preferred_payment_method: this.preferredPaymentMethod,
172+
discount_percentage: this.discountPercentage && parseFloat(this.discountPercentage),
173+
mobile_phone_code: this.mobilePhoneCode,
174+
mobile_phone: this.mobilePhone,
175+
home_phone_code: this.homePhoneCode,
176+
home_phone: this.homePhone,
177+
email_address: this.emailAddress,
178+
street_name_and_number: this.streetNameAndNumber,
179+
flat_floor: this.flatFloor,
180+
area: this.area,
181+
city: this.city,
182+
postcode: this.postcode,
183+
country_code: this.countryCode,
184+
general_notes: this.generalNotes,
185+
medical_notes: this.medicalNotes,
186+
courses: this.courses,
187+
enrolment_date: this.enrolmentDate,
188+
},
189+
});
190+
191+
$.export("$summary", `Successfully registered student with ID: ${response.data.id}`);
192+
return response;
193+
},
194+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export const LIMIT = 100;
2+
3+
export const GENDER_OPTIONS = [
4+
"Female",
5+
"Male",
6+
"Not Specified",
7+
];
8+
9+
export const PAYMENT_METHOD_OPTIONS = [
10+
{
11+
label: "Cash",
12+
value: 1,
13+
},
14+
{
15+
label: "Cheque",
16+
value: 2,
17+
},
18+
{
19+
label: "Credit Card",
20+
value: 3,
21+
},
22+
{
23+
label: "Bank Transfer",
24+
value: 4,
25+
},
26+
{
27+
label: "Direct Debit",
28+
value: 5,
29+
},
30+
];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

components/teach_n_go/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/teach_n_go",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Teach 'n Go Components",
55
"main": "teach_n_go.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

0 commit comments

Comments
 (0)