-
Notifications
You must be signed in to change notification settings - Fork 5.5k
14336 aweber #18738
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
base: master
Are you sure you want to change the base?
14336 aweber #18738
Changes from all commits
5af1965
76006bd
44b6eb2
68a4918
5671e0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,165 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import aweberApp from "../../aweber.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
key: "aweber-create-broadcast", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: "Create Broadcast", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "Create a broadcast under the specified account and list. [See the docs here](https://api.aweber.com/#tag/Broadcasts/paths/~1accounts~1%7BaccountId%7D~1lists~1%7BlistId%7D~1broadcasts/post).", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
annotations: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
destructiveHint: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
openWorldHint: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
readOnlyHint: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"accountId", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
listId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"listId", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
({ accountId }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bodyHTML: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Body HTML", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "The content of the message in HTML format. If `Body Text` is not provided, it will be auto-generated. If `Body Text` is not provided, `Body HTML` must be provided.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bodyText: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Body Text", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "The content of the message in plain text, used when HTML is not supported. If `Body HTML` is not provided, the broadcast will be sent using only the `Body Text`. If `Body Text` is not provided, `Body HTML` must be provided.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+31
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify the bodyHTML description and add runtime validation. The description for Additionally, as noted in a previous review, while both props are now optional, there's no validation in the Apply this diff to clarify the description: bodyHTML: {
type: "string",
label: "Body HTML",
- description: "The content of the message in HTML format. If `Body Text` is not provided, it will be auto-generated. If `Body Text` is not provided, `Body HTML` must be provided.",
+ description: "The content of the message in HTML format. If `Body Text` is not provided, it will be auto-generated from `Body HTML`. At least one of `Body HTML` or `Body Text` must be provided.",
optional: true,
},
bodyText: {
type: "string",
label: "Body Text",
description: "The content of the message in plain text, used when HTML is not supported. If `Body HTML` is not provided, the broadcast will be sent using only the `Body Text`. If `Body Text` is not provided, `Body HTML` must be provided.",
optional: true,
}, Then add validation in the async run({ $ }) {
+ if (!this.bodyHTML && !this.bodyText) {
+ throw new Error("At least one of 'Body HTML' or 'Body Text' must be provided.");
+ }
+
const response = await this.aweberApp.createBroadcast({ 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bodyAmp: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Body AMP", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "The content of the message in AMP format. [Read Aweber KB article before using this field](https://help.aweber.com/hc/en-us/articles/360025741194)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clickTrackingEnabled: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "boolean", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Click Tracking Enabled", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "Enables links in the email message to be tracked.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
excludeLists: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"listSelfLink", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
({ accountId }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "string[]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Exclude Lists", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "List of [Lists](https://api.aweber.com/#tag/Lists) URLs to exclude in the delivery of this broadcast. **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/lists/<list_id>`**", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
includeLists: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"listSelfLink", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
({ accountId }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "string[]", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Include Lists", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "List of [Lists](https://api.aweber.com/#tag/Lists) URLs to include in the delivery of this broadcast. **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/lists/<list_id>`**", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
facebookIntegration: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"integrations", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
({ accountId }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
serviceName: "facebook", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Facebook Integration", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "URL to the [Facebook broadcast integration](https://api.aweber.com/#tag/Integrations) to use for this broadcast. When the broadcast is sent, the subject of the broadcast will be posted to this Facebook integration - **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/integrations/<integration_id>`**.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isArchived: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "boolean", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Is Archived", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "Whether the broadcast enabled sharing via an archive URL.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
notifyOnSend: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "boolean", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Notify on Send", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "If true, notify when stats are available on a sent broadcast message.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
segmentLink: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"segmentSelfLink", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId, listId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
listId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
subject: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Subject", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "The broadcast subject line. Subject must not be empty nor contain only whitespace.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
twitterIntegration: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
aweberApp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"integrations", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
({ accountId }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
serviceName: "twitter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label: "Twitter Integration", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "URL to the [Twitter broadcast integration](https://api.aweber.com/#tag/Integrations) to use for this broadcast. When the broadcast is sent, the subject of the broadcast will be tweeted - **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/integrations/<integration_id>`**.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const response = await this.aweberApp.createBroadcast({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accountId: this.accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
listId: this.listId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
body_html: this.bodyHTML, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
body_text: this.bodyText, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
body_amp: this.bodyAmp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
click_tracking_enabled: this.clickTrackingEnabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exclude_lists: this.excludeLists, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
include_lists: this.includeLists, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
facebook_integration: this.facebookIntegration, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
is_archived: this.isArchived, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
notify_on_send: this.notifyOnSend, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
segment_link: this.segmentLink, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
subject: this.subject, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
twitter_integration: this.twitterIntegration, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Content-Type": "application/x-www-form-urlencoded", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$.export("$summary", `Successfully created broadcast with **UUID: ${response.uuid}**.`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; |
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.