Skip to content

Commit 604f940

Browse files
committed
init
1 parent e5ad5d4 commit 604f940

File tree

3 files changed

+114
-5
lines changed

3 files changed

+114
-5
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import hullo from "../../hullo.app.mjs";
2+
3+
export default {
4+
key: "hullo-add-update-member",
5+
name: "Add or Update Member",
6+
description: "Adds a new member or updates an existing member's data in Hullo",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
hullo,
11+
memberId: {
12+
propDefinition: [
13+
hullo,
14+
"memberId",
15+
],
16+
},
17+
memberInfo: {
18+
propDefinition: [
19+
hullo,
20+
"memberInfo",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.hullo.addOrUpdateMember(this.memberId, this.memberInfo);
26+
$.export("$summary", `Successfully added or updated member with ID ${this.memberId}`);
27+
return response;
28+
},
29+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import hullo from "../../hullo.app.mjs";
2+
3+
export default {
4+
key: "hullo-send-message",
5+
name: "Send Message",
6+
description: "Sends a personalized message to a Hullo member.",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
hullo,
11+
memberId: {
12+
propDefinition: [
13+
hullo,
14+
"memberId",
15+
],
16+
},
17+
messageContent: {
18+
propDefinition: [
19+
hullo,
20+
"messageContent",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.hullo.sendMessage(this.memberId, this.messageContent);
26+
$.export("$summary", `Successfully sent message to member with ID: ${this.memberId}`);
27+
return response;
28+
},
29+
};

components/hullo/hullo.app.mjs

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,62 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "hullo",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
memberId: {
8+
type: "string",
9+
label: "Member ID",
10+
description: "The ID of the Hullo member",
11+
},
12+
messageContent: {
13+
type: "string",
14+
label: "Message Content",
15+
description: "The content of the message to send",
16+
},
17+
memberInfo: {
18+
type: "object",
19+
label: "Member Info",
20+
description: "Details of the member such as name, email, etc.",
21+
},
22+
},
523
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
24+
_baseUrl() {
25+
return "https://app.hullo.me/api";
26+
},
27+
async _makeRequest(opts = {}) {
28+
const {
29+
$ = this,
30+
method = "GET",
31+
path,
32+
headers,
33+
...otherOpts
34+
} = opts;
35+
return axios($, {
36+
...otherOpts,
37+
method,
38+
url: this._baseUrl() + path,
39+
headers: {
40+
...headers,
41+
Authorization: `Bearer ${this.$auth.api_token}`,
42+
},
43+
});
44+
},
45+
async sendMessage(memberId, messageContent) {
46+
return this._makeRequest({
47+
method: "POST",
48+
path: `/members/${memberId}/messages`,
49+
data: {
50+
content: messageContent,
51+
},
52+
});
53+
},
54+
async addOrUpdateMember(memberId, memberInfo) {
55+
return this._makeRequest({
56+
method: "PUT",
57+
path: `/members/${memberId}`,
58+
data: memberInfo,
59+
});
960
},
1061
},
11-
};
62+
};

0 commit comments

Comments
 (0)