Skip to content

Commit 7f91bab

Browse files
authored
New Components - buysellads (#17505)
* new components * pnpm-lock.yaml * updates
1 parent 7dc03a2 commit 7f91bab

File tree

7 files changed

+309
-8
lines changed

7 files changed

+309
-8
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import buysellads from "../../buysellads.app.mjs";
2+
3+
export default {
4+
key: "buysellads-get-creatives-daily-stats",
5+
name: "Get Creatives Daily Stats",
6+
description: "Returns the creative stats by day for line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#creatives-daily-stats)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
buysellads,
11+
lineItemId: {
12+
propDefinition: [
13+
buysellads,
14+
"lineItemId",
15+
],
16+
},
17+
startDate: {
18+
propDefinition: [
19+
buysellads,
20+
"startDate",
21+
],
22+
},
23+
endDate: {
24+
propDefinition: [
25+
buysellads,
26+
"endDate",
27+
],
28+
},
29+
csvOutput: {
30+
propDefinition: [
31+
buysellads,
32+
"csvOutput",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.buysellads.listCreativesDailyStats({
38+
$,
39+
params: {
40+
lineitemId: this.lineItemId,
41+
startDate: this.startDate,
42+
endDate: this.endDate,
43+
type: this.csvOutput
44+
? "csv"
45+
: undefined,
46+
},
47+
});
48+
49+
const length = this.csvOutput
50+
? response.split("\n").length - 1
51+
: response.length;
52+
53+
$.export("$summary", `Successfully fetched ${length} creative stat${length === 1
54+
? ""
55+
: "s"}`);
56+
return response;
57+
},
58+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import buysellads from "../../buysellads.app.mjs";
2+
3+
export default {
4+
key: "buysellads-get-creatives",
5+
name: "Get Creatives",
6+
description: "Returns the creative stats for line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#creatives)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
buysellads,
11+
lineItemId: {
12+
propDefinition: [
13+
buysellads,
14+
"lineItemId",
15+
],
16+
},
17+
startDate: {
18+
propDefinition: [
19+
buysellads,
20+
"startDate",
21+
],
22+
},
23+
endDate: {
24+
propDefinition: [
25+
buysellads,
26+
"endDate",
27+
],
28+
},
29+
csvOutput: {
30+
propDefinition: [
31+
buysellads,
32+
"csvOutput",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.buysellads.listCreatives({
38+
$,
39+
params: {
40+
lineitemId: this.lineItemId,
41+
startDate: this.startDate,
42+
endDate: this.endDate,
43+
type: this.csvOutput
44+
? "csv"
45+
: undefined,
46+
},
47+
});
48+
49+
const length = this.csvOutput
50+
? response.split("\n").length - 1
51+
: response.length;
52+
53+
$.export("$summary", `Successfully fetched ${length} creative${length === 1
54+
? ""
55+
: "s"}`);
56+
return response;
57+
},
58+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import buysellads from "../../buysellads.app.mjs";
2+
3+
export default {
4+
key: "buysellads-get-daily-stats",
5+
name: "Get Daily Stats",
6+
description: "Returns the daily stats for active line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#daily-stats)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
buysellads,
11+
lineItemId: {
12+
propDefinition: [
13+
buysellads,
14+
"lineItemId",
15+
],
16+
},
17+
startDate: {
18+
propDefinition: [
19+
buysellads,
20+
"startDate",
21+
],
22+
},
23+
endDate: {
24+
propDefinition: [
25+
buysellads,
26+
"endDate",
27+
],
28+
},
29+
csvOutput: {
30+
propDefinition: [
31+
buysellads,
32+
"csvOutput",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.buysellads.listDailyStats({
38+
$,
39+
params: {
40+
lineitemId: this.lineItemId,
41+
startDate: this.startDate,
42+
endDate: this.endDate,
43+
type: this.csvOutput
44+
? "csv"
45+
: undefined,
46+
},
47+
});
48+
49+
const length = this.csvOutput
50+
? response.split("\n").length - 1
51+
: response.length;
52+
53+
$.export("$summary", `Successfully fetched ${length} daily stat${length === 1
54+
? ""
55+
: "s"}`);
56+
return response;
57+
},
58+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import buysellads from "../../buysellads.app.mjs";
2+
3+
export default {
4+
key: "buysellads-get-line-items",
5+
name: "Get Line Items",
6+
description: "Returns the details of active line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#lineitems)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
buysellads,
11+
startDate: {
12+
propDefinition: [
13+
buysellads,
14+
"startDate",
15+
],
16+
},
17+
endDate: {
18+
propDefinition: [
19+
buysellads,
20+
"endDate",
21+
],
22+
},
23+
csvOutput: {
24+
propDefinition: [
25+
buysellads,
26+
"csvOutput",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.buysellads.listLineItems({
32+
$,
33+
params: {
34+
startDate: this.startDate,
35+
endDate: this.endDate,
36+
type: this.csvOutput
37+
? "csv"
38+
: undefined,
39+
},
40+
});
41+
42+
const length = this.csvOutput
43+
? response.split("\n").length - 1
44+
: response.length;
45+
46+
$.export("$summary", `Successfully fetched ${length} line item${length === 1
47+
? ""
48+
: "s"}`);
49+
return response;
50+
},
51+
};
Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,80 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "buysellads",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
lineItemId: {
8+
type: "string",
9+
label: "Line Item ID",
10+
description: "The ID of a line item",
11+
optional: true,
12+
async options() {
13+
const lineitems = await this.listLineItems();
14+
return lineitems?.map((lineitem) => ({
15+
label: lineitem.lineitem_name,
16+
value: lineitem.lineitem_id,
17+
})) || [];
18+
},
19+
},
20+
startDate: {
21+
type: "string",
22+
label: "Start Date",
23+
description: "The start date in `yyyy-mm-dd` format",
24+
optional: true,
25+
},
26+
endDate: {
27+
type: "string",
28+
label: "End Date",
29+
description: "The end date in `yyyy-mm-dd` format",
30+
optional: true,
31+
},
32+
csvOutput: {
33+
type: "boolean",
34+
label: "CSV Output",
35+
description: "Whether to return the response as CSV output",
36+
optional: true,
37+
},
38+
},
539
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
40+
_baseUrl() {
41+
return "https://papi.buysellads.com";
42+
},
43+
_makeRequest({
44+
$ = this, path, params = {}, ...opts
45+
}) {
46+
return axios($, {
47+
url: `${this._baseUrl()}${path}`,
48+
params: {
49+
...params,
50+
key: this.$auth.api_key,
51+
},
52+
...opts,
53+
});
54+
},
55+
listLineItems(opts = {}) {
56+
return this._makeRequest({
57+
path: "/lineitems",
58+
...opts,
59+
});
60+
},
61+
listDailyStats(opts = {}) {
62+
return this._makeRequest({
63+
path: "/daily-stats",
64+
...opts,
65+
});
66+
},
67+
listCreatives(opts = {}) {
68+
return this._makeRequest({
69+
path: "/creatives",
70+
...opts,
71+
});
72+
},
73+
listCreativesDailyStats(opts = {}) {
74+
return this._makeRequest({
75+
path: "/creatives-daily-stats",
76+
...opts,
77+
});
978
},
1079
},
1180
};

components/buysellads/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/buysellads",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream BuySellAds Components",
55
"main": "buysellads.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.1.0"
1417
}
1518
}

pnpm-lock.yaml

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)