diff --git a/components/doppler_marketing_automation/actions/add-subscriber/add-subscriber.mjs b/components/doppler_marketing_automation/actions/add-subscriber/add-subscriber.mjs deleted file mode 100644 index 768b2d3fb0d4b..0000000000000 --- a/components/doppler_marketing_automation/actions/add-subscriber/add-subscriber.mjs +++ /dev/null @@ -1,60 +0,0 @@ -import app from "../../doppler_marketing_automation.app.mjs"; - -export default { - name: "Add Subscriber", - version: "0.0.1", - key: "doppler_marketing_automation-add-subscriber", - description: "Add new subscriber. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameSubscribersPost)", - type: "action", - props: { - app, - email: { - label: "Subscriber Email", - description: "The subscriber email", - type: "string", - }, - birthday: { - type: "string", - label: "Birthday", - description: "Birthday of the subscriber in YYYY-MM-DD format. E.g. `1999-05-28`", - }, - firstName: { - type: "string", - label: "First Name", - description: "First name of the subscriber", - }, - lastName: { - type: "string", - label: "Last Name", - description: "Last name of the subscriber", - }, - }, - async run({ $ }) { - const response = await this.app.addSubscriber({ - $, - data: { - email: this.email, - fields: [ - { - name: "BIRTHDAY", - value: this.birthday, - }, - { - name: "FIRSTNAME", - value: this.firstName, - }, - { - name: "LASTNAME", - value: this.lastName, - }, - ], - }, - }); - - if (response) { - $.export("$summary", `Successfully added subscriber with email ${this.email}`); - } - - return response; - }, -}; diff --git a/components/doppler_marketing_automation/actions/add-update-subscriber/add-update-subscriber.mjs b/components/doppler_marketing_automation/actions/add-update-subscriber/add-update-subscriber.mjs new file mode 100644 index 0000000000000..33bacf08d24d9 --- /dev/null +++ b/components/doppler_marketing_automation/actions/add-update-subscriber/add-update-subscriber.mjs @@ -0,0 +1,93 @@ +import { + COUNTRY_OPTIONS, GENDER_OPTIONS, +} from "../../common/constants.mjs"; +import app from "../../doppler_marketing_automation.app.mjs"; + +export default { + key: "doppler_marketing_automation-add-update-subscriber", + name: "Add or Update Subscriber", + description: "Adds a new subscriber or updates an existing one. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersPost)", + version: "0.0.1", + type: "action", + props: { + app, + listId: { + propDefinition: [ + app, + "listId", + ], + }, + subscriberEmail: { + type: "string", + label: "Subscriber Email", + description: "The email of the subscriber to add or update.", + }, + firstName: { + type: "string", + label: "First Name", + description: "Subscriber first name", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "Subscriber last name", + optional: true, + }, + birthDate: { + type: "string", + label: "Birth Date", + description: "The birth date of the subscriber", + optional: true, + }, + country: { + type: "string", + label: "Country", + description: "Optional country of the subscriber", + options: COUNTRY_OPTIONS, + optional: true, + }, + gender: { + type: "string", + label: "Gender", + description: "The gender of the subscriber", + options: GENDER_OPTIONS, + optional: true, + }, + }, + async run({ $ }) { + const fields = []; + if (this.firstName) fields.push({ + name: "FIRSTNAME", + value: this.firstName, + }); + if (this.lastName) fields.push({ + name: "LASTNAME", + value: this.lastName, + }); + if (this.birthDate) fields.push({ + name: "BIRTHDAY", + value: this.birthDate, + }); + if (this.country) fields.push({ + name: "COUNTRY", + value: this.country, + }); + if (this.gender) fields.push({ + name: "GENDER", + value: this.gender, + }); + + const response = await this.app.addOrUpdateSubscriber({ + $, + listId: this.listId, + data: { + email: this.subscriberEmail, + fields, + }, + }); + + $.export("$summary", `Successfully added or updated subscriber with email: ${this.subscriberEmail}`); + return response; + }, +}; diff --git a/components/doppler_marketing_automation/actions/get-subscriber/get-subscriber.mjs b/components/doppler_marketing_automation/actions/get-subscriber/get-subscriber.mjs index 77665ebee5b12..0678c6e9ff4e6 100644 --- a/components/doppler_marketing_automation/actions/get-subscriber/get-subscriber.mjs +++ b/components/doppler_marketing_automation/actions/get-subscriber/get-subscriber.mjs @@ -2,7 +2,7 @@ import app from "../../doppler_marketing_automation.app.mjs"; export default { name: "Get Subscriber", - version: "0.0.1", + version: "0.0.2", key: "doppler_marketing_automation-get-subscriber", description: "Get a subscriber. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameSubscribersByEmailGet)", type: "action", diff --git a/components/doppler_marketing_automation/actions/remove-subscriber/remove-subscriber.mjs b/components/doppler_marketing_automation/actions/remove-subscriber/remove-subscriber.mjs index cabbdcb1b5b97..d5ba344af5f8e 100644 --- a/components/doppler_marketing_automation/actions/remove-subscriber/remove-subscriber.mjs +++ b/components/doppler_marketing_automation/actions/remove-subscriber/remove-subscriber.mjs @@ -1,10 +1,10 @@ import app from "../../doppler_marketing_automation.app.mjs"; export default { - name: "Remove Subscriber", - version: "0.0.1", key: "doppler_marketing_automation-remove-subscriber", - description: "Remove a subscriber. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersByEmailDelete)", + name: "Remove Subscriber", + description: "Removes a subscriber from a list completely. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersByEmailDelete)", + version: "0.0.2", type: "action", props: { app, @@ -18,8 +18,8 @@ export default { propDefinition: [ app, "subscriberEmail", - (c) => ({ - listId: c.listId, + ({ listId }) => ({ + listId, }), ], }, @@ -30,11 +30,7 @@ export default { email: this.email, listId: this.listId, }); - - if (response) { - $.export("$summary", `Successfully removed subscriber with email ${this.email}`); - } - + $.export("$summary", `Successfully removed subscriber: ${this.email} from list: ${this.listId}`); return response; }, }; diff --git a/components/doppler_marketing_automation/actions/unsubscribe-email/unsubscribe-email.mjs b/components/doppler_marketing_automation/actions/unsubscribe-email/unsubscribe-email.mjs new file mode 100644 index 0000000000000..0256fb3645841 --- /dev/null +++ b/components/doppler_marketing_automation/actions/unsubscribe-email/unsubscribe-email.mjs @@ -0,0 +1,31 @@ +import app from "../../doppler_marketing_automation.app.mjs"; + +export default { + key: "doppler_marketing_automation-unsubscribe-email", + name: "Unsubscribe Email", + description: "Unsubscribe an email address from the account. Once unsubscribed, the user will not receive any more communication. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameUnsubscribedPost)", + version: "0.0.1", + type: "action", + props: { + app, + email: { + propDefinition: [ + app, + "subscriberEmail", + () => ({ + filter: ({ status }) => status != "unsubscribed", + }), + ], + }, + }, + async run({ $ }) { + const response = await this.app.unsubscribeSubscriber({ + $, + data: { + email: this.email, + }, + }); + $.export("$summary", `Successfully unsubscribed email: ${this.email}`); + return response; + }, +}; diff --git a/components/doppler_marketing_automation/common/constants.mjs b/components/doppler_marketing_automation/common/constants.mjs new file mode 100644 index 0000000000000..2f2fdb8ef86e7 --- /dev/null +++ b/components/doppler_marketing_automation/common/constants.mjs @@ -0,0 +1,1009 @@ +export const GENDER_OPTIONS = [ + { + label: "Female", + value: "F", + }, + { + label: "Male", + value: "M", + }, +]; + +export const COUNTRY_OPTIONS = [ + { + label: "Argentina", + value: "AR", + }, + { + label: "United States", + value: "US", + }, + { + label: "Brazil", + value: "BR", + }, + { + label: "Mexico", + value: "MX", + }, + { + label: "Chile", + value: "CL", + }, + { + label: "Guatemala", + value: "GT", + }, + { + label: "Paraguay", + value: "PY", + }, + { + label: "France", + value: "FR", + }, + { + label: "Italy", + value: "IT", + }, + { + label: "Spain", + value: "ES", + }, + { + label: "China", + value: "CN", + }, + { + label: "Japan", + value: "JP", + }, + { + label: "Afghanistan", + value: "AF", + }, + { + label: "Åland Islands", + value: "AX", + }, + { + label: "Albania", + value: "AL", + }, + { + label: "Algeria", + value: "DZ", + }, + { + label: "American Samoa", + value: "AS", + }, + { + label: "Andorra", + value: "AD", + }, + { + label: "Angola", + value: "AO", + }, + { + label: "Anguilla", + value: "AI", + }, + { + label: "Antarctica", + value: "AQ", + }, + { + label: "Antigua and Barbuda", + value: "AG", + }, + { + label: "Armenia", + value: "AM", + }, + { + label: "Aruba", + value: "AW", + }, + { + label: "Australia", + value: "AU", + }, + { + label: "Austria", + value: "AT", + }, + { + label: "Azerbaijan", + value: "AZ", + }, + { + label: "Bahamas", + value: "BS", + }, + { + label: "Bahrain", + value: "BH", + }, + { + label: "Bangladesh", + value: "BD", + }, + { + label: "Barbados", + value: "BB", + }, + { + label: "Belarus", + value: "BY", + }, + { + label: "Belgium", + value: "BE", + }, + { + label: "Belize", + value: "BZ", + }, + { + label: "Benin", + value: "BJ", + }, + { + label: "Bermuda", + value: "BM", + }, + { + label: "Bhutan", + value: "BT", + }, + { + label: "Bolivia, Plurinational State of", + value: "BO", + }, + { + label: "Bonaire, Sint Eustatius and Saba", + value: "BQ", + }, + { + label: "Bosnia and Herzegovina", + value: "BA", + }, + { + label: "Botswana", + value: "BW", + }, + { + label: "Bouvet Island", + value: "BV", + }, + { + label: "British Indian Ocean Territory", + value: "IO", + }, + { + label: "Brunei Darussalam", + value: "BN", + }, + { + label: "Bulgaria", + value: "BG", + }, + { + label: "Burkina Faso", + value: "BF", + }, + { + label: "Burundi", + value: "BI", + }, + { + label: "Cambodia", + value: "KH", + }, + { + label: "Cameroon", + value: "CM", + }, + { + label: "Canada", + value: "CA", + }, + { + label: "Cape Verde", + value: "CV", + }, + { + label: "Cayman Islands", + value: "KY", + }, + { + label: "Central African Republic", + value: "CF", + }, + { + label: "Chad", + value: "TD", + }, + { + label: "Christmas Island", + value: "CX", + }, + { + label: "Cocos (Keeling) Islands", + value: "CC", + }, + { + label: "Colombia", + value: "CO", + }, + { + label: "Comoros", + value: "KM", + }, + { + label: "Congo", + value: "CG", + }, + { + label: "Congo, the Democratic Republic of the", + value: "CD", + }, + { + label: "Cook Islands", + value: "CK", + }, + { + label: "Costa Rica", + value: "CR", + }, + { + label: "Côte d'Ivoire", + value: "CI", + }, + { + label: "Croatia", + value: "HR", + }, + { + label: "Cuba", + value: "CU", + }, + { + label: "Curaçao", + value: "CW", + }, + { + label: "Cyprus", + value: "CY", + }, + { + label: "Czech Republic", + value: "CZ", + }, + { + label: "Denmark", + value: "DK", + }, + { + label: "Djibouti", + value: "DJ", + }, + { + label: "Dominica", + value: "DM", + }, + { + label: "Dominican Republic", + value: "DO", + }, + { + label: "Ecuador", + value: "EC", + }, + { + label: "Egypt", + value: "EG", + }, + { + label: "El Salvador", + value: "SV", + }, + { + label: "Equatorial Guinea", + value: "GQ", + }, + { + label: "Eritrea", + value: "ER", + }, + { + label: "Estonia", + value: "EE", + }, + { + label: "Ethiopia", + value: "ET", + }, + { + label: "Falkland Islands (Malvinas)", + value: "FK", + }, + { + label: "Faroe Islands", + value: "FO", + }, + { + label: "Fiji", + value: "FJ", + }, + { + label: "Finland", + value: "FI", + }, + { + label: "French Guiana", + value: "GF", + }, + { + label: "French Polynesia", + value: "PF", + }, + { + label: "French Southern Territories", + value: "TF", + }, + { + label: "Gabon", + value: "GA", + }, + { + label: "Gambia", + value: "GM", + }, + { + label: "Georgia", + value: "GE", + }, + { + label: "Germany", + value: "DE", + }, + { + label: "Ghana", + value: "GH", + }, + { + label: "Gibraltar", + value: "GI", + }, + { + label: "Greece", + value: "GR", + }, + { + label: "Greenland", + value: "GL", + }, + { + label: "Grenada", + value: "GD", + }, + { + label: "Guadeloupe", + value: "GP", + }, + { + label: "Guam", + value: "GU", + }, + { + label: "Guernsey", + value: "GG", + }, + { + label: "Guinea", + value: "GN", + }, + { + label: "Guinea-Bissau", + value: "GW", + }, + { + label: "Guyana", + value: "GY", + }, + { + label: "Haiti", + value: "HT", + }, + { + label: "Heard Island and McDonald Islands", + value: "HM", + }, + { + label: "Holy See (Vatican City State)", + value: "VA", + }, + { + label: "Honduras", + value: "HN", + }, + { + label: "Hong Kong", + value: "HK", + }, + { + label: "Hungary", + value: "HU", + }, + { + label: "Iceland", + value: "IS", + }, + { + label: "India", + value: "IN", + }, + { + label: "Indonesia", + value: "ID", + }, + { + label: "Iran, Islamic Republic of", + value: "IR", + }, + { + label: "Iraq", + value: "IQ", + }, + { + label: "Ireland", + value: "IE", + }, + { + label: "Isle of Man", + value: "IM", + }, + { + label: "Israel", + value: "IL", + }, + { + label: "Jamaica", + value: "JM", + }, + { + label: "Jersey", + value: "JE", + }, + { + label: "Jordan", + value: "JO", + }, + { + label: "Kazakhstan", + value: "KZ", + }, + { + label: "Kenya", + value: "KE", + }, + { + label: "Kiribati", + value: "KI", + }, + { + label: "Korea, Democratic People's Republic of", + value: "KP", + }, + { + label: "Korea, Republic of", + value: "KR", + }, + { + label: "Kuwait", + value: "KW", + }, + { + label: "Kyrgyzstan", + value: "KG", + }, + { + label: "Lao People's Democratic Republic", + value: "LA", + }, + { + label: "Latvia", + value: "LV", + }, + { + label: "Lebanon", + value: "LB", + }, + { + label: "Lesotho", + value: "LS", + }, + { + label: "Liberia", + value: "LR", + }, + { + label: "Libya", + value: "LY", + }, + { + label: "Liechtenstein", + value: "LI", + }, + { + label: "Lithuania", + value: "LT", + }, + { + label: "Luxembourg", + value: "LU", + }, + { + label: "Macao", + value: "MO", + }, + { + label: "Macedonia, the Former Yugoslav Republic of", + value: "MK", + }, + { + label: "Madagascar", + value: "MG", + }, + { + label: "Malawi", + value: "MW", + }, + { + label: "Malaysia", + value: "MY", + }, + { + label: "Maldives", + value: "MV", + }, + { + label: "Mali", + value: "ML", + }, + { + label: "Malta", + value: "MT", + }, + { + label: "Marshall Islands", + value: "MH", + }, + { + label: "Martinique", + value: "MQ", + }, + { + label: "Mauritania", + value: "MR", + }, + { + label: "Mauritius", + value: "MU", + }, + { + label: "Mayotte", + value: "YT", + }, + { + label: "Micronesia, Federated States of", + value: "FM", + }, + { + label: "Moldova, Republic of", + value: "MD", + }, + { + label: "Monaco", + value: "MC", + }, + { + label: "Mongolia", + value: "MN", + }, + { + label: "Montenegro", + value: "ME", + }, + { + label: "Montserrat", + value: "MS", + }, + { + label: "Morocco", + value: "MA", + }, + { + label: "Mozambique", + value: "MZ", + }, + { + label: "Myanmar", + value: "MM", + }, + { + label: "Namibia", + value: "NA", + }, + { + label: "Nauru", + value: "NR", + }, + { + label: "Nepal", + value: "NP", + }, + { + label: "Netherlands", + value: "NL", + }, + { + label: "New Caledonia", + value: "NC", + }, + { + label: "New Zealand", + value: "NZ", + }, + { + label: "Nicaragua", + value: "NI", + }, + { + label: "Niger", + value: "NE", + }, + { + label: "Nigeria", + value: "NG", + }, + { + label: "Niue", + value: "NU", + }, + { + label: "Norfolk Island", + value: "NF", + }, + { + label: "Northern Mariana Islands", + value: "MP", + }, + { + label: "Norway", + value: "NO", + }, + { + label: "Oman", + value: "OM", + }, + { + label: "Pakistan", + value: "PK", + }, + { + label: "Palau", + value: "PW", + }, + { + label: "Palestine, State of", + value: "PS", + }, + { + label: "Panama", + value: "PA", + }, + { + label: "Papua New Guinea", + value: "PG", + }, + { + label: "Peru", + value: "PE", + }, + { + label: "Philippines", + value: "PH", + }, + { + label: "Pitcairn", + value: "PN", + }, + { + label: "Poland", + value: "PL", + }, + { + label: "Portugal", + value: "PT", + }, + { + label: "Puerto Rico", + value: "PR", + }, + { + label: "Qatar", + value: "QA", + }, + { + label: "Réunion", + value: "RE", + }, + { + label: "Romania", + value: "RO", + }, + { + label: "Russian Federation", + value: "RU", + }, + { + label: "Rwanda", + value: "RW", + }, + { + label: "Saint Barthélemy", + value: "BL", + }, + { + label: "Saint Helena, Ascension and Tristan da Cunha", + value: "SH", + }, + { + label: "Saint Kitts and Nevis", + value: "KN", + }, + { + label: "Saint Lucia", + value: "LC", + }, + { + label: "Saint Martin (French part)", + value: "MF", + }, + { + label: "Saint Pierre and Miquelon", + value: "PM", + }, + { + label: "Saint Vincent and the Grenadines", + value: "VC", + }, + { + label: "Samoa", + value: "WS", + }, + { + label: "San Marino", + value: "SM", + }, + { + label: "Sao Tome and Principe", + value: "ST", + }, + { + label: "Saudi Arabia", + value: "SA", + }, + { + label: "Senegal", + value: "SN", + }, + { + label: "Serbia", + value: "RS", + }, + { + label: "Seychelles", + value: "SC", + }, + { + label: "Sierra Leone", + value: "SL", + }, + { + label: "Singapore", + value: "SG", + }, + { + label: "Sint Maarten (Dutch part)", + value: "SX", + }, + { + label: "Slovakia", + value: "SK", + }, + { + label: "Slovenia", + value: "SI", + }, + { + label: "Solomon Islands", + value: "SB", + }, + { + label: "Somalia", + value: "SO", + }, + { + label: "South Africa", + value: "ZA", + }, + { + label: "South Georgia and the South Sandwich Islands", + value: "GS", + }, + { + label: "South Sudan", + value: "SS", + }, + { + label: "Sri Lanka", + value: "LK", + }, + { + label: "Sudan", + value: "SD", + }, + { + label: "Suriname", + value: "SR", + }, + { + label: "Svalbard and Jan Mayen", + value: "SJ", + }, + { + label: "Swaziland", + value: "SZ", + }, + { + label: "Sweden", + value: "SE", + }, + { + label: "Switzerland", + value: "CH", + }, + { + label: "Syrian Arab Republic", + value: "SY", + }, + { + label: "Taiwan, Province of China", + value: "TW", + }, + { + label: "Tajikistan", + value: "TJ", + }, + { + label: "Tanzania, United Republic of", + value: "TZ", + }, + { + label: "Thailand", + value: "TH", + }, + { + label: "Timor-Leste", + value: "TL", + }, + { + label: "Togo", + value: "TG", + }, + { + label: "Tokelau", + value: "TK", + }, + { + label: "Tonga", + value: "TO", + }, + { + label: "Trinidad and Tobago", + value: "TT", + }, + { + label: "Tunisia", + value: "TN", + }, + { + label: "Turkey", + value: "TR", + }, + { + label: "Turkmenistan", + value: "TM", + }, + { + label: "Turks and Caicos Islands", + value: "TC", + }, + { + label: "Tuvalu", + value: "TV", + }, + { + label: "Uganda", + value: "UG", + }, + { + label: "Ukraine", + value: "UA", + }, + { + label: "United Arab Emirates", + value: "AE", + }, + { + label: "United Kingdom", + value: "GB", + }, + { + label: "United States Minor Outlying Islands", + value: "UM", + }, + { + label: "Uruguay", + value: "UY", + }, + { + label: "Uzbekistan", + value: "UZ", + }, + { + label: "Vanuatu", + value: "VU", + }, + { + label: "Venezuela, Bolivarian Republic of", + value: "VE", + }, + { + label: "Viet Nam", + value: "VN", + }, + { + label: "Virgin Islands, British", + value: "VG", + }, + { + label: "Virgin Islands, U.S.", + value: "VI", + }, + { + label: "Wallis and Futuna", + value: "WF", + }, + { + label: "Western Sahara", + value: "EH", + }, + { + label: "Yemen", + value: "YE", + }, + { + label: "Zambia", + value: "ZM", + }, + { + label: "Zimbabwe", + value: "ZW", + }, +]; diff --git a/components/doppler_marketing_automation/doppler_marketing_automation.app.mjs b/components/doppler_marketing_automation/doppler_marketing_automation.app.mjs index 7868d8f697fc8..44c21284b3715 100644 --- a/components/doppler_marketing_automation/doppler_marketing_automation.app.mjs +++ b/components/doppler_marketing_automation/doppler_marketing_automation.app.mjs @@ -8,12 +8,17 @@ export default { label: "List ID", description: "The list ID", type: "string", - async options() { - const { items: resources } = await this.getLists(); - - return resources.map((resource) => ({ - value: resource.listId, - label: resource.name, + async options({ page }) { + const { items } = await this.listLists({ + params: { + page: page + 1, + }, + }); + return items.map(({ + listId: value, name: label, + }) => ({ + label, + value, })); }, }, @@ -21,56 +26,66 @@ export default { label: "Subscriber Email", description: "The subscriber email", type: "string", - async options({ listId }) { - const { items: resources } = await this.getSubscribers({ + async options({ + page, listId, filter = () => true, + }) { + const { items } = await this.listSubscribers({ listId, + params: { + page: page + 1, + }, }); - - return resources.map((resource) => resource.email); + return items.filter(filter).map(({ email }) => email); }, }, + fields: { + label: "Fields", + description: "Optional fields for a subscriber in JSON format", + type: "string[]", + optional: true, + }, + origin: { + label: "Origin Header", + description: "Value for the X-Doppler-Subscriber-Origin header", + type: "string", + optional: true, + }, }, methods: { - _apiKey() { - return this.$auth.api_key; + _baseUrl() { + return `https://restapi.fromdoppler.com/accounts/${this.$auth.account_name}`; }, - _accountName() { - return this.$auth.account_name; + _headers() { + return { + "Authorization": `token ${this.$auth.api_key}`, + }; }, - _apiUrl() { - return `https://restapi.fromdoppler.com/accounts/${this._accountName()}`; - }, - async _makeRequest({ - $ = this, path, ...args + _makeRequest({ + $ = this, path, ...opts }) { return axios($, { - url: `${this._apiUrl()}${path}`, - ...args, - headers: { - ...args.headers, - "Authorization": `token ${this._apiKey()}`, - }, + url: this._baseUrl() + path, + headers: this._headers(), + ...opts, }); }, - async getLists(args = {}) { + listLists(args = {}) { return this._makeRequest({ path: "/lists", ...args, }); }, - async getSubscribers({ - listId, ...args + listSubscribers({ + listId = null, ...opts }) { - const extraPath = listId - ? `/lists/${listId}` - : ""; - return this._makeRequest({ - path: `${extraPath}/subscribers`, - ...args, + path: `${listId + ? `/lists/${listId}` + : ""}/subscribers`, + ...opts, }); }, - async getSubscriber({ + getSubscriber({ email, ...args }) { return this._makeRequest({ @@ -78,19 +93,28 @@ export default { ...args, }); }, - async addSubscriber(args = {}) { + addOrUpdateSubscriber({ + listId, ...opts + }) { return this._makeRequest({ - path: "/subscribers", - method: "post", - ...args, + method: "POST", + path: `/lists/${listId}/subscribers`, + ...opts, + }); + }, + unsubscribeSubscriber(opts = {}) { + return this._makeRequest({ + path: "/unsubscribed", + method: "POST", + ...opts, }); }, - async removeSubscriber({ + removeSubscriber({ email, listId, ...args }) { return this._makeRequest({ path: `/lists/${listId}/subscribers/${email}`, - method: "delete", + method: "DELETE", ...args, }); }, diff --git a/components/doppler_marketing_automation/package.json b/components/doppler_marketing_automation/package.json index b3034b7124ce7..7fcb95dfc537a 100644 --- a/components/doppler_marketing_automation/package.json +++ b/components/doppler_marketing_automation/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/doppler_marketing_automation", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Doppler Marketing Automation Components", "main": "doppler_marketing_automation.app.mjs", "keywords": [ @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.5.1" + "@pipedream/platform": "^3.0.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5178a24692786..8354fd9454a77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2749,9 +2749,9 @@ importers: components/doppler_marketing_automation: specifiers: - '@pipedream/platform': ^1.5.1 + '@pipedream/platform': ^3.0.3 dependencies: - '@pipedream/platform': 1.5.1 + '@pipedream/platform': 3.0.3 components/doppler_ops: specifiers: {} @@ -12935,6 +12935,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: + resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sts' + - aws-crt + dev: false + /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13170,7 +13219,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13212,55 +13261,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: - resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sso-oidc' - - aws-crt - dev: false - /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -17587,7 +17587,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq + '@aws-sdk/client-sts': 3.600.0 '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6