Skip to content

Commit 8abcb0b

Browse files
committed
Added actions
1 parent 7918c48 commit 8abcb0b

File tree

7 files changed

+211
-25
lines changed

7 files changed

+211
-25
lines changed

components/tubular/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import app from "../../tubular.app.mjs";
2+
3+
export default {
4+
key: "tubular-create-lead",
5+
name: "Create Lead",
6+
description: "Create lead and return its ID. [See the documentation](https://developer.tubular.io/examples/#create-lead-and-return-its-id)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
firstName: {
12+
propDefinition: [
13+
app,
14+
"firstName",
15+
],
16+
},
17+
lastName: {
18+
propDefinition: [
19+
app,
20+
"lastName",
21+
],
22+
},
23+
note: {
24+
propDefinition: [
25+
app,
26+
"note",
27+
],
28+
},
29+
lead: {
30+
propDefinition: [
31+
app,
32+
"lead",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const query = `
38+
mutation {
39+
addContact(input: {
40+
firstName: "${this.firstName}",
41+
lastName: "${this.lastName}",
42+
note: "${this.note}",
43+
lead: ${this.lead}
44+
}) {
45+
contact {
46+
id
47+
}
48+
}
49+
}
50+
`;
51+
52+
const response = await this.app.createLead({
53+
$,
54+
data: {
55+
query,
56+
},
57+
});
58+
59+
$.export("$summary", "Successfully created Lead with ID: " + response.data.addContact.contact.id);
60+
return response;
61+
},
62+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import app from "../../tubular.app.mjs";
2+
3+
export default {
4+
key: "tubular-get-deals-by-date",
5+
name: "Get Deals By Date",
6+
description: "Get deals ordered by date of creation. [See the documentation](https://developer.tubular.io/examples/#get-deals-ordered-by-date-of-creation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
async run({ $ }) {
13+
const query = `{
14+
viewer{
15+
pipelines(first:100){
16+
edges{
17+
node{
18+
deals(orderBy:CREATED_AT, direction: DESC){
19+
edges{
20+
node{
21+
id
22+
name
23+
currency
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
}
31+
}`;
32+
const response = await this.app.getDealsByDate({
33+
$,
34+
data: {
35+
query,
36+
},
37+
});
38+
$.export("$summary", "Successfully fetched Deals");
39+
return response;
40+
},
41+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../tubular.app.mjs";
2+
3+
export default {
4+
key: "tubular-get-leads",
5+
name: "Get Leads",
6+
description: "Get leads ordered by date of creation. [See the documentation](https://developer.tubular.io/examples/#get-first-10-leads)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
12+
},
13+
async run({ $ }) {
14+
const query = `{
15+
viewer{
16+
leads(first: 100){
17+
edges{
18+
node{
19+
id
20+
fullName
21+
email
22+
lead
23+
}
24+
}
25+
}
26+
}
27+
}`;
28+
const response = await this.app.getLeads({
29+
$,
30+
data: {
31+
query,
32+
},
33+
});
34+
$.export("$summary", "Successfully fetched Leads");
35+
return response;
36+
},
37+
};

components/tubular/app/tubular.app.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

components/tubular/tubular.app.mjs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { axios } from "@pipedream/platform";
2+
3+
export default {
4+
type: "app",
5+
app: "tubular",
6+
propDefinitions: {
7+
firstName: {
8+
type: "string",
9+
label: "First Name",
10+
description: "The contact's first name",
11+
},
12+
lastName: {
13+
type: "string",
14+
label: "Last Name",
15+
description: "The contact's last name",
16+
},
17+
note: {
18+
type: "string",
19+
label: "Note",
20+
description: "A note about the contact",
21+
},
22+
lead: {
23+
type: "boolean",
24+
label: "Lead",
25+
description: "Indicates whether the contact is a lead",
26+
},
27+
},
28+
methods: {
29+
_baseUrl() {
30+
return "https://api.tubular.io/graphql";
31+
},
32+
async _makeRequest(opts = {}) {
33+
const {
34+
$ = this,
35+
headers,
36+
...otherOpts
37+
} = opts;
38+
return axios($, {
39+
...otherOpts,
40+
url: this._baseUrl(),
41+
headers: {
42+
"Authorization": `${this.$auth.api_token}`,
43+
...headers,
44+
},
45+
});
46+
},
47+
async createLead(args = {}) {
48+
return this._makeRequest({
49+
method: "POST",
50+
...args,
51+
});
52+
},
53+
async getDealsByDate(args = {}) {
54+
return this._makeRequest({
55+
method: "POST",
56+
...args,
57+
});
58+
},
59+
async getLeads(args = {}) {
60+
return this._makeRequest({
61+
method: "POST",
62+
...args,
63+
});
64+
},
65+
},
66+
};

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)