-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* waitlist init * [Components] waitlist #12804 Sources - New List - New Subscriber * pnpm update
- Loading branch information
1 parent
b025f96
commit 566feff
Showing
8 changed files
with
254 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/waitlist", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Waitlist Components", | ||
"main": "waitlist.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,9 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.0" | ||
} | ||
} | ||
} | ||
|
This file contains 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,62 @@ | ||
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
import waitlist from "../../waitlist.app.mjs"; | ||
|
||
export default { | ||
props: { | ||
waitlist, | ||
db: "$.service.db", | ||
timer: { | ||
label: "Polling interval", | ||
description: "Pipedream will poll the Waitlist API on this schedule", | ||
type: "$.interface.timer", | ||
default: { | ||
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
_getLastValue() { | ||
return this.db.get("lastValue") || 0; | ||
}, | ||
_setLastValue(lastValue) { | ||
this.db.set("lastValue", lastValue); | ||
}, | ||
getProps() { | ||
return {}; | ||
}, | ||
async startEvent(maxResults = 0) { | ||
const lastValue = this._getLastValue(); | ||
const fn = this.getFunction(); | ||
const field = this.getField(); | ||
|
||
const items = await fn({ | ||
...this.getProps(), | ||
}); | ||
|
||
const filteredResponse = items.filter((item) => this.getFilter(item[field], lastValue)); | ||
|
||
if (filteredResponse.length) { | ||
if (maxResults && filteredResponse.length > maxResults) { | ||
filteredResponse.length = maxResults; | ||
} | ||
this._setLastValue(filteredResponse[filteredResponse.length - 1][field]); | ||
} | ||
|
||
for (const item of filteredResponse) { | ||
this.$emit( item, { | ||
id: item.id || item.uuid, | ||
summary: this.getSummary(item), | ||
ts: Date.parse(item.created_at), | ||
}); | ||
} | ||
}, | ||
}, | ||
hooks: { | ||
async deploy() { | ||
await this.startEvent(25); | ||
}, | ||
}, | ||
async run() { | ||
await this.startEvent(); | ||
}, | ||
}; |
This file contains 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,28 @@ | ||
import common from "../common/base.mjs"; | ||
import sampleEmit from "./test-event.mjs"; | ||
|
||
export default { | ||
...common, | ||
key: "waitlist-new-list", | ||
name: "New List Created", | ||
description: "Emit new event each time a waitlist is created. [See the documentation](https://getwaitlist.com/docs/api-docs/waitlist)", | ||
version: "0.0.1", | ||
type: "source", | ||
dedupe: "unique", | ||
methods: { | ||
...common.methods, | ||
getFunction() { | ||
return this.waitlist.listWaitlists; | ||
}, | ||
getSummary(item) { | ||
return `New waitlist with Id: ${item.id}`; | ||
}, | ||
getField() { | ||
return "id"; | ||
}, | ||
getFilter(item, lastValue) { | ||
return item > lastValue; | ||
}, | ||
}, | ||
sampleEmit, | ||
}; |
This file contains 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,40 @@ | ||
export default { | ||
"id": 213, | ||
"configuration_style_json": { | ||
"social_links": { | ||
"facebook": "", | ||
"instagram": "", | ||
"linkedin": "", | ||
"pinterest": "", | ||
"twitter": "https://twitter.com/WaitlistAPI" | ||
}, | ||
"status_description": "Thanks for signing up!", | ||
"status_font_color": "#000000", | ||
"status_main_color": "#222222", | ||
"widget_background_color": "#4937E7", | ||
"widget_button_color": "#000000", | ||
"widget_font_color": "#000000" | ||
}, | ||
"logo": null, | ||
"spots_to_move_upon_referral": 3, | ||
"uses_firstname_lastname": false, | ||
"uses_leaderboard": true, | ||
"uses_signup_verification": false, | ||
"waitlist_name": "Title", | ||
"waitlist_url_location": "https://getwaitlist.com", | ||
"statistics": { | ||
'total_signups': 2200, | ||
'current_signups': 2200, | ||
}, | ||
"title": null, | ||
"success_title": null, | ||
"required_contact_detail": "EMAIL", | ||
"widget_shows_social_links": false, | ||
"signup_button_title": "Sign Up", | ||
"hide_counts": false, | ||
"leaderboard_length": 5, | ||
"remove_widget_headers": false, | ||
"questions": [{'question_value': "What is your favorite animal?", 'optional': false, "answer_value": ["Cat", "Dog", "Duck", "Other"]}], | ||
"twitter_message": "", | ||
"organization_uuid_fk": "30120c24-0ddc-4f35-9bc6-f5e3c7b09257", | ||
} |
44 changes: 44 additions & 0 deletions
44
components/waitlist/sources/new-subscriber/new-subscriber.mjs
This file contains 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,44 @@ | ||
import common from "../common/base.mjs"; | ||
import sampleEmit from "./test-event.mjs"; | ||
|
||
export default { | ||
...common, | ||
key: "waitlist-new-subscriber", | ||
name: "New Subscriber Added", | ||
description: "Emit new event each time a subscriber is added. [See the documentation](https://getwaitlist.com/docs/api-docs/waitlist)", | ||
version: "0.0.1", | ||
type: "source", | ||
dedupe: "unique", | ||
props: { | ||
...common.props, | ||
waitlistId: { | ||
propDefinition: [ | ||
common.props.waitlist, | ||
"waitlistId", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
...common.methods, | ||
getFunction() { | ||
return this.waitlist.listSignups; | ||
}, | ||
getProps() { | ||
return { | ||
waitlistId: this.waitlistId, | ||
}; | ||
}, | ||
getSummary(item) { | ||
return `New signup with Id: ${item.uuid}`; | ||
}, | ||
getField() { | ||
return "created_at"; | ||
}, | ||
getFilter(item, lastValue) { | ||
let parseDate = item.split("_"); | ||
const itemDate = `${parseDate[0]}T${parseDate[1].replace(/-/g, ":")}`; | ||
return Date.parse(itemDate) > Date.parse(lastValue); | ||
}, | ||
}, | ||
sampleEmit, | ||
}; |
This file contains 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,19 @@ | ||
export default { | ||
"amount_referred": 0, | ||
"created_at": "2022-04-10_18-34-28", | ||
"email": "[email protected]", | ||
"priority": 4985, | ||
"referral_link": "https://getwaitlist.com?ref_id=4F0BTBMAB", | ||
"referral_token": "4F0BTBMAB", | ||
"referred_by_signup_token": null, | ||
"removed_date": null, | ||
"removed_priority": null, | ||
"uuid": "c60ff9f2-1a58-4551-87ea-414991184fba", | ||
"verified": false, | ||
"answers": [{'question_value': "What is your favorite animal?", 'optional': false, "answer_value": "Cat"}], | ||
"phone": null, | ||
"first_name": "Maya", | ||
"last_name": "Kyler", | ||
"metadata": {}, | ||
"waitlist_id": 1234 | ||
} |
This file contains 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: "waitlist", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
waitlistId: { | ||
type: "string", | ||
label: "Waitlist Id", | ||
description: "The ID of your waitlist.", | ||
async options() { | ||
const waitlists = await this.listWaitlists(); | ||
|
||
return waitlists.map(({ | ||
id: value, waitlist_name: label, | ||
}) => ({ | ||
label, | ||
value, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return "https://api.getwaitlist.com/api/v1"; | ||
}, | ||
_headers() { | ||
return { | ||
"Content-Type": "application/json", | ||
"api-key": `${this.$auth.api_key}`, | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, path, ...opts | ||
}) { | ||
return axios($, { | ||
url: this._baseUrl() + path, | ||
headers: this._headers(), | ||
...opts, | ||
}); | ||
}, | ||
listWaitlists(opts = {}) { | ||
return this._makeRequest({ | ||
path: "/waitlist", | ||
...opts, | ||
}); | ||
}, | ||
listSignups({ | ||
waitlistId, ...opts | ||
}) { | ||
return this._makeRequest({ | ||
path: `/signup/waitlist/${waitlistId}`, | ||
...opts, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.