Skip to content

Commit 412dc1e

Browse files
committed
[Components] teach_n_go #14312
Sources - New Class Created - New Student Registration Actions - Create Prospect - Create Student
1 parent a56f9a3 commit 412dc1e

File tree

13 files changed

+567
-455
lines changed

13 files changed

+567
-455
lines changed
Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,87 @@
1-
import teachNGo from "../../teach_n_go.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import app from "../../teach_n_go.app.mjs";
32

43
export default {
54
key: "teach_n_go-create-prospect",
65
name: "Create Prospect",
76
description: "Creates a new prospect inside Teach 'n Go. [See the documentation](https://intercom.help/teach-n-go/en/articles/5750592-prospect-registration-api)",
8-
version: "0.0.{{ts}}",
7+
version: "0.0.1",
98
type: "action",
109
props: {
11-
teachNGo,
12-
prospectDetails: {
10+
app,
11+
firstName: {
1312
propDefinition: [
14-
teachNGo,
15-
"prospectDetails",
13+
app,
14+
"firstName",
1615
],
1716
},
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+
},
1868
},
1969
async run({ $ }) {
20-
const response = await this.teachNGo.createProspect({
21-
prospectDetails: this.prospectDetails,
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+
},
2283
});
23-
$.export("$summary", `Successfully created prospect with ID: ${response.id}`);
84+
$.export("$summary", `Successfully created prospect with ID: ${response.data.id}`);
2485
return response;
2586
},
2687
};
Lines changed: 174 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,194 @@
1-
import teachNGo from "../../teach_n_go.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import { PAYMENT_METHOD_OPTIONS } from "../../common/constants.mjs";
2+
import app from "../../teach_n_go.app.mjs";
33

44
export default {
55
key: "teach_n_go-create-student",
66
name: "Create Student",
77
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.{{ts}}",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
teachNGo,
12-
personalDetails: {
11+
app,
12+
firstName: {
1313
propDefinition: [
14-
teachNGo,
15-
"personalDetails",
14+
app,
15+
"firstName",
1616
],
17+
description: "The student's first name.",
1718
},
18-
academicDetails: {
19+
lastName: {
1920
propDefinition: [
20-
teachNGo,
21-
"academicDetails",
21+
app,
22+
"lastName",
2223
],
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,
23159
},
24160
},
25161
async run({ $ }) {
26-
const response = await this.teachNGo.registerStudent({
27-
personalDetails: this.personalDetails,
28-
academicDetails: this.academicDetails,
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+
},
29189
});
30190

31-
$.export("$summary", `Successfully registered student with ID: ${response.id}`);
191+
$.export("$summary", `Successfully registered student with ID: ${response.data.id}`);
32192
return response;
33193
},
34194
};

components/teach_n_go/actions/invoice-mark-paid/invoice-mark-paid.mjs

Lines changed: 0 additions & 34 deletions
This file was deleted.
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+
};

0 commit comments

Comments
 (0)