-
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.
- Loading branch information
1 parent
d81cb68
commit 03b056d
Showing
7 changed files
with
631 additions
and
4 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
components/adhook/actions/create-calendar-event/create-calendar-event.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,67 @@ | ||
import adhook from "../../adhook.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "adhook-create-calendar-event", | ||
name: "Create Calendar Event", | ||
description: "Generates a personalized calendar event in AdHook. [See the documentation](https://app.adhook.io/api-doc/)", | ||
version: "0.0.{{ts}}", | ||
type: "action", | ||
props: { | ||
adhook, | ||
eventName: { | ||
propDefinition: [ | ||
adhook, | ||
"eventName", | ||
], | ||
}, | ||
startDate: { | ||
propDefinition: [ | ||
adhook, | ||
"startDate", | ||
], | ||
}, | ||
endDate: { | ||
propDefinition: [ | ||
adhook, | ||
"endDate", | ||
], | ||
}, | ||
eventDescription: { | ||
propDefinition: [ | ||
adhook, | ||
"eventDescription", | ||
], | ||
optional: true, | ||
}, | ||
attendees: { | ||
propDefinition: [ | ||
adhook, | ||
"attendees", | ||
], | ||
optional: true, | ||
}, | ||
attachments: { | ||
propDefinition: [ | ||
adhook, | ||
"attachments", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.adhook.createCalendarEvent({ | ||
data: { | ||
eventName: this.eventName, | ||
startDate: this.startDate, | ||
endDate: this.endDate, | ||
eventDescription: this.eventDescription, | ||
attendees: this.attendees, | ||
attachments: this.attachments, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created calendar event: ${this.eventName}`); | ||
return response; | ||
}, | ||
}; |
72 changes: 72 additions & 0 deletions
72
components/adhook/actions/create-update-post/create-update-post.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,72 @@ | ||
import adhook from "../../adhook.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "adhook-create-update-post", | ||
name: "Create or Update Post", | ||
description: "Adds a new post or modifies an existing post in Adhook. [See the documentation](https://app.adhook.io/api-doc/)", | ||
version: "0.0.{{ts}}", | ||
type: "action", | ||
props: { | ||
adhook, | ||
postId: { | ||
propDefinition: [ | ||
adhook, | ||
"postId", | ||
], | ||
optional: true, | ||
}, | ||
postContent: { | ||
propDefinition: [ | ||
adhook, | ||
"postContent", | ||
], | ||
}, | ||
visibility: { | ||
propDefinition: [ | ||
adhook, | ||
"visibility", | ||
], | ||
}, | ||
postAttachments: { | ||
propDefinition: [ | ||
adhook, | ||
"postAttachments", | ||
], | ||
optional: true, | ||
}, | ||
mentionUsers: { | ||
propDefinition: [ | ||
adhook, | ||
"mentionUsers", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const data = { | ||
postContent: this.postContent, | ||
visibility: this.visibility, | ||
postAttachments: this.postAttachments, | ||
mentionUsers: this.mentionUsers, | ||
}; | ||
|
||
if (this.postId) { | ||
data.postId = this.postId; | ||
} | ||
|
||
const response = await axios($, { | ||
method: "POST", | ||
url: `${this.adhook._baseUrl()}/posts`, | ||
headers: { | ||
Authorization: `Bearer ${this.adhook.$auth.oauth_access_token}`, | ||
}, | ||
data, | ||
}); | ||
|
||
$.export("$summary", `Successfully ${this.postId | ||
? "updated" | ||
: "created"} post`); | ||
return response; | ||
}, | ||
}; |
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,186 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "adhook", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
postType: { | ||
type: "string", | ||
label: "Post Type", | ||
description: "The type of the post", | ||
optional: true, | ||
}, | ||
postAuthor: { | ||
type: "string", | ||
label: "Post Author", | ||
description: "The author of the post", | ||
optional: true, | ||
}, | ||
postTags: { | ||
type: "string[]", | ||
label: "Post Tags", | ||
description: "Tags associated with the post", | ||
optional: true, | ||
}, | ||
postId: { | ||
type: "string", | ||
label: "Post ID", | ||
description: "The ID of the post", | ||
}, | ||
isNew: { | ||
type: "boolean", | ||
label: "Is New", | ||
description: "Indicates if the post is new", | ||
optional: true, | ||
}, | ||
updateType: { | ||
type: "string", | ||
label: "Update Type", | ||
description: "Type of update made to the post", | ||
optional: true, | ||
}, | ||
eventName: { | ||
type: "string", | ||
label: "Event Name", | ||
description: "Name of the calendar event", | ||
}, | ||
startDate: { | ||
type: "string", | ||
label: "Start Date", | ||
description: "Start date of the event", | ||
}, | ||
endDate: { | ||
type: "string", | ||
label: "End Date", | ||
description: "End date of the event", | ||
}, | ||
eventDescription: { | ||
type: "string", | ||
label: "Event Description", | ||
description: "Description of the event", | ||
optional: true, | ||
}, | ||
attendees: { | ||
type: "string[]", | ||
label: "Attendees", | ||
description: "List of attendees for the event", | ||
optional: true, | ||
}, | ||
attachments: { | ||
type: "string[]", | ||
label: "Attachments", | ||
description: "Attachments for the event", | ||
optional: true, | ||
}, | ||
postContent: { | ||
type: "string", | ||
label: "Post Content", | ||
description: "Content of the post", | ||
}, | ||
visibility: { | ||
type: "string", | ||
label: "Visibility", | ||
description: "Visibility setting of the post", | ||
}, | ||
postAttachments: { | ||
type: "string[]", | ||
label: "Post Attachments", | ||
description: "Attachments for the post", | ||
optional: true, | ||
}, | ||
mentionUsers: { | ||
type: "string[]", | ||
label: "Mention Users", | ||
description: "Users to mention in the post", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
_baseUrl() { | ||
return "https://app.adhook.io/api"; | ||
}, | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, method = "GET", path = "/", headers, ...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
method, | ||
url: this._baseUrl() + path, | ||
headers: { | ||
...headers, | ||
Authorization: `Bearer ${this.$auth.oauth_access_token}`, | ||
}, | ||
}); | ||
}, | ||
async emitNewPostEvent(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/events/new_post", | ||
data: { | ||
postType: this.postType, | ||
postAuthor: this.postAuthor, | ||
postTags: this.postTags, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
async emitPostCreatedOrUpdatedEvent(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/events/post_created_or_updated", | ||
data: { | ||
postId: this.postId, | ||
postAuthor: this.postAuthor, | ||
postTags: this.postTags, | ||
isNew: this.isNew, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
async emitPostUpdatedEvent(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/events/post_updated", | ||
data: { | ||
postId: this.postId, | ||
postAuthor: this.postAuthor, | ||
postTags: this.postTags, | ||
updateType: this.updateType, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
async createCalendarEvent(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/events/calendar", | ||
data: { | ||
eventName: this.eventName, | ||
startDate: this.startDate, | ||
endDate: this.endDate, | ||
eventDescription: this.eventDescription, | ||
attendees: this.attendees, | ||
attachments: this.attachments, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
async addOrUpdatePost(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/posts", | ||
data: { | ||
postContent: this.postContent, | ||
visibility: this.visibility, | ||
postAttachments: this.postAttachments, | ||
mentionUsers: this.mentionUsers, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
}, | ||
}, | ||
}; | ||
}; |
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 |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
"publishConfig": { | ||
"access": "public" | ||
} | ||
} | ||
} |
Oops, something went wrong.