-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Educateme - new components #19357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Educateme - new components #19357
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
components/educateme/actions/create-course/create-course.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import educateme from "../../educateme.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "educateme-create-course", | ||
| name: "Create Course", | ||
| description: "Create a new course. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| educateme, | ||
| title: { | ||
| type: "string", | ||
| label: "Title", | ||
| description: "The title of the course", | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Course Type", | ||
| description: "The type of the course", | ||
| options: [ | ||
| "COHORT_BASED", | ||
| "SELF_PACED", | ||
| ], | ||
| }, | ||
| previewUrl: { | ||
| type: "string", | ||
| label: "Preview URL", | ||
| description: "The URL of the course preview", | ||
| optional: true, | ||
| }, | ||
| withProgramSyncing: { | ||
| type: "boolean", | ||
| label: "With Program Syncing", | ||
| description: "Whether to sync the course with the program", | ||
| optional: true, | ||
| }, | ||
| duplicatedCourseId: { | ||
| propDefinition: [ | ||
| educateme, | ||
| "courseId", | ||
| ], | ||
| label: "Duplicated Course ID", | ||
| description: "Optional. In case you need to copy a structure from another course", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { result } = await this.educateme.createCourse({ | ||
| $, | ||
| data: { | ||
| title: this.title, | ||
| type: this.type, | ||
| previewUrl: this.previewUrl, | ||
| withProgramSyncing: this.withProgramSyncing, | ||
| duplicatedCourseId: this.duplicatedCourseId, | ||
| }, | ||
| }); | ||
| if (result?.id) { | ||
| $.export("$summary", `Successfully created course with ID: ${result.id}`); | ||
| } | ||
| return result; | ||
| }, | ||
| }; |
49 changes: 49 additions & 0 deletions
49
components/educateme/actions/find-courses/find-courses.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import educateme from "../../educateme.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "educateme-find-courses", | ||
| name: "Find Courses", | ||
| description: "Find courses by optional filters. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| educateme, | ||
| learnerEmail: { | ||
| type: "string", | ||
| label: "Learner Email", | ||
| description: "Filter courses by assigned learner email", | ||
| optional: true, | ||
| }, | ||
| isFinished: { | ||
| type: "boolean", | ||
| label: "Is Finished", | ||
| description: "If the course is finished", | ||
| optional: true, | ||
| }, | ||
| isSuspended: { | ||
| type: "boolean", | ||
| label: "Is Suspended", | ||
| description: "If the course is suspended", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const courses = await this.educateme.listCourses({ | ||
| $, | ||
| params: { | ||
| learnerEmail: this.learnerEmail, | ||
| isFinished: this.isFinished, | ||
| isSuspended: this.isSuspended, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully found ${courses.length} course${courses.length === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return courses; | ||
| }, | ||
| }; |
31 changes: 31 additions & 0 deletions
31
components/educateme/actions/get-course-activities/get-course-activities.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import educateme from "../../educateme.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "educateme-get-course-activities", | ||
| name: "Get Course Activities", | ||
| description: "Get the activities for a course. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| educateme, | ||
| courseId: { | ||
| propDefinition: [ | ||
| educateme, | ||
| "courseId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { result } = await this.educateme.listCourseActivities({ | ||
| $, | ||
| courseId: this.courseId, | ||
| }); | ||
| $.export("$summary", "Successfully retrieved course activities"); | ||
| return result; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,57 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "educateme", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| courseId: { | ||
| type: "string", | ||
| label: "Course ID", | ||
| description: "The ID of a course", | ||
| async options() { | ||
| const courses = await this.listCourses(); | ||
| return courses.map((course) => ({ | ||
| label: course.title, | ||
| value: course.id, | ||
| })); | ||
| }, | ||
| }, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return this.$auth.api_url; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| ...opts, | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| "api-key": `${this.$auth.api_key}`, | ||
| }, | ||
| }); | ||
| }, | ||
| listCourses(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/courses", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listCourseActivities({ | ||
| courseId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/courses/${courseId}/lessons`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createCourse(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/courses", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import educateme from "../../educateme.app.mjs"; | ||
| import { | ||
| DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, ConfigurationError, | ||
| } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| educateme, | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| async getResources() { | ||
| throw new ConfigurationError("getResources method must be implemented"); | ||
| }, | ||
| generateMeta() { | ||
| throw new ConfigurationError("generateMeta method must be implemented"); | ||
| }, | ||
| }, | ||
| async run() { | ||
| const resources = await this.getResources(); | ||
| for (const resource of resources || []) { | ||
| const meta = this.generateMeta(resource); | ||
| this.$emit(resource, meta); | ||
| } | ||
| }, | ||
| }; |
36 changes: 36 additions & 0 deletions
36
components/educateme/sources/new-course-activity/new-course-activity.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "educateme-new-course-activity", | ||
| name: "New Course Activity", | ||
| 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)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| ...common.props, | ||
| courseId: { | ||
| propDefinition: [ | ||
| common.props.educateme, | ||
| "courseId", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| async getResources() { | ||
| const { result } = await this.educateme.listCourseActivities({ | ||
| courseId: this.courseId, | ||
| }); | ||
| return result; | ||
| }, | ||
| generateMeta(activity) { | ||
| return { | ||
| id: activity.id, | ||
| summary: `New activity: ${activity.title}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, | ||
| }, | ||
| }; |
24 changes: 24 additions & 0 deletions
24
components/educateme/sources/new-course-created/new-course-created.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "educateme-new-course-created", | ||
| name: "New Course Created", | ||
| description: "Emit new event when a new course is created. [See the documentation](https://edme.notion.site/API-integration-v0-2-ef33641eb7f24fa9a6efb969c1f2928f)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getResources() { | ||
| return this.educateme.listCourses(); | ||
| }, | ||
| generateMeta(course) { | ||
| return { | ||
| id: course.id, | ||
| summary: `New course: ${course.title}`, | ||
| ts: Date.now(), | ||
| }; | ||
| }, | ||
| }, | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.