diff --git a/components/pidj/actions/create-contact/create-contact.mjs b/components/pidj/actions/create-contact/create-contact.mjs new file mode 100644 index 0000000000000..7977572e4dab8 --- /dev/null +++ b/components/pidj/actions/create-contact/create-contact.mjs @@ -0,0 +1,172 @@ +import { TIMEZONE_OPTIONS } from "../../common/constants.mjs"; +import pidj from "../../pidj.app.mjs"; + +export default { + key: "pidj-create-contact", + name: "Create Contact", + description: "Initiates a process to add a new contact to your Pidj account. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).", + version: "0.0.1", + type: "action", + props: { + pidj, + phoneNumber: { + type: "string", + label: "Phone Number", + description: "Phone number for the contact. This must be in E.164 format. **e.g., +18885552222**", + }, + emailAddress: { + type: "string", + label: "Email Address", + description: "The contact's email address.", + optional: true, + }, + firstName: { + type: "string", + label: "First Name", + description: "The contact's first name.", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "The contact's last name.", + optional: true, + }, + businessName: { + type: "string", + label: "Business Name", + description: "The contact's business name.", + optional: true, + }, + displayName: { + type: "string", + label: "Display Name", + description: "The contact's display name, if present, and different from first and last name.", + optional: true, + }, + groupId: { + propDefinition: [ + pidj, + "groupId", + ], + optional: true, + }, + timezone: { + type: "string", + label: "Timezone", + description: "Timezone identifier for the contact. If omitted, this will default to the account value.", + options: TIMEZONE_OPTIONS, + optional: true, + }, + externalId: { + type: "string", + label: "External Id", + description: "The external ID of the contact from your own system. This may be used in any enabled integrations to cross-identify the contact record.", + optional: true, + }, + homeAddressStreet1: { + type: "string", + label: "Home Street 1", + description: "The home street address 1.", + optional: true, + }, + homeAddressStreet2: { + type: "string", + label: "Home Street 2", + description: "The home street address 2.", + optional: true, + }, + homeAddressCity: { + type: "string", + label: "Home City", + description: "The home city address.", + optional: true, + }, + homeAddressState: { + type: "string", + label: "Home State", + description: "The home state address. Must be the standard 2 character abbreviation (**ANSI2-letter** or **USPS**). Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations).", + optional: true, + }, + homeAddressPostal: { + type: "string", + label: "Home Postal", + description: "Valid 5 or 10 digit zipcode (US addresses). British, Canadian, and Australian postal codes also supported.", + optional: true, + }, + homeAddressCountry: { + type: "string", + label: "Home Country", + description: "Must be either **ISO 3166-1 alpha-2** or **ISO 3166-1 alpha-3**. Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/ISO_3166-1).", + optional: true, + }, + businessAddressStreet1: { + type: "string", + label: "Business Street 1", + description: "The business street address 1.", + optional: true, + }, + businessAddressStreet2: { + type: "string", + label: "Business Street 2", + description: "The business street address 2.", + optional: true, + }, + businessAddressCity: { + type: "string", + label: "Business City", + description: "The business city address.", + optional: true, + }, + businessAddressState: { + type: "string", + label: "Business State", + description: "The business state address. Must be the standard 2 character abbreviation (**ANSI2-letter** or **USPS**). Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations).", + optional: true, + }, + businessAddressPostal: { + type: "string", + label: "Business Postal", + description: "Valid 5 or 10 digit zipcode (US addresses). British, Canadian, and Australian postal codes also supported.", + optional: true, + }, + businessAddressCountry: { + type: "string", + label: "Business Country", + description: "Must be either **ISO 3166-1 alpha-2** or **ISO 3166-1 alpha-3**. Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/ISO_3166-1).", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.pidj.addContact({ + $, + data: { + phone_number: this.phoneNumber, + email_address: this.emailAddress, + first_name: this.firstName, + last_name: this.lastName, + business_name: this.businessName, + display_name: this.displayName, + group: this.groupId, + timezone: this.timezone, + external_id: this.externalId, + addresses: { + home_street_1: this.homeAddressStreet1, + home_street_2: this.homeAddressStreet2, + home_city: this.homeAddressCity, + home_state: this.homeAddressState, + home_postal: this.homeAddressPostal, + home_country: this.homeAddressCountry, + business_street_1: this.businessAddressStreet1, + business_street_2: this.businessAddressStreet2, + business_city: this.businessAddressCity, + business_state: this.businessAddressState, + business_postal: this.businessAddressPostal, + business_country: this.businessAddressCountry, + }, + }, + }); + $.export("$summary", `Successfully added a new contact with Id: ${response.id}`); + return response; + }, +}; diff --git a/components/pidj/actions/initiate-survey/initiate-survey.mjs b/components/pidj/actions/initiate-survey/initiate-survey.mjs new file mode 100644 index 0000000000000..d05a665b2f4ee --- /dev/null +++ b/components/pidj/actions/initiate-survey/initiate-survey.mjs @@ -0,0 +1,57 @@ +import { ConfigurationError } from "@pipedream/platform"; +import pidj from "../../pidj.app.mjs"; + +export default { + key: "pidj-initiate-survey", + name: "Initiate Survey", + description: "Triggers a pre-configured text survey to a specific contact. Requires the contact's information and the survey ID. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).", + version: "0.0.1", + type: "action", + props: { + pidj, + surveyId: { + propDefinition: [ + pidj, + "surveyId", + ], + }, + contactId: { + propDefinition: [ + pidj, + "contactId", + ], + }, + fromNumber: { + propDefinition: [ + pidj, + "fromNumber", + ], + optional: true, + }, + groupId: { + propDefinition: [ + pidj, + "groupId", + ], + optional: true, + }, + }, + async run({ $ }) { + if ((!this.fromNumber && !this.groupId) || (this.fromNumber && this.groupId)) { + throw new ConfigurationError("You must provide either From Number or Group Id."); + } + + const response = await this.pidj.triggerSurvey({ + $, + data: { + survey_id: this.surveyId, + contact_id: this.contactId, + from_number: this.fromNumber, + group_id: this.groupId, + }, + }); + + $.export("$summary", `Successfully initiated survey for contact ${this.contactId}`); + return response; + }, +}; diff --git a/components/pidj/actions/send-message/send-message.mjs b/components/pidj/actions/send-message/send-message.mjs new file mode 100644 index 0000000000000..a3b6a6ce8606d --- /dev/null +++ b/components/pidj/actions/send-message/send-message.mjs @@ -0,0 +1,44 @@ +import { ConfigurationError } from "@pipedream/platform"; +import pidj from "../../pidj.app.mjs"; + +export default { + key: "pidj-send-message", + name: "Send Message", + description: "Sends a text message to a specified phone number from your pidj account. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).", + version: "0.0.1", + type: "action", + props: { + pidj, + groupId: { + propDefinition: [ + pidj, + "groupId", + ], + }, + toNumber: { + propDefinition: [ + pidj, + "toNumber", + ], + }, + textBody: { + type: "string", + label: "Text Body", + description: "The text to send. Message lengths greater than 1,600 characters will be truncated. Messages with emoji and special characters may have a smaller limit due to encoding requirements. [See Pidj FAQ for details](https://pidjco.gopidj.com/faq).", + }, + }, + async run({ $ }) { + const response = await this.pidj.sendMessage({ + $, + data: { + group_id: this.groupId, + to_number: this.toNumber, + text_body: this.textBody, + }, + }); + if (response.status != "success") throw new ConfigurationError(response.message); + + $.export("$summary", `Message successfully sent to ${this.toNumber}`); + return response; + }, +}; diff --git a/components/pidj/common/constants.mjs b/components/pidj/common/constants.mjs new file mode 100644 index 0000000000000..7e1205e5046a7 --- /dev/null +++ b/components/pidj/common/constants.mjs @@ -0,0 +1,599 @@ +export const TIMEZONE_OPTIONS = [ + "Africa/Abidjan", + "Africa/Accra", + "Africa/Addis_Ababa", + "Africa/Algiers", + "Africa/Asmara", + "Africa/Asmera", + "Africa/Bamako", + "Africa/Bangui", + "Africa/Banjul", + "Africa/Bissau", + "Africa/Blantyre", + "Africa/Brazzaville", + "Africa/Bujumbura", + "Africa/Cairo", + "Africa/Casablanca", + "Africa/Ceuta", + "Africa/Conakry", + "Africa/Dakar", + "Africa/Dar_es_Salaam", + "Africa/Djibouti", + "Africa/Douala", + "Africa/El_Aaiun", + "Africa/Freetown", + "Africa/Gaborone", + "Africa/Harare", + "Africa/Johannesburg", + "Africa/Juba", + "Africa/Kampala", + "Africa/Khartoum", + "Africa/Kigali", + "Africa/Kinshasa", + "Africa/Lagos", + "Africa/Libreville", + "Africa/Lome", + "Africa/Luanda", + "Africa/Lubumbashi", + "Africa/Lusaka", + "Africa/Malabo", + "Africa/Maputo", + "Africa/Maseru", + "Africa/Mbabane", + "Africa/Mogadishu", + "Africa/Monrovia", + "Africa/Nairobi", + "Africa/Ndjamena", + "Africa/Niamey", + "Africa/Nouakchott", + "Africa/Ouagadougou", + "Africa/Porto-Novo", + "Africa/Sao_Tome", + "Africa/Timbuktu", + "Africa/Tripoli", + "Africa/Tunis", + "Africa/Windhoek", + "America/Adak", + "America/Anchorage", + "America/Anguilla", + "America/Antigua", + "America/Araguaina", + "America/Argentina/Buenos_Aires", + "America/Argentina/Catamarca", + "America/Argentina/ComodRivadavia", + "America/Argentina/Cordoba", + "America/Argentina/Jujuy", + "America/Argentina/La_Rioja", + "America/Argentina/Mendoza", + "America/Argentina/Rio_Gallegos", + "America/Argentina/Salta", + "America/Argentina/San_Juan", + "America/Argentina/San_Luis", + "America/Argentina/Tucuman", + "America/Argentina/Ushuaia", + "America/Aruba", + "America/Asuncion", + "America/Atikokan", + "America/Atka", + "America/Bahia", + "America/Bahia_Banderas", + "America/Barbados", + "America/Belem", + "America/Belize", + "America/Blanc-Sablon", + "America/Boa_Vista", + "America/Bogota", + "America/Boise", + "America/Buenos_Aires", + "America/Cambridge_Bay", + "America/Campo_Grande", + "America/Cancun", + "America/Caracas", + "America/Catamarca", + "America/Cayenne", + "America/Cayman", + "America/Chicago", + "America/Chihuahua", + "America/Ciudad_Juarez", + "America/Coral_Harbour", + "America/Cordoba", + "America/Costa_Rica", + "America/Creston", + "America/Cuiaba", + "America/Curacao", + "America/Danmarkshavn", + "America/Dawson", + "America/Dawson_Creek", + "America/Denver", + "America/Detroit", + "America/Dominica", + "America/Edmonton", + "America/Eirunepe", + "America/El_Salvador", + "America/Ensenada", + "America/Fort_Nelson", + "America/Fort_Wayne", + "America/Fortaleza", + "America/Glace_Bay", + "America/Godthab", + "America/Goose_Bay", + "America/Grand_Turk", + "America/Grenada", + "America/Guadeloupe", + "America/Guatemala", + "America/Guayaquil", + "America/Guyana", + "America/Halifax", + "America/Havana", + "America/Hermosillo", + "America/Indiana/Indianapolis", + "America/Indiana/Knox", + "America/Indiana/Marengo", + "America/Indiana/Petersburg", + "America/Indiana/Tell_City", + "America/Indiana/Vevay", + "America/Indiana/Vincennes", + "America/Indiana/Winamac", + "America/Indianapolis", + "America/Inuvik", + "America/Iqaluit", + "America/Jamaica", + "America/Jujuy", + "America/Juneau", + "America/Kentucky/Louisville", + "America/Kentucky/Monticello", + "America/Knox_IN", + "America/Kralendijk", + "America/La_Paz", + "America/Lima", + "America/Los_Angeles", + "America/Louisville", + "America/Lower_Princes", + "America/Maceio", + "America/Managua", + "America/Manaus", + "America/Marigot", + "America/Martinique", + "America/Matamoros", + "America/Mazatlan", + "America/Mendoza", + "America/Menominee", + "America/Merida", + "America/Metlakatla", + "America/Mexico_City", + "America/Miquelon", + "America/Moncton", + "America/Monterrey", + "America/Montevideo", + "America/Montreal", + "America/Montserrat", + "America/Nassau", + "America/New_York", + "America/Nipigon", + "America/Nome", + "America/Noronha", + "America/North_Dakota/Beulah", + "America/North_Dakota/Center", + "America/North_Dakota/New_Salem", + "America/Nuuk", + "America/Ojinaga", + "America/Panama", + "America/Pangnirtung", + "America/Paramaribo", + "America/Phoenix", + "America/Port-au-Prince", + "America/Port_of_Spain", + "America/Porto_Acre", + "America/Porto_Velho", + "America/Puerto_Rico", + "America/Punta_Arenas", + "America/Rainy_River", + "America/Rankin_Inlet", + "America/Recife", + "America/Regina", + "America/Resolute", + "America/Rio_Branco", + "America/Rosario", + "America/Santa_Isabel", + "America/Santarem", + "America/Santiago", + "America/Santo_Domingo", + "America/Sao_Paulo", + "America/Scoresbysund", + "America/Shiprock", + "America/Sitka", + "America/St_Barthelemy", + "America/St_Johns", + "America/St_Kitts", + "America/St_Lucia", + "America/St_Thomas", + "America/St_Vincent", + "America/Swift_Current", + "America/Tegucigalpa", + "America/Thule", + "America/Thunder_Bay", + "America/Tijuana", + "America/Toronto", + "America/Tortola", + "America/Vancouver", + "America/Virgin", + "America/Whitehorse", + "America/Winnipeg", + "America/Yakutat", + "America/Yellowknife", + "Antarctica/Casey", + "Antarctica/Davis", + "Antarctica/DumontDUrville", + "Antarctica/Macquarie", + "Antarctica/Mawson", + "Antarctica/McMurdo", + "Antarctica/Palmer", + "Antarctica/Rothera", + "Antarctica/South_Pole", + "Antarctica/Syowa", + "Antarctica/Troll", + "Antarctica/Vostok", + "Arctic/Longyearbyen", + "Asia/Aden", + "Asia/Almaty", + "Asia/Amman", + "Asia/Anadyr", + "Asia/Aqtau", + "Asia/Aqtobe", + "Asia/Ashgabat", + "Asia/Ashkhabad", + "Asia/Atyrau", + "Asia/Baghdad", + "Asia/Bahrain", + "Asia/Baku", + "Asia/Bangkok", + "Asia/Barnaul", + "Asia/Beirut", + "Asia/Bishkek", + "Asia/Brunei", + "Asia/Calcutta", + "Asia/Chita", + "Asia/Choibalsan", + "Asia/Chongqing", + "Asia/Chungking", + "Asia/Colombo", + "Asia/Dacca", + "Asia/Damascus", + "Asia/Dhaka", + "Asia/Dili", + "Asia/Dubai", + "Asia/Dushanbe", + "Asia/Famagusta", + "Asia/Gaza", + "Asia/Harbin", + "Asia/Hebron", + "Asia/Ho_Chi_Minh", + "Asia/Hong_Kong", + "Asia/Hovd", + "Asia/Irkutsk", + "Asia/Istanbul", + "Asia/Jakarta", + "Asia/Jayapura", + "Asia/Jerusalem", + "Asia/Kabul", + "Asia/Kamchatka", + "Asia/Karachi", + "Asia/Kashgar", + "Asia/Kathmandu", + "Asia/Katmandu", + "Asia/Khandyga", + "Asia/Kolkata", + "Asia/Krasnoyarsk", + "Asia/Kuala_Lumpur", + "Asia/Kuching", + "Asia/Kuwait", + "Asia/Macao", + "Asia/Macau", + "Asia/Magadan", + "Asia/Makassar", + "Asia/Manila", + "Asia/Muscat", + "Asia/Nicosia", + "Asia/Novokuznetsk", + "Asia/Novosibirsk", + "Asia/Omsk", + "Asia/Oral", + "Asia/Phnom_Penh", + "Asia/Pontianak", + "Asia/Pyongyang", + "Asia/Qatar", + "Asia/Qostanay", + "Asia/Qyzylorda", + "Asia/Rangoon", + "Asia/Riyadh", + "Asia/Saigon", + "Asia/Sakhalin", + "Asia/Samarkand", + "Asia/Seoul", + "Asia/Shanghai", + "Asia/Singapore", + "Asia/Srednekolymsk", + "Asia/Taipei", + "Asia/Tashkent", + "Asia/Tbilisi", + "Asia/Tehran", + "Asia/Tel_Aviv", + "Asia/Thimbu", + "Asia/Thimphu", + "Asia/Tokyo", + "Asia/Tomsk", + "Asia/Ujung_Pandang", + "Asia/Ulaanbaatar", + "Asia/Ulan_Bator", + "Asia/Urumqi", + "Asia/Ust-Nera", + "Asia/Vientiane", + "Asia/Vladivostok", + "Asia/Yakutsk", + "Asia/Yangon", + "Asia/Yekaterinburg", + "Asia/Yerevan", + "Atlantic/Azores", + "Atlantic/Bermuda", + "Atlantic/Canary", + "Atlantic/Cape_Verde", + "Atlantic/Faeroe", + "Atlantic/Faroe", + "Atlantic/Jan_Mayen", + "Atlantic/Madeira", + "Atlantic/Reykjavik", + "Atlantic/South_Georgia", + "Atlantic/St_Helena", + "Atlantic/Stanley", + "Australia/ACT", + "Australia/Adelaide", + "Australia/Brisbane", + "Australia/Broken_Hill", + "Australia/Canberra", + "Australia/Currie", + "Australia/Darwin", + "Australia/Eucla", + "Australia/Hobart", + "Australia/LHI", + "Australia/Lindeman", + "Australia/Lord_Howe", + "Australia/Melbourne", + "Australia/North", + "Australia/NSW", + "Australia/Perth", + "Australia/Queensland", + "Australia/South", + "Australia/Sydney", + "Australia/Tasmania", + "Australia/Victoria", + "Australia/West", + "Australia/Yancowinna", + "Brazil/Acre", + "Brazil/DeNoronha", + "Brazil/East", + "Brazil/West", + "Canada/Atlantic", + "Canada/Central", + "Canada/Eastern", + "Canada/Mountain", + "Canada/Newfoundland", + "Canada/Pacific", + "Canada/Saskatchewan", + "Canada/Yukon", + "CET", + "Chile/Continental", + "Chile/EasterIsland", + "CST6CDT", + "Cuba", + "EET", + "Egypt", + "Eire", + "EST", + "EST5EDT", + "Etc/GMT", + "Etc/GMT+0", + "Etc/GMT+1", + "Etc/GMT+10", + "Etc/GMT+11", + "Etc/GMT+12", + "Etc/GMT+2", + "Etc/GMT+3", + "Etc/GMT+4", + "Etc/GMT+5", + "Etc/GMT+6", + "Etc/GMT+7", + "Etc/GMT+8", + "Etc/GMT+9", + "Etc/GMT-0", + "Etc/GMT-1", + "Etc/GMT-10", + "Etc/GMT-11", + "Etc/GMT-12", + "Etc/GMT-13", + "Etc/GMT-14", + "Etc/GMT-2", + "Etc/GMT-3", + "Etc/GMT-4", + "Etc/GMT-5", + "Etc/GMT-6", + "Etc/GMT-7", + "Etc/GMT-8", + "Etc/GMT-9", + "Etc/GMT0", + "Etc/Greenwich", + "Etc/UCT", + "Etc/Universal", + "Etc/UTC", + "Etc/Zulu", + "Europe/Amsterdam", + "Europe/Andorra", + "Europe/Astrakhan", + "Europe/Athens", + "Europe/Belfast", + "Europe/Belgrade", + "Europe/Berlin", + "Europe/Bratislava", + "Europe/Brussels", + "Europe/Bucharest", + "Europe/Budapest", + "Europe/Busingen", + "Europe/Chisinau", + "Europe/Copenhagen", + "Europe/Dublin", + "Europe/Gibraltar", + "Europe/Guernsey", + "Europe/Helsinki", + "Europe/Isle_of_Man", + "Europe/Istanbul", + "Europe/Jersey", + "Europe/Kaliningrad", + "Europe/Kiev", + "Europe/Kirov", + "Europe/Kyiv", + "Europe/Lisbon", + "Europe/Ljubljana", + "Europe/London", + "Europe/Luxembourg", + "Europe/Madrid", + "Europe/Malta", + "Europe/Mariehamn", + "Europe/Minsk", + "Europe/Monaco", + "Europe/Moscow", + "Europe/Nicosia", + "Europe/Oslo", + "Europe/Paris", + "Europe/Podgorica", + "Europe/Prague", + "Europe/Riga", + "Europe/Rome", + "Europe/Samara", + "Europe/San_Marino", + "Europe/Sarajevo", + "Europe/Saratov", + "Europe/Simferopol", + "Europe/Skopje", + "Europe/Sofia", + "Europe/Stockholm", + "Europe/Tallinn", + "Europe/Tirane", + "Europe/Tiraspol", + "Europe/Ulyanovsk", + "Europe/Uzhgorod", + "Europe/Vaduz", + "Europe/Vatican", + "Europe/Vienna", + "Europe/Vilnius", + "Europe/Volgograd", + "Europe/Warsaw", + "Europe/Zagreb", + "Europe/Zaporozhye", + "Europe/Zurich", + "Factory", + "GB", + "GB-Eire", + "GMT", + "GMT+0", + "GMT-0", + "GMT0", + "Greenwich", + "Hongkong", + "HST", + "Iceland", + "Indian/Antananarivo", + "Indian/Chagos", + "Indian/Christmas", + "Indian/Cocos", + "Indian/Comoro", + "Indian/Kerguelen", + "Indian/Mahe", + "Indian/Maldives", + "Indian/Mauritius", + "Indian/Mayotte", + "Indian/Reunion", + "Iran", + "Israel", + "Jamaica", + "Japan", + "Kwajalein", + "Libya", + "MET", + "Mexico/BajaNorte", + "Mexico/BajaSur", + "Mexico/General", + "MST", + "MST7MDT", + "Navajo", + "NZ", + "NZ-CHAT", + "Pacific/Apia", + "Pacific/Auckland", + "Pacific/Bougainville", + "Pacific/Chatham", + "Pacific/Chuuk", + "Pacific/Easter", + "Pacific/Efate", + "Pacific/Enderbury", + "Pacific/Fakaofo", + "Pacific/Fiji", + "Pacific/Funafuti", + "Pacific/Galapagos", + "Pacific/Gambier", + "Pacific/Guadalcanal", + "Pacific/Guam", + "Pacific/Honolulu", + "Pacific/Johnston", + "Pacific/Kanton", + "Pacific/Kiritimati", + "Pacific/Kosrae", + "Pacific/Kwajalein", + "Pacific/Majuro", + "Pacific/Marquesas", + "Pacific/Midway", + "Pacific/Nauru", + "Pacific/Niue", + "Pacific/Norfolk", + "Pacific/Noumea", + "Pacific/Pago_Pago", + "Pacific/Palau", + "Pacific/Pitcairn", + "Pacific/Pohnpei", + "Pacific/Ponape", + "Pacific/Port_Moresby", + "Pacific/Rarotonga", + "Pacific/Saipan", + "Pacific/Samoa", + "Pacific/Tahiti", + "Pacific/Tarawa", + "Pacific/Tongatapu", + "Pacific/Truk", + "Pacific/Wake", + "Pacific/Wallis", + "Pacific/Yap", + "Poland", + "Portugal", + "PRC", + "PST8PDT", + "ROC", + "ROK", + "Singapore", + "Turkey", + "UCT", + "Universal", + "US/Alaska", + "US/Aleutian", + "US/Arizona", + "US/Central", + "US/East-Indiana", + "US/Eastern", + "US/Hawaii", + "US/Indiana-Starke", + "US/Michigan", + "US/Mountain", + "US/Pacific", + "US/Samoa", + "UTC", + "W-SU", + "WET", + "Zulu", +]; diff --git a/components/pidj/package.json b/components/pidj/package.json index a89e4b3ad710b..a088d58551a78 100644 --- a/components/pidj/package.json +++ b/components/pidj/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/pidj", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Pidj Components", "main": "pidj.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.0" } -} \ No newline at end of file +} diff --git a/components/pidj/pidj.app.mjs b/components/pidj/pidj.app.mjs index b95910d9367e6..30bfed651a7eb 100644 --- a/components/pidj/pidj.app.mjs +++ b/components/pidj/pidj.app.mjs @@ -1,11 +1,125 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "pidj", - propDefinitions: {}, + propDefinitions: { + contactId: { + type: "string", + label: "Contact ID", + description: "The ID of the contact.", + async options() { + const { contacts } = await this.listContacts(); + + return contacts.map(({ + id: value, first_name, last_name, display_name, phone_number, + }) => ({ + label: (first_name && last_name) + ? `${first_name} ${last_name}` + : `${display_name || phone_number}`, + value, + })); + }, + }, + groupId: { + type: "string", + label: "Group Id", + description: "The Id of the group.", + async options() { + const { groups } = await this.listGroups(); + + return groups.map(({ + group_id: value, name: label, + }) => ({ + label, + value, + })); + }, + optional: true, + }, + surveyId: { + type: "string", + label: "Survey ID", + description: "The ID of the survey to be triggered.", + async options() { + const { surveys } = await this.listSurveys(); + + return surveys.map(({ + survey_id: value, name: label, + }) => ({ + label, + value, + })); + }, + }, + fromNumber: { + type: "string", + label: "From Number", + description: "Phone number to send from; this will determine which group the message sends from, and must be an active number from one of your groups. This must be in E.164 format, e.g., +18885552222", + }, + toNumber: { + type: "string", + label: "To Number", + description: "Phone number to send to. This must be in E.164 format, e.g., +18885553333.", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.gopidj.com/api/2020"; + }, + _auth() { + return { + username: `${this.$auth.account_key}`, + password: `${this.$auth.token}`, + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + auth: this._auth(), + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + ...opts, + }); + }, + addContact(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/contact", + ...opts, + }); + }, + listGroups() { + return this._makeRequest({ + path: "/groups", + }); + }, + listSurveys() { + return this._makeRequest({ + path: "/surveys", + }); + }, + listContacts() { + return this._makeRequest({ + path: "/contacts", + }); + }, + triggerSurvey(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/survey/initiate", + ...opts, + }); + }, + sendMessage(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/send", + ...opts, + }); }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c1ae45bbbdea..47a84ab41285a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6578,7 +6578,10 @@ importers: '@pipedream/platform': 1.5.1 components/pidj: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.0 + dependencies: + '@pipedream/platform': 3.0.0 components/piggy: specifiers: