|  | 
|  | 1 | +import aweberApp from "../../aweber.app.mjs"; | 
|  | 2 | + | 
|  | 3 | +export default { | 
|  | 4 | +  key: "aweber-create-broadcast", | 
|  | 5 | +  name: "Create Broadcast", | 
|  | 6 | +  description: "Create a broadcast under the specified account and list. [See the documentation](https://api.aweber.com/#tag/Broadcasts/paths/~1accounts~1%7BaccountId%7D~1lists~1%7BlistId%7D~1broadcasts/post).", | 
|  | 7 | +  type: "action", | 
|  | 8 | +  version: "0.0.1", | 
|  | 9 | +  annotations: { | 
|  | 10 | +    destructiveHint: false, | 
|  | 11 | +    openWorldHint: true, | 
|  | 12 | +    readOnlyHint: false, | 
|  | 13 | +  }, | 
|  | 14 | +  props: { | 
|  | 15 | +    aweberApp, | 
|  | 16 | +    accountId: { | 
|  | 17 | +      propDefinition: [ | 
|  | 18 | +        aweberApp, | 
|  | 19 | +        "accountId", | 
|  | 20 | +      ], | 
|  | 21 | +    }, | 
|  | 22 | +    listId: { | 
|  | 23 | +      propDefinition: [ | 
|  | 24 | +        aweberApp, | 
|  | 25 | +        "listId", | 
|  | 26 | +        ({ accountId }) => ({ | 
|  | 27 | +          accountId, | 
|  | 28 | +        }), | 
|  | 29 | +      ], | 
|  | 30 | +    }, | 
|  | 31 | +    bodyHTML: { | 
|  | 32 | +      type: "string", | 
|  | 33 | +      label: "Body HTML", | 
|  | 34 | +      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.", | 
|  | 35 | +      optional: true, | 
|  | 36 | +    }, | 
|  | 37 | +    bodyText: { | 
|  | 38 | +      type: "string", | 
|  | 39 | +      label: "Body Text", | 
|  | 40 | +      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.", | 
|  | 41 | +      optional: true, | 
|  | 42 | +    }, | 
|  | 43 | +    bodyAmp: { | 
|  | 44 | +      type: "string", | 
|  | 45 | +      label: "Body AMP", | 
|  | 46 | +      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)", | 
|  | 47 | +      optional: true, | 
|  | 48 | +    }, | 
|  | 49 | +    clickTrackingEnabled: { | 
|  | 50 | +      type: "boolean", | 
|  | 51 | +      label: "Click Tracking Enabled", | 
|  | 52 | +      description: "Enables links in the email message to be tracked.", | 
|  | 53 | +      optional: true, | 
|  | 54 | +    }, | 
|  | 55 | +    excludeLists: { | 
|  | 56 | +      propDefinition: [ | 
|  | 57 | +        aweberApp, | 
|  | 58 | +        "listSelfLink", | 
|  | 59 | +        ({ accountId }) => ({ | 
|  | 60 | +          accountId, | 
|  | 61 | +        }), | 
|  | 62 | +      ], | 
|  | 63 | +      type: "string[]", | 
|  | 64 | +      label: "Exclude Lists", | 
|  | 65 | +      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>`**", | 
|  | 66 | +      optional: true, | 
|  | 67 | +    }, | 
|  | 68 | +    includeLists: { | 
|  | 69 | +      propDefinition: [ | 
|  | 70 | +        aweberApp, | 
|  | 71 | +        "listSelfLink", | 
|  | 72 | +        ({ accountId }) => ({ | 
|  | 73 | +          accountId, | 
|  | 74 | +        }), | 
|  | 75 | +      ], | 
|  | 76 | +      type: "string[]", | 
|  | 77 | +      label: "Include Lists", | 
|  | 78 | +      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>`**", | 
|  | 79 | +      optional: true, | 
|  | 80 | +    }, | 
|  | 81 | +    facebookIntegration: { | 
|  | 82 | +      propDefinition: [ | 
|  | 83 | +        aweberApp, | 
|  | 84 | +        "integrations", | 
|  | 85 | +        ({ accountId }) => ({ | 
|  | 86 | +          accountId, | 
|  | 87 | +          serviceName: "facebook", | 
|  | 88 | +        }), | 
|  | 89 | +      ], | 
|  | 90 | +      label: "Facebook Integration", | 
|  | 91 | +      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>`**.", | 
|  | 92 | +      optional: true, | 
|  | 93 | +    }, | 
|  | 94 | +    isArchived: { | 
|  | 95 | +      type: "boolean", | 
|  | 96 | +      label: "Is Archived", | 
|  | 97 | +      description: "Whether the broadcast enabled sharing via an archive URL.", | 
|  | 98 | +      optional: true, | 
|  | 99 | +    }, | 
|  | 100 | +    notifyOnSend: { | 
|  | 101 | +      type: "boolean", | 
|  | 102 | +      label: "Notify on Send", | 
|  | 103 | +      description: "If true, notify when stats are available on a sent broadcast message.", | 
|  | 104 | +      optional: true, | 
|  | 105 | +    }, | 
|  | 106 | +    segmentLink: { | 
|  | 107 | +      propDefinition: [ | 
|  | 108 | +        aweberApp, | 
|  | 109 | +        "segmentSelfLink", | 
|  | 110 | +        ({ | 
|  | 111 | +          accountId, listId, | 
|  | 112 | +        }) => ({ | 
|  | 113 | +          accountId, | 
|  | 114 | +          listId, | 
|  | 115 | +        }), | 
|  | 116 | +      ], | 
|  | 117 | +      optional: true, | 
|  | 118 | +    }, | 
|  | 119 | +    subject: { | 
|  | 120 | +      type: "string", | 
|  | 121 | +      label: "Subject", | 
|  | 122 | +      description: "The broadcast subject line. Subject must not be empty nor contain only whitespace.", | 
|  | 123 | +    }, | 
|  | 124 | +    twitterIntegration: { | 
|  | 125 | +      propDefinition: [ | 
|  | 126 | +        aweberApp, | 
|  | 127 | +        "integrations", | 
|  | 128 | +        ({ accountId }) => ({ | 
|  | 129 | +          accountId, | 
|  | 130 | +          serviceName: "twitter", | 
|  | 131 | +        }), | 
|  | 132 | +      ], | 
|  | 133 | +      label: "Twitter Integration", | 
|  | 134 | +      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>`**.", | 
|  | 135 | +      optional: true, | 
|  | 136 | +    }, | 
|  | 137 | +  }, | 
|  | 138 | +  async run({ $ }) { | 
|  | 139 | +    const response = await this.aweberApp.createBroadcast({ | 
|  | 140 | +      $, | 
|  | 141 | +      accountId: this.accountId, | 
|  | 142 | +      listId: this.listId, | 
|  | 143 | +      data: { | 
|  | 144 | +        body_html: this.bodyHTML, | 
|  | 145 | +        body_text: this.bodyText, | 
|  | 146 | +        body_amp: this.bodyAmp, | 
|  | 147 | +        click_tracking_enabled: this.clickTrackingEnabled, | 
|  | 148 | +        exclude_lists: this.excludeLists, | 
|  | 149 | +        include_lists: this.includeLists, | 
|  | 150 | +        facebook_integration: this.facebookIntegration, | 
|  | 151 | +        is_archived: this.isArchived, | 
|  | 152 | +        notify_on_send: this.notifyOnSend, | 
|  | 153 | +        segment_link: this.segmentLink, | 
|  | 154 | +        subject: this.subject, | 
|  | 155 | +        twitter_integration: this.twitterIntegration, | 
|  | 156 | +      }, | 
|  | 157 | +      headers: { | 
|  | 158 | +        "Content-Type": "application/x-www-form-urlencoded", | 
|  | 159 | +      }, | 
|  | 160 | +    }); | 
|  | 161 | + | 
|  | 162 | +    $.export("$summary", `Successfully created broadcast with **UUID: ${response.uuid}**.`); | 
|  | 163 | +    return response; | 
|  | 164 | +  }, | 
|  | 165 | +}; | 
0 commit comments