Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions components/ayrshare/actions/create-user/create-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import app from "../../ayrshare.app.mjs";

export default {
key: "ayrshare-create-user",
name: "Create User",
description: "Create a new User Profile under your Primary Profile. [See the documentation](https://www.ayrshare.com/docs/apis/profiles/create-profile)",
version: "0.0.1",
type: "action",
props: {
app,
title: {
propDefinition: [
app,
"title",
],
},
messagingActive: {
propDefinition: [
app,
"messagingActive",
],
},
hideTopHeader: {
propDefinition: [
app,
"hideTopHeader",
],
},
topHeader: {
propDefinition: [
app,
"topHeader",
],
},
subHeader: {
propDefinition: [
app,
"subHeader",
],
},
disableSocial: {
propDefinition: [
app,
"disableSocial",
],
},
team: {
propDefinition: [
app,
"team",
],
},
email: {
propDefinition: [
app,
"email",
],
},
tags: {
propDefinition: [
app,
"tags",
],
},
},
async run({ $ }) {
const response = await this.app.createUser({
$,
data: {
title: this.title,
messagingActive: this.messagingActive,
hideTopHeader: this.hideTopHeader,
topHeader: this.topHeader,
subHeader: this.subHeader,
disableSocial: this.disableSocial,
team: this.team,
email: this.email,
tags: this.tags,
},
});
$.export("$summary", "Successfully created user with the profile Key: " + response.profileKey);
return response;
},
};
37 changes: 37 additions & 0 deletions components/ayrshare/actions/delete-user/delete-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import app from "../../ayrshare.app.mjs";

export default {
key: "ayrshare-delete-user",
name: "Delete User",
description: "Delete a user profile you are the owner of. [See the documentation](https://www.ayrshare.com/docs/apis/profiles/delete-profile)",
version: "0.0.1",
type: "action",
props: {
app,
profileToDelete: {
propDefinition: [
app,
"profileToDelete",
],
},
profileKey: {
propDefinition: [
app,
"profileKey",
],
description: "Unique key returned after profile creation. Must be informed only if `title` is not provided",
optional: true,
},
},
async run({ $ }) {
const response = await this.app.deleteUser({
$,
data: {
title: this.profileToDelete,
profileKey: this.profileKey,
},
});
$.export("$summary", "Successfully sent the request to delete the user profile. Status: " + response.status);
return response;
},
};
71 changes: 71 additions & 0 deletions components/ayrshare/actions/update-user/update-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import app from "../../ayrshare.app.mjs";

export default {
key: "ayrshare-update-user",
name: "Update User",
description: "Update an existing profile. [See the documentation](https://www.ayrshare.com/docs/apis/profiles/update-profile)",
version: "0.0.1",
type: "action",
props: {
app,
profileKey: {
propDefinition: [
app,
"profileKey",
],
},
title: {
propDefinition: [
app,
"title",
],
description: "Unique title of the profile that will be updated",
},
messagingActive: {
propDefinition: [
app,
"messagingActive",
],
},
hideTopHeader: {
propDefinition: [
app,
"hideTopHeader",
],
},
topHeader: {
propDefinition: [
app,
"topHeader",
],
},
disableSocial: {
propDefinition: [
app,
"disableSocial",
],
},
tags: {
propDefinition: [
app,
"tags",
],
},
},
async run({ $ }) {
const response = await this.app.updateUser({
$,
data: {
title: this.title,
messagingActive: this.messagingActive,
hideTopHeader: this.hideTopHeader,
topHeader: this.topHeader,
disableSocial: this.disableSocial,
tags: this.tags,
profileKey: this.profileKey,
},
});
$.export("$summary", "Successfully sent the request to update the user profile. Status: " + response.status);
return response;
},
};
127 changes: 123 additions & 4 deletions components/ayrshare/ayrshare.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,130 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "ayrshare",
propDefinitions: {},
propDefinitions: {
title: {
type: "string",
label: "Title",
description: "Unique title for the new profile",
},
messagingActive: {
type: "boolean",
label: "Messaging Active",
description: "Enable messaging functionality for this profile",
optional: true,
},
hideTopHeader: {
type: "boolean",
label: "Hide Top Header",
description: "Hide the top header text on the account linking page",
optional: true,
},
topHeader: {
type: "string",
label: "Top Header",
description: "Custom header text shown on the social linking page",
optional: true,
},
subHeader: {
type: "string",
label: "Sub Header",
description: "Custom sub-header text shown below the header on the linking page",
optional: true,
},
disableSocial: {
type: "string[]",
label: "Disable Social",
description: "List of social platforms to disable for this profile",
options: constants.SOCIAL_NETWORKS,
optional: true,
},
team: {
type: "boolean",
label: "Team",
description: "Set to true to invite the user as a team member",
optional: true,
},
email: {
type: "string",
label: "Email",
description: "Email address to send the team invitation to",
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "Custom internal tags to help categorize the profile",
optional: true,
},
profileKey: {
type: "string",
label: "Profile Key",
description: "Unique key returned after profile creation",
},
profileToDelete: {
type: "string",
label: "Title",
description: "Unique title of the profile that will be deleted. Must be informed only if `profileKey` is not provided",
optional: true,
async options() {
const response = await this.getProfiles();
const profiles = response.profiles;
return profiles.map((profiles) => ({
label: profiles.title,
value: profiles.title,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.ayrshare.com/api";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
Authorization: `Bearer ${this.$auth.api_key}`,
...headers,
},
});
},
async createUser(args = {}) {
return this._makeRequest({
path: "/profiles",
method: "post",
...args,
});
},
async updateUser(args = {}) {
return this._makeRequest({
path: "/profiles",
method: "patch",
...args,
});
},
async deleteUser(args = {}) {
return this._makeRequest({
path: "/profiles",
method: "delete",
...args,
});
},
async getProfiles(args = {}) {
return this._makeRequest({
path: "/profiles",
...args,
});
},
},
};
17 changes: 17 additions & 0 deletions components/ayrshare/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
SOCIAL_NETWORKS: [
"bluesky",
"facebook",
"gmb",
"instagram",
"linkedin",
"pinterest",
"reddit",
"snapchat",
"telegram",
"threads",
"tiktok",
"twitter",
"youtube",
],
};
5 changes: 4 additions & 1 deletion components/ayrshare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/ayrshare",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Ayrshare Components",
"main": "ayrshare.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading