Skip to content

Commit e1a5952

Browse files
authored
Educateme - new components (#19357)
* new components * pnpm-lock.yaml * updates
1 parent 8673252 commit e1a5952

File tree

9 files changed

+302
-10
lines changed

9 files changed

+302
-10
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import educateme from "../../educateme.app.mjs";
2+
3+
export default {
4+
key: "educateme-create-course",
5+
name: "Create Course",
6+
description: "Create a new course. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
educateme,
16+
title: {
17+
type: "string",
18+
label: "Title",
19+
description: "The title of the course",
20+
},
21+
type: {
22+
type: "string",
23+
label: "Course Type",
24+
description: "The type of the course",
25+
options: [
26+
"COHORT_BASED",
27+
"SELF_PACED",
28+
],
29+
},
30+
previewUrl: {
31+
type: "string",
32+
label: "Preview URL",
33+
description: "The URL of the course preview",
34+
optional: true,
35+
},
36+
withProgramSyncing: {
37+
type: "boolean",
38+
label: "With Program Syncing",
39+
description: "Whether to sync the course with the program",
40+
optional: true,
41+
},
42+
duplicatedCourseId: {
43+
propDefinition: [
44+
educateme,
45+
"courseId",
46+
],
47+
label: "Duplicated Course ID",
48+
description: "Optional. In case you need to copy a structure from another course",
49+
optional: true,
50+
},
51+
},
52+
async run({ $ }) {
53+
const { result } = await this.educateme.createCourse({
54+
$,
55+
data: {
56+
title: this.title,
57+
type: this.type,
58+
previewUrl: this.previewUrl,
59+
withProgramSyncing: this.withProgramSyncing,
60+
duplicatedCourseId: this.duplicatedCourseId,
61+
},
62+
});
63+
if (result?.id) {
64+
$.export("$summary", `Successfully created course with ID: ${result.id}`);
65+
}
66+
return result;
67+
},
68+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import educateme from "../../educateme.app.mjs";
2+
3+
export default {
4+
key: "educateme-find-courses",
5+
name: "Find Courses",
6+
description: "Find courses by optional filters. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
educateme,
16+
learnerEmail: {
17+
type: "string",
18+
label: "Learner Email",
19+
description: "Filter courses by assigned learner email",
20+
optional: true,
21+
},
22+
isFinished: {
23+
type: "boolean",
24+
label: "Is Finished",
25+
description: "If the course is finished",
26+
optional: true,
27+
},
28+
isSuspended: {
29+
type: "boolean",
30+
label: "Is Suspended",
31+
description: "If the course is suspended",
32+
optional: true,
33+
},
34+
},
35+
async run({ $ }) {
36+
const courses = await this.educateme.listCourses({
37+
$,
38+
params: {
39+
learnerEmail: this.learnerEmail,
40+
isFinished: this.isFinished,
41+
isSuspended: this.isSuspended,
42+
},
43+
});
44+
$.export("$summary", `Successfully found ${courses.length} course${courses.length === 1
45+
? ""
46+
: "s"}`);
47+
return courses;
48+
},
49+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import educateme from "../../educateme.app.mjs";
2+
3+
export default {
4+
key: "educateme-get-course-activities",
5+
name: "Get Course Activities",
6+
description: "Get the activities for a course. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
educateme,
16+
courseId: {
17+
propDefinition: [
18+
educateme,
19+
"courseId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const { result } = await this.educateme.listCourseActivities({
25+
$,
26+
courseId: this.courseId,
27+
});
28+
$.export("$summary", "Successfully retrieved course activities");
29+
return result;
30+
},
31+
};
Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "educateme",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
courseId: {
8+
type: "string",
9+
label: "Course ID",
10+
description: "The ID of a course",
11+
async options() {
12+
const courses = await this.listCourses();
13+
return courses.map((course) => ({
14+
label: course.title,
15+
value: course.id,
16+
}));
17+
},
18+
},
19+
},
520
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
21+
_baseUrl() {
22+
return this.$auth.api_url;
23+
},
24+
_makeRequest({
25+
$ = this, path, ...opts
26+
}) {
27+
return axios($, {
28+
...opts,
29+
url: `${this._baseUrl()}${path}`,
30+
headers: {
31+
"api-key": `${this.$auth.api_key}`,
32+
},
33+
});
34+
},
35+
listCourses(opts = {}) {
36+
return this._makeRequest({
37+
path: "/courses",
38+
...opts,
39+
});
40+
},
41+
listCourseActivities({
42+
courseId, ...opts
43+
}) {
44+
return this._makeRequest({
45+
path: `/courses/${courseId}/lessons`,
46+
...opts,
47+
});
48+
},
49+
createCourse(opts = {}) {
50+
return this._makeRequest({
51+
method: "POST",
52+
path: "/courses",
53+
...opts,
54+
});
955
},
1056
},
11-
};
57+
};

components/educateme/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/educateme",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream EducateMe Components",
55
"main": "educateme.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
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import educateme from "../../educateme.app.mjs";
2+
import {
3+
DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, ConfigurationError,
4+
} from "@pipedream/platform";
5+
6+
export default {
7+
props: {
8+
educateme,
9+
timer: {
10+
type: "$.interface.timer",
11+
default: {
12+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
13+
},
14+
},
15+
},
16+
methods: {
17+
async getResources() {
18+
throw new ConfigurationError("getResources method must be implemented");
19+
},
20+
generateMeta() {
21+
throw new ConfigurationError("generateMeta method must be implemented");
22+
},
23+
},
24+
async run() {
25+
const resources = await this.getResources();
26+
for (const resource of resources || []) {
27+
const meta = this.generateMeta(resource);
28+
this.$emit(resource, meta);
29+
}
30+
},
31+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import common from "../common/base.mjs";
2+
3+
export default {
4+
...common,
5+
key: "educateme-new-course-activity",
6+
name: "New Course Activity",
7+
description: "Emit new event when a new activity is created in a course. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
props: {
12+
...common.props,
13+
courseId: {
14+
propDefinition: [
15+
common.props.educateme,
16+
"courseId",
17+
],
18+
},
19+
},
20+
methods: {
21+
...common.methods,
22+
async getResources() {
23+
const { result } = await this.educateme.listCourseActivities({
24+
courseId: this.courseId,
25+
});
26+
return result;
27+
},
28+
generateMeta(activity) {
29+
return {
30+
id: activity.id,
31+
summary: `New activity: ${activity.title}`,
32+
ts: Date.now(),
33+
};
34+
},
35+
},
36+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import common from "../common/base.mjs";
2+
3+
export default {
4+
...common,
5+
key: "educateme-new-course-created",
6+
name: "New Course Created",
7+
description: "Emit new event when a new course is created. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
methods: {
12+
...common.methods,
13+
getResources() {
14+
return this.educateme.listCourses();
15+
},
16+
generateMeta(course) {
17+
return {
18+
id: course.id,
19+
summary: `New course: ${course.title}`,
20+
ts: Date.now(),
21+
};
22+
},
23+
},
24+
};

pnpm-lock.yaml

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)