-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Components] nextdoor - new action components #15306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jcortes
wants to merge
1
commit into
master
Choose a base branch
from
nextdoor-new-lead-instant-source
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+949
−10
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
202 changes: 202 additions & 0 deletions
202
components/nextdoor/actions/create-ad-group/create-ad-group.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
import app from "../../nextdoor.app.mjs"; | ||
import utils from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "nextdoor-create-ad-group", | ||
name: "Create Ad Group", | ||
description: "Creates an ad group based on the input payload for an existing campaign. [See the documentation](https://developer.nextdoor.com/reference/adgroup-create).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
advertiserId: { | ||
propDefinition: [ | ||
app, | ||
"advertiserId", | ||
], | ||
}, | ||
campaignId: { | ||
propDefinition: [ | ||
app, | ||
"campaignId", | ||
({ advertiserId }) => ({ | ||
advertiserId, | ||
}), | ||
], | ||
}, | ||
name: { | ||
description: "The name of the ad group.", | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
placements: { | ||
type: "string[]", | ||
label: "Placements", | ||
description: "The placements for the ad group.", | ||
options: [ | ||
"RHR", | ||
"FEED", | ||
"FSF", | ||
], | ||
}, | ||
bidAmount: { | ||
type: "string", | ||
label: "Bid Amount", | ||
description: "The bid amount for the ad group. The value must be a string in the format `USD 10` as an example.", | ||
}, | ||
bidPricingType: { | ||
type: "string", | ||
label: "Bid Pricing Type", | ||
description: "The bid pricing type for the ad group. The value must be one of `CPM`.", | ||
options: [ | ||
"CPM", | ||
], | ||
}, | ||
budgetAmount: { | ||
type: "string", | ||
label: "Budget Amount", | ||
description: "The budget amount for the ad group. The value must be a string in the format `USD 10` as an example.", | ||
}, | ||
budgetType: { | ||
type: "string", | ||
label: "Budget Type", | ||
description: "The budget type for the ad group.", | ||
options: [ | ||
"DAILY_CAP_MONEY", | ||
], | ||
}, | ||
startTime: { | ||
propDefinition: [ | ||
app, | ||
"startTime", | ||
], | ||
}, | ||
endTime: { | ||
propDefinition: [ | ||
app, | ||
"endTime", | ||
], | ||
}, | ||
numberOfFrequencyCaps: { | ||
type: "integer", | ||
label: "Number Of Frequency Caps", | ||
description: "The number of frequency caps to be collected. Defaults to `1`.", | ||
default: 1, | ||
reloadProps: true, | ||
}, | ||
}, | ||
methods: { | ||
frequencyCapsPropsMapper(prefix) { | ||
const { | ||
[`${prefix}maxImpressions`]: maxImpressions, | ||
[`${prefix}numTimeunits`]: numTimeunits, | ||
[`${prefix}timeunit`]: timeunit, | ||
} = this; | ||
|
||
return { | ||
max_impressions: maxImpressions, | ||
num_timeunits: numTimeunits, | ||
timeunit, | ||
}; | ||
}, | ||
getFrequencyCapsPropDefinitions({ | ||
prefix, | ||
label, | ||
} = {}) { | ||
return { | ||
[`${prefix}maxImpressions`]: { | ||
type: "integer", | ||
label: `${label} - Max Impressions`, | ||
description: "The maximum number of impressions.", | ||
}, | ||
[`${prefix}numTimeunits`]: { | ||
type: "integer", | ||
label: `${label} - Number of Time Units`, | ||
description: "The number of time units for frequency caps.", | ||
}, | ||
[`${prefix}timeunit`]: { | ||
type: "string", | ||
label: `${label} - Time Unit`, | ||
description: "The time unit for frequency caps.", | ||
options: [ | ||
"MINUTE", | ||
"MINUTES", | ||
"HOUR", | ||
"HOURS", | ||
"DAY", | ||
"DAYS", | ||
"WEEK", | ||
"WEEKS", | ||
"MONTH", | ||
"MONTHS", | ||
], | ||
}, | ||
}; | ||
}, | ||
createAdGroup(args = {}) { | ||
return this.app.post({ | ||
path: "/adgroup/create", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async additionalProps() { | ||
const { | ||
numberOfFrequencyCaps, | ||
getFrequencyCapsPropDefinitions, | ||
} = this; | ||
|
||
return utils.getAdditionalProps({ | ||
numberOfFields: numberOfFrequencyCaps, | ||
fieldName: "frequency cap", | ||
getPropDefinitions: getFrequencyCapsPropDefinitions, | ||
}); | ||
}, | ||
async run({ $ }) { | ||
const { | ||
createAdGroup, | ||
advertiserId, | ||
campaignId, | ||
name, | ||
placements, | ||
bidAmount, | ||
bidPricingType, | ||
budgetAmount, | ||
budgetType, | ||
startTime, | ||
endTime, | ||
numberOfFrequencyCaps, | ||
frequencyCapsPropsMapper, | ||
} = this; | ||
|
||
const response = await createAdGroup({ | ||
$, | ||
data: { | ||
advertiser_id: advertiserId, | ||
campaign_id: campaignId, | ||
name, | ||
placements: utils.parseArray(placements), | ||
bid: { | ||
amount: bidAmount, | ||
pricing_type: bidPricingType, | ||
}, | ||
budget: { | ||
amount: budgetAmount, | ||
budget_type: budgetType, | ||
}, | ||
start_time: startTime, | ||
end_time: endTime, | ||
frequency_caps: utils.getFieldsProps({ | ||
numberOfFields: numberOfFrequencyCaps, | ||
fieldName: "frequency cap", | ||
propsMapper: frequencyCapsPropsMapper, | ||
}), | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created ad group with ID \`${response.id}\`.`); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import app from "../../nextdoor.app.mjs"; | ||
|
||
export default { | ||
key: "nextdoor-create-ad", | ||
name: "Create Ad", | ||
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).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
advertiserId: { | ||
propDefinition: [ | ||
app, | ||
"advertiserId", | ||
], | ||
}, | ||
campaignId: { | ||
propDefinition: [ | ||
app, | ||
"campaignId", | ||
({ advertiserId }) => ({ | ||
advertiserId, | ||
}), | ||
], | ||
}, | ||
adGroupId: { | ||
propDefinition: [ | ||
app, | ||
"adGroupId", | ||
({ | ||
advertiserId, | ||
campaignId, | ||
}) => ({ | ||
advertiserId, | ||
campaignId, | ||
}), | ||
], | ||
}, | ||
creativeId: { | ||
propDefinition: [ | ||
app, | ||
"creativeId", | ||
({ advertiserId }) => ({ | ||
advertiserId, | ||
}), | ||
], | ||
}, | ||
name: { | ||
description: "The name of the ad.", | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
createAd(args = {}) { | ||
return this.app.post({ | ||
path: "/ad/create", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
createAd, | ||
advertiserId, | ||
adGroupId, | ||
creativeId, | ||
name, | ||
} = this; | ||
|
||
const response = await createAd({ | ||
$, | ||
data: { | ||
advertiser_id: advertiserId, | ||
adgroup_id: adGroupId, | ||
creative_id: creativeId, | ||
name, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created ad with ID \`${response.id}\`.`); | ||
return response; | ||
}, | ||
}; |
59 changes: 59 additions & 0 deletions
59
components/nextdoor/actions/create-advertiser/create-advertiser.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import app from "../../nextdoor.app.mjs"; | ||
|
||
export default { | ||
key: "nextdoor-create-advertiser", | ||
name: "Create Advertiser", | ||
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).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
name: { | ||
description: "The name of the advertiser.", | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
websiteUrl: { | ||
propDefinition: [ | ||
app, | ||
"websiteUrl", | ||
], | ||
}, | ||
categoryId: { | ||
propDefinition: [ | ||
app, | ||
"categoryId", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
createAdvertiser(args = {}) { | ||
return this.app.post({ | ||
path: "/advertiser/create", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
createAdvertiser, | ||
name, | ||
websiteUrl, | ||
categoryId, | ||
} = this; | ||
|
||
const response = await createAdvertiser({ | ||
$, | ||
data: { | ||
name, | ||
website_url: websiteUrl, | ||
category_id: categoryId, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created advertiser with ID \`${response.id}\`.`); | ||
return response; | ||
}, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there really only one option? If so, it should probably be set in the code directly instead of being a prop