Skip to content

Commit 8fb9953

Browse files
authored
[Components] ayrshare #12524 (#16744)
* Added actions * Added actions * Update update-user.mjs
1 parent cac65df commit 8fb9953

File tree

7 files changed

+341
-6
lines changed

7 files changed

+341
-6
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import app from "../../ayrshare.app.mjs";
2+
3+
export default {
4+
key: "ayrshare-create-user",
5+
name: "Create User",
6+
description: "Create a new User Profile under your Primary Profile. [See the documentation](https://www.ayrshare.com/docs/apis/profiles/create-profile)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
title: {
12+
propDefinition: [
13+
app,
14+
"title",
15+
],
16+
},
17+
messagingActive: {
18+
propDefinition: [
19+
app,
20+
"messagingActive",
21+
],
22+
},
23+
hideTopHeader: {
24+
propDefinition: [
25+
app,
26+
"hideTopHeader",
27+
],
28+
},
29+
topHeader: {
30+
propDefinition: [
31+
app,
32+
"topHeader",
33+
],
34+
},
35+
subHeader: {
36+
propDefinition: [
37+
app,
38+
"subHeader",
39+
],
40+
},
41+
disableSocial: {
42+
propDefinition: [
43+
app,
44+
"disableSocial",
45+
],
46+
},
47+
team: {
48+
propDefinition: [
49+
app,
50+
"team",
51+
],
52+
},
53+
email: {
54+
propDefinition: [
55+
app,
56+
"email",
57+
],
58+
},
59+
tags: {
60+
propDefinition: [
61+
app,
62+
"tags",
63+
],
64+
},
65+
},
66+
async run({ $ }) {
67+
const response = await this.app.createUser({
68+
$,
69+
data: {
70+
title: this.title,
71+
messagingActive: this.messagingActive,
72+
hideTopHeader: this.hideTopHeader,
73+
topHeader: this.topHeader,
74+
subHeader: this.subHeader,
75+
disableSocial: this.disableSocial,
76+
team: this.team,
77+
email: this.email,
78+
tags: this.tags,
79+
},
80+
});
81+
$.export("$summary", "Successfully created user with the profile Key: " + response.profileKey);
82+
return response;
83+
},
84+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../ayrshare.app.mjs";
2+
3+
export default {
4+
key: "ayrshare-delete-user",
5+
name: "Delete User",
6+
description: "Delete a user profile you are the owner of. [See the documentation](https://www.ayrshare.com/docs/apis/profiles/delete-profile)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
profileToDelete: {
12+
propDefinition: [
13+
app,
14+
"profileToDelete",
15+
],
16+
},
17+
profileKey: {
18+
propDefinition: [
19+
app,
20+
"profileKey",
21+
],
22+
description: "Unique key returned after profile creation. Must be informed only if `title` is not provided",
23+
optional: true,
24+
},
25+
},
26+
async run({ $ }) {
27+
const response = await this.app.deleteUser({
28+
$,
29+
data: {
30+
title: this.profileToDelete,
31+
profileKey: this.profileKey,
32+
},
33+
});
34+
$.export("$summary", "Successfully sent the request to delete the user profile. Status: " + response.status);
35+
return response;
36+
},
37+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import app from "../../ayrshare.app.mjs";
2+
3+
export default {
4+
key: "ayrshare-update-user",
5+
name: "Update User",
6+
description: "Update an existing profile. [See the documentation](https://www.ayrshare.com/docs/apis/profiles/update-profile)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
profileKey: {
12+
propDefinition: [
13+
app,
14+
"profileKey",
15+
],
16+
},
17+
title: {
18+
propDefinition: [
19+
app,
20+
"title",
21+
],
22+
description: "Unique title of the profile that will be updated",
23+
},
24+
messagingActive: {
25+
propDefinition: [
26+
app,
27+
"messagingActive",
28+
],
29+
},
30+
hideTopHeader: {
31+
propDefinition: [
32+
app,
33+
"hideTopHeader",
34+
],
35+
},
36+
topHeader: {
37+
propDefinition: [
38+
app,
39+
"topHeader",
40+
],
41+
},
42+
disableSocial: {
43+
propDefinition: [
44+
app,
45+
"disableSocial",
46+
],
47+
},
48+
tags: {
49+
propDefinition: [
50+
app,
51+
"tags",
52+
],
53+
},
54+
},
55+
async run({ $ }) {
56+
const response = await this.app.updateUser({
57+
$,
58+
data: {
59+
title: this.title,
60+
messagingActive: this.messagingActive,
61+
hideTopHeader: this.hideTopHeader,
62+
topHeader: this.topHeader,
63+
disableSocial: this.disableSocial,
64+
tags: this.tags,
65+
profileKey: this.profileKey,
66+
},
67+
});
68+
$.export("$summary", "Successfully sent the request to update the user profile. Status: " + response.status);
69+
return response;
70+
},
71+
};

components/ayrshare/ayrshare.app.mjs

Lines changed: 123 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,130 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "ayrshare",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
title: {
9+
type: "string",
10+
label: "Title",
11+
description: "Unique title for the new profile",
12+
},
13+
messagingActive: {
14+
type: "boolean",
15+
label: "Messaging Active",
16+
description: "Enable messaging functionality for this profile",
17+
optional: true,
18+
},
19+
hideTopHeader: {
20+
type: "boolean",
21+
label: "Hide Top Header",
22+
description: "Hide the top header text on the account linking page",
23+
optional: true,
24+
},
25+
topHeader: {
26+
type: "string",
27+
label: "Top Header",
28+
description: "Custom header text shown on the social linking page",
29+
optional: true,
30+
},
31+
subHeader: {
32+
type: "string",
33+
label: "Sub Header",
34+
description: "Custom sub-header text shown below the header on the linking page",
35+
optional: true,
36+
},
37+
disableSocial: {
38+
type: "string[]",
39+
label: "Disable Social",
40+
description: "List of social platforms to disable for this profile",
41+
options: constants.SOCIAL_NETWORKS,
42+
optional: true,
43+
},
44+
team: {
45+
type: "boolean",
46+
label: "Team",
47+
description: "Set to true to invite the user as a team member",
48+
optional: true,
49+
},
50+
email: {
51+
type: "string",
52+
label: "Email",
53+
description: "Email address to send the team invitation to",
54+
optional: true,
55+
},
56+
tags: {
57+
type: "string[]",
58+
label: "Tags",
59+
description: "Custom internal tags to help categorize the profile",
60+
optional: true,
61+
},
62+
profileKey: {
63+
type: "string",
64+
label: "Profile Key",
65+
description: "Unique key returned after profile creation",
66+
},
67+
profileToDelete: {
68+
type: "string",
69+
label: "Title",
70+
description: "Unique title of the profile that will be deleted. Must be informed only if `profileKey` is not provided",
71+
optional: true,
72+
async options() {
73+
const response = await this.getProfiles();
74+
const profiles = response.profiles;
75+
return profiles.map((profiles) => ({
76+
label: profiles.title,
77+
value: profiles.title,
78+
}));
79+
},
80+
},
81+
},
582
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
83+
_baseUrl() {
84+
return "https://api.ayrshare.com/api";
85+
},
86+
async _makeRequest(opts = {}) {
87+
const {
88+
$ = this,
89+
path,
90+
headers,
91+
...otherOpts
92+
} = opts;
93+
return axios($, {
94+
...otherOpts,
95+
url: this._baseUrl() + path,
96+
headers: {
97+
Authorization: `Bearer ${this.$auth.api_key}`,
98+
...headers,
99+
},
100+
});
101+
},
102+
async createUser(args = {}) {
103+
return this._makeRequest({
104+
path: "/profiles",
105+
method: "post",
106+
...args,
107+
});
108+
},
109+
async updateUser(args = {}) {
110+
return this._makeRequest({
111+
path: "/profiles",
112+
method: "patch",
113+
...args,
114+
});
115+
},
116+
async deleteUser(args = {}) {
117+
return this._makeRequest({
118+
path: "/profiles",
119+
method: "delete",
120+
...args,
121+
});
122+
},
123+
async getProfiles(args = {}) {
124+
return this._makeRequest({
125+
path: "/profiles",
126+
...args,
127+
});
9128
},
10129
},
11130
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default {
2+
SOCIAL_NETWORKS: [
3+
"bluesky",
4+
"facebook",
5+
"gmb",
6+
"instagram",
7+
"linkedin",
8+
"pinterest",
9+
"reddit",
10+
"snapchat",
11+
"telegram",
12+
"threads",
13+
"tiktok",
14+
"twitter",
15+
"youtube",
16+
],
17+
};

components/ayrshare/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/ayrshare",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Ayrshare Components",
55
"main": "ayrshare.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)