Skip to content

Commit f0642cc

Browse files
committed
Added actions
1 parent 7918c48 commit f0642cc

File tree

6 files changed

+321
-14
lines changed

6 files changed

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

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 <[email protected]> (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 & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)