Skip to content

Commit aca6e93

Browse files
committed
[Components] nextdoor - new action components
1 parent 0d5fd08 commit aca6e93

File tree

9 files changed

+734
-18
lines changed

9 files changed

+734
-18
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
import app from "../../nextdoor.app.mjs";
2+
3+
export default {
4+
key: "nextdoor-create-ad-group",
5+
name: "Create Ad Group",
6+
description: "Creates an ad group based on the input payload for an existing campaign. [See the documentation](https://developer.nextdoor.com/reference/adgroup-create).",
7+
version: "0.0.7",
8+
type: "action",
9+
props: {
10+
app,
11+
advertiserId: {
12+
propDefinition: [
13+
app,
14+
"advertiserId",
15+
],
16+
},
17+
campaignId: {
18+
propDefinition: [
19+
app,
20+
"campaignId",
21+
({ advertiserId }) => ({
22+
advertiserId,
23+
}),
24+
],
25+
},
26+
name: {
27+
description: "The name of the ad group.",
28+
propDefinition: [
29+
app,
30+
"name",
31+
],
32+
},
33+
placements: {
34+
type: "string[]",
35+
label: "Placements",
36+
description: "The placements for the ad group.",
37+
options: [
38+
"RHR",
39+
"FEED",
40+
"FSF",
41+
],
42+
},
43+
bid: {
44+
type: "object",
45+
label: "Bid",
46+
description: "The bid for the ad group.",
47+
default: {
48+
amount: "USD 10",
49+
pricing_type: "CPM",
50+
},
51+
},
52+
budget: {
53+
type: "object",
54+
label: "Budget",
55+
description: "The budget for the ad group. Both `amount` and `budget_type` properties are required.",
56+
default: {
57+
amount: "USD 1000",
58+
budget_type: "DAILY_CAP_MONEY",
59+
},
60+
},
61+
startTime: {
62+
propDefinition: [
63+
app,
64+
"startTime",
65+
],
66+
},
67+
endTime: {
68+
propDefinition: [
69+
app,
70+
"endTime",
71+
],
72+
},
73+
frecuencyCaps: {
74+
type: "string[]",
75+
label: "Frecuency Caps",
76+
description: "The frecuency caps for the ad group. Eligible timeunit values are `MINUTE, MINUTES, HOUR, HOURS, DAY, DAYS, WEEK, WEEKS, MONTH, MONTHS`.",
77+
optional: true,
78+
default: [
79+
JSON.stringify({
80+
max_impressions: "<int>",
81+
num_timeunits: "<int>",
82+
timeunit: "<string>",
83+
}),
84+
],
85+
},
86+
targeting: {
87+
type: "object",
88+
label: "Targeting",
89+
description: "Targeting options for the ad group. Should be an object with details as specified by the API documentation.",
90+
optional: true,
91+
},
92+
},
93+
methods: {
94+
createAdGroup(args = {}) {
95+
return this.app.post({
96+
path: "/adgroup/create",
97+
...args,
98+
});
99+
},
100+
},
101+
async run({ $ }) {
102+
const {
103+
createAdGroup,
104+
advertiserId,
105+
campaignId,
106+
name,
107+
placements,
108+
bid,
109+
budget,
110+
startTime,
111+
endTime,
112+
frecuencyCaps,
113+
targeting,
114+
} = this;
115+
116+
const response = await createAdGroup({
117+
$,
118+
data: {
119+
advertiser_id: advertiserId,
120+
campaign_id: campaignId,
121+
name,
122+
placements,
123+
bid,
124+
budget,
125+
start_time: startTime,
126+
end_time: endTime,
127+
frecuency_caps: frecuencyCaps,
128+
targeting,
129+
},
130+
});
131+
132+
$.export("$summary", `Successfully created ad group with ID \`${response.id}\`.`);
133+
return response;
134+
},
135+
};
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import app from "../../nextdoor.app.mjs";
2+
3+
export default {
4+
key: "nextdoor-create-ad",
5+
name: "Create Ad",
6+
description: "Creates an ad based on the input payload for an existing NAM ad group. [See the documentation](https://developer.nextdoor.com/reference/ad-create).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
advertiserId: {
12+
propDefinition: [
13+
app,
14+
"advertiserId",
15+
],
16+
},
17+
campaignId: {
18+
propDefinition: [
19+
app,
20+
"campaignId",
21+
({ advertiserId }) => ({
22+
advertiserId,
23+
}),
24+
],
25+
},
26+
adGroupId: {
27+
propDefinition: [
28+
app,
29+
"adGroupId",
30+
({
31+
advertiserId,
32+
campaignId,
33+
}) => ({
34+
advertiserId,
35+
campaignId,
36+
}),
37+
],
38+
},
39+
creativeId: {
40+
propDefinition: [
41+
app,
42+
"creativeId",
43+
({ advertiserId }) => ({
44+
advertiserId,
45+
}),
46+
],
47+
},
48+
name: {
49+
description: "The name of the ad.",
50+
propDefinition: [
51+
app,
52+
"name",
53+
],
54+
},
55+
},
56+
methods: {
57+
createAd(args = {}) {
58+
return this.app.post({
59+
path: "/ad/create",
60+
...args,
61+
});
62+
},
63+
},
64+
async run({ $ }) {
65+
const {
66+
createAd,
67+
advertiserId,
68+
adGroupId,
69+
creativeId,
70+
name,
71+
} = this;
72+
73+
const response = await createAd({
74+
$,
75+
data: {
76+
advertiser_id: advertiserId,
77+
adgroup_id: adGroupId,
78+
creative_id: creativeId,
79+
name,
80+
},
81+
});
82+
83+
$.export("$summary", `Successfully created ad with ID \`${response.id}\`.`);
84+
return response;
85+
},
86+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import app from "../../nextdoor.app.mjs";
2+
3+
export default {
4+
key: "nextdoor-create-advertiser",
5+
name: "Create Advertiser",
6+
description: "Creates an advertiser that is tied to the NAM profile the API credentials are tied to. [See the documentation](https://developer.nextdoor.com/reference/advertiser-create).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
name: {
12+
description: "The name of the advertiser.",
13+
propDefinition: [
14+
app,
15+
"name",
16+
],
17+
},
18+
websiteUrl: {
19+
propDefinition: [
20+
app,
21+
"websiteUrl",
22+
],
23+
},
24+
categoryId: {
25+
propDefinition: [
26+
app,
27+
"categoryId",
28+
],
29+
},
30+
},
31+
methods: {
32+
createAdvertiser(args = {}) {
33+
return this.app.post({
34+
path: "/advertiser/create",
35+
...args,
36+
});
37+
},
38+
},
39+
async run({ $ }) {
40+
const {
41+
createAdvertiser,
42+
name,
43+
websiteUrl,
44+
categoryId,
45+
} = this;
46+
47+
const response = await createAdvertiser({
48+
$,
49+
data: {
50+
name,
51+
website_url: websiteUrl,
52+
category_id: categoryId,
53+
},
54+
});
55+
56+
$.export("$summary", `Successfully created advertiser with ID \`${response.id}\`.`);
57+
return response;
58+
},
59+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import app from "../../nextdoor.app.mjs";
2+
3+
export default {
4+
key: "nextdoor-create-campaign",
5+
name: "Create Campaign",
6+
description: "Creates a campaign. [See the documentation](https://developer.nextdoor.com/reference/campaign-create).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
advertiserId: {
12+
propDefinition: [
13+
app,
14+
"advertiserId",
15+
],
16+
},
17+
name: {
18+
description: "The name of the campaign.",
19+
propDefinition: [
20+
app,
21+
"name",
22+
],
23+
},
24+
objective: {
25+
propDefinition: [
26+
app,
27+
"objective",
28+
],
29+
},
30+
},
31+
methods: {
32+
createCampaign(args = {}) {
33+
return this.app.post({
34+
path: "/campaign/create",
35+
...args,
36+
});
37+
},
38+
},
39+
async run({ $ }) {
40+
const {
41+
createCampaign,
42+
advertiserId,
43+
name,
44+
objective,
45+
} = this;
46+
47+
const response = await createCampaign({
48+
$,
49+
data: {
50+
advertiser_id: advertiserId,
51+
name,
52+
objective,
53+
},
54+
});
55+
56+
$.export("$summary", `Successfully created campaign with ID \`${response.id}\`.`);
57+
return response;
58+
},
59+
};

0 commit comments

Comments
 (0)