-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - planning_center #16625
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
Changes from all commits
Commits
Show all changes
2 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
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,16 +1,18 @@ | ||
| { | ||
| "name": "@pipedream/planning_center", | ||
| "version": "0.0.2", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Planning Center Components", | ||
| "main": "dist/app/planning_center.app.mjs", | ||
| "main": "planning_center.app.mjs", | ||
| "keywords": [ | ||
| "pipedream", | ||
| "planning_center" | ||
| ], | ||
| "files": ["dist"], | ||
| "homepage": "https://pipedream.com/apps/planning_center", | ||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } |
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,98 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| const DEFAULT_LIMIT = 25; | ||
| const MAX_LIMIT = 100; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "planning_center", | ||
| propDefinitions: { | ||
| listId: { | ||
| type: "string", | ||
| label: "List ID", | ||
| description: "The ID of the list to monitor for new persons", | ||
| async options({ page }) { | ||
| const { data } = await this.listLists({ | ||
| params: { | ||
| per_page: DEFAULT_LIMIT, | ||
| offset: page * DEFAULT_LIMIT, | ||
| }, | ||
| }); | ||
| return data?.map(({ | ||
| id: value, attributes, | ||
| }) => ({ | ||
| label: attributes.name_or_description, | ||
| value, | ||
| })) || []; | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| _baseUrl() { | ||
| return "https://api.planningcenteronline.com"; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, | ||
| path, | ||
| ...otherOpts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| Authorization: `Bearer ${this.$auth.oauth_access_token}`, | ||
| }, | ||
| ...otherOpts, | ||
| }); | ||
| }, | ||
| getListResult({ | ||
| listId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/people/v2/lists/${listId}/list_results`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listLists(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/people/v2/lists", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listDonations(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/giving/v2/donations", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| getCalendarEvents(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/calendar/v2/events", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| async *paginate({ | ||
| fn, args, max, | ||
| }) { | ||
| args = { | ||
| ...args, | ||
| params: { | ||
| ...args?.params, | ||
| per_page: MAX_LIMIT, | ||
| offset: 0, | ||
| }, | ||
| }; | ||
| let total, count = 0; | ||
|
|
||
| do { | ||
| const { data } = await fn(args); | ||
| for (const item of data) { | ||
| yield item; | ||
| if (max && ++count >= max) { | ||
| return; | ||
| } | ||
| } | ||
| total = data?.length; | ||
| args.params.offset += args.params.per_page; | ||
| } while (total); | ||
| }, | ||
| }, | ||
| }; |
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,82 @@ | ||
| import planningCenter from "../../planning_center.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| planningCenter, | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getLastTs() { | ||
| return this.db.get("lastTs") || 0; | ||
| }, | ||
| _setLastTs(lastTs) { | ||
| this.db.set("lastTs", lastTs); | ||
| }, | ||
| getArgs() { | ||
| return {}; | ||
| }, | ||
| getTs(item) { | ||
| return Date.parse(item.attributes.created_at); | ||
| }, | ||
| isSorted() { | ||
| return true; | ||
| }, | ||
| emitEvent(item) { | ||
| const meta = this.generateMeta(item); | ||
| this.$emit(item, meta); | ||
| }, | ||
| generateMeta(item) { | ||
| return { | ||
| id: item.id, | ||
| summary: this.getSummary(item), | ||
| ts: this.getTs(item), | ||
| }; | ||
| }, | ||
| async processEvent(max) { | ||
| const lastTs = this._getLastTs(); | ||
| let maxTs = lastTs; | ||
| const fn = this.getResourceFn(); | ||
| const args = this.getArgs(); | ||
| const isSorted = this.isSorted(); | ||
|
|
||
| const results = this.planningCenter.paginate({ | ||
| fn, | ||
| args, | ||
| max, | ||
| }); | ||
|
|
||
| for await (const item of results) { | ||
| const ts = this.getTs(item); | ||
| if (ts >= lastTs) { | ||
| this.emitEvent(item); | ||
| maxTs = Math.max(ts, maxTs); | ||
| } else if (isSorted) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| this._setLastTs(maxTs); | ||
| }, | ||
| getResourceFn() { | ||
| throw new Error("getResourceFn is not implemented"); | ||
| }, | ||
| getSummary() { | ||
| throw new Error("getSummary is not implemented"); | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| await this.processEvent(25); | ||
| }, | ||
| }, | ||
| async run() { | ||
| await this.processEvent(); | ||
| }, | ||
| }; | ||
23 changes: 23 additions & 0 deletions
23
components/planning_center/sources/new-calendar-event/new-calendar-event.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,23 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "planning_center-new-calendar-event", | ||
| name: "New Calendar Event", | ||
| description: "Emit new event when a new calendar event is created. [See the documentation](https://developer.planning.center/docs/#/apps/calendar/2022-07-07/vertices/event)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getResourceFn() { | ||
| return this.planningCenter.getCalendarEvents; | ||
| }, | ||
| isSorted() { | ||
| return false; | ||
| }, | ||
| getSummary(item) { | ||
| return `New Calendar Event with ID: ${item.id}`; | ||
| }, | ||
| }, | ||
| }; |
27 changes: 27 additions & 0 deletions
27
components/planning_center/sources/new-donation/new-donation.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,27 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "planning_center-new-donation", | ||
| name: "New Donation Received", | ||
| description: "Emit new event when a donation is received. [See the documentation](https://developer.planning.center/docs/#/apps/giving/2019-10-18/vertices/donation)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getResourceFn() { | ||
| return this.planningCenter.listDonations; | ||
| }, | ||
| getArgs() { | ||
| return { | ||
| params: { | ||
| order: "-created_at", | ||
| }, | ||
| }; | ||
| }, | ||
| getSummary(item) { | ||
| return `New Donation with ID: ${item.id}`; | ||
| }, | ||
| }, | ||
| }; |
37 changes: 37 additions & 0 deletions
37
components/planning_center/sources/new-list-result/new-list-result.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,37 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "planning_center-new-list-result", | ||
| name: "New Person Added to List", | ||
| description: "Emit new event when a person is added to the specified list. [See the documentation](https://developer.planning.center/docs/#/apps/people/2025-03-20/vertices/list_result)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| ...common.props, | ||
| listId: { | ||
| propDefinition: [ | ||
| common.props.planningCenter, | ||
| "listId", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getResourceFn() { | ||
| return this.planningCenter.getListResult; | ||
| }, | ||
| getArgs() { | ||
| return { | ||
| listId: this.listId, | ||
| params: { | ||
| order: "-created_at", | ||
| }, | ||
| }; | ||
| }, | ||
| getSummary(item) { | ||
| return `New List Result with ID: ${item.id}`; | ||
| }, | ||
| }, | ||
| }; |
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.