Skip to content

Commit 81c4ad1

Browse files
committed
[Components] nextdoor - new action components
1 parent 902ac05 commit 81c4ad1

File tree

10 files changed

+784
-8
lines changed

10 files changed

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