Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import buysellads from "../../buysellads.app.mjs";

export default {
key: "buysellads-get-creatives-daily-stats",
name: "Get Creatives Daily Stats",
description: "Returns the creative stats by day for line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#creatives-daily-stats)",
version: "0.0.1",
type: "action",
props: {
buysellads,
lineItemId: {
propDefinition: [
buysellads,
"lineItemId",
],
},
startDate: {
propDefinition: [
buysellads,
"startDate",
],
},
endDate: {
propDefinition: [
buysellads,
"endDate",
],
},
csvOutput: {
propDefinition: [
buysellads,
"csvOutput",
],
},
},
async run({ $ }) {
const response = await this.buysellads.listCreativesDailyStats({
$,
params: {
lineitemId: this.lineItemId,
startDate: this.startDate,
endDate: this.endDate,
type: this.csvOutput
? "csv"
: undefined,
},
});

const length = this.csvOutput
? response.split("\n").length - 1
: response.length;

$.export("$summary", `Successfully fetched ${length} creative stat${length === 1
? ""
: "s"}`);
return response;
},
};
58 changes: 58 additions & 0 deletions components/buysellads/actions/get-creatives/get-creatives.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import buysellads from "../../buysellads.app.mjs";

export default {
key: "buysellads-get-creatives",
name: "Get Creatives",
description: "Returns the creative stats for line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#creatives)",
version: "0.0.1",
type: "action",
props: {
buysellads,
lineItemId: {
propDefinition: [
buysellads,
"lineItemId",
],
},
startDate: {
propDefinition: [
buysellads,
"startDate",
],
},
endDate: {
propDefinition: [
buysellads,
"endDate",
],
},
csvOutput: {
propDefinition: [
buysellads,
"csvOutput",
],
},
},
async run({ $ }) {
const response = await this.buysellads.listCreatives({
$,
params: {
lineitemId: this.lineItemId,
startDate: this.startDate,
endDate: this.endDate,
type: this.csvOutput
? "csv"
: undefined,
},
});

const length = this.csvOutput
? response.split("\n").length - 1
: response.length;

$.export("$summary", `Successfully fetched ${length} creative${length === 1
? ""
: "s"}`);
return response;
},
};
58 changes: 58 additions & 0 deletions components/buysellads/actions/get-daily-stats/get-daily-stats.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import buysellads from "../../buysellads.app.mjs";

export default {
key: "buysellads-get-daily-stats",
name: "Get Daily Stats",
description: "Returns the daily stats for active line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#daily-stats)",
version: "0.0.1",
type: "action",
props: {
buysellads,
lineItemId: {
propDefinition: [
buysellads,
"lineItemId",
],
},
startDate: {
propDefinition: [
buysellads,
"startDate",
],
},
endDate: {
propDefinition: [
buysellads,
"endDate",
],
},
csvOutput: {
propDefinition: [
buysellads,
"csvOutput",
],
},
},
async run({ $ }) {
const response = await this.buysellads.listDailyStats({
$,
params: {
lineitemId: this.lineItemId,
startDate: this.startDate,
endDate: this.endDate,
type: this.csvOutput
? "csv"
: undefined,
},
});

const length = this.csvOutput
? response.split("\n").length - 1
: response.length;

$.export("$summary", `Successfully fetched ${length} daily stat${length === 1
? ""
: "s"}`);
return response;
},
};
51 changes: 51 additions & 0 deletions components/buysellads/actions/get-line-items/get-line-items.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import buysellads from "../../buysellads.app.mjs";

export default {
key: "buysellads-get-line-items",
name: "Get Line Items",
description: "Returns the details of active line items. [See the documentation](https://docs.buysellads.com/advertiser-api/endpoints#lineitems)",
version: "0.0.1",
type: "action",
props: {
buysellads,
startDate: {
propDefinition: [
buysellads,
"startDate",
],
},
endDate: {
propDefinition: [
buysellads,
"endDate",
],
},
csvOutput: {
propDefinition: [
buysellads,
"csvOutput",
],
},
},
async run({ $ }) {
const response = await this.buysellads.listLineItems({
$,
params: {
startDate: this.startDate,
endDate: this.endDate,
type: this.csvOutput
? "csv"
: undefined,
},
});

const length = this.csvOutput
? response.split("\n").length - 1
: response.length;

$.export("$summary", `Successfully fetched ${length} line item${length === 1
? ""
: "s"}`);
return response;
},
};
77 changes: 73 additions & 4 deletions components/buysellads/buysellads.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,80 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "buysellads",
propDefinitions: {},
propDefinitions: {
lineItemId: {
type: "string",
label: "Line Item ID",
description: "The ID of a line item",
optional: true,
async options() {
const lineitems = await this.listLineItems();
return lineitems?.map((lineitem) => ({
label: lineitem.lineitem_name,
value: lineitem.lineitem_id,
})) || [];
},
},
startDate: {
type: "string",
label: "Start Date",
description: "The start date in `yyyy-mm-dd` format",
optional: true,
},
endDate: {
type: "string",
label: "End Date",
description: "The end date in `yyyy-mm-dd` format",
optional: true,
},
csvOutput: {
type: "boolean",
label: "CSV Output",
description: "Whether to return the response as CSV output",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://papi.buysellads.com";
},
_makeRequest({
$ = this, path, params = {}, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
params: {
...params,
key: this.$auth.api_key,
},
...opts,
});
},
listLineItems(opts = {}) {
return this._makeRequest({
path: "/lineitems",
...opts,
});
},
listDailyStats(opts = {}) {
return this._makeRequest({
path: "/daily-stats",
...opts,
});
},
listCreatives(opts = {}) {
return this._makeRequest({
path: "/creatives",
...opts,
});
},
listCreativesDailyStats(opts = {}) {
return this._makeRequest({
path: "/creatives-daily-stats",
...opts,
});
},
},
};
5 changes: 4 additions & 1 deletion components/buysellads/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/buysellads",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream BuySellAds Components",
"main": "buysellads.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
Loading
Loading