diff --git a/components/membado/actions/add-remove-tags/add-remove-tags.mjs b/components/membado/actions/add-remove-tags/add-remove-tags.mjs new file mode 100644 index 0000000000000..43a285873d13d --- /dev/null +++ b/components/membado/actions/add-remove-tags/add-remove-tags.mjs @@ -0,0 +1,48 @@ +import membado from "../../membado.app.mjs"; + +export default { + name: "Add or Remove Tags from User", + version: "0.0.1", + key: "membado-add-remove-tags", + description: + "Assign tags to or remove them from a user. [See the documentation](https://membado.zendesk.com/hc/de/articles/18155937106204-API-Documentation)", + type: "action", + props: { + membado, + mail: { + type: "string", + label: "Email address", + description: + "The email address of the user to whom the tags should be assigned or removed", + }, + tagsAdd: { + type: "string[]", + label: "Tags to add", + description: "A list of tag IDs to assign to the user.", + optional: true, + }, + tagsRemove: { + type: "string[]", + label: "Tags to remove", + description: "A list of tag IDs to remove from the user.", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.membado.addMember({ + $, + data: { + mail: this.mail, + tags_add: this.tagsAdd?.join?.() ?? this.tagsAdd, + tags_remove: this.tagsRemove?.join?.() ?? this.tagsRemove, + }, + }); + + $.export( + "$summary", + `Successfully changed tags for ${this.mail}`, + ); + + return response; + }, +}; diff --git a/components/membado/membado.app.mjs b/components/membado/membado.app.mjs index 76fe2e29b095e..fa8b01bd0d760 100644 --- a/components/membado/membado.app.mjs +++ b/components/membado/membado.app.mjs @@ -1,11 +1,32 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "membado", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseRequest({ + $, data, headers, ...args + }) { + return axios($, { + baseURL: `https://www.membado.io/api/${this.$auth.user_identifier}`, + data: { + ...data, + apikey: this.$auth.api_key, + }, + headers: { + ...headers, + "content-type": "application/x-www-form-urlencoded", + }, + ...args, + }); + }, + addMember(args) { + return this._baseRequest({ + method: "POST", + url: "/add-member", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/membado/package.json b/components/membado/package.json index 8693603cd8153..e860e2eb32783 100644 --- a/components/membado/package.json +++ b/components/membado/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/membado", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Membado Components", "main": "membado.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e34e33e8f9b6..7d9c424b574db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7919,7 +7919,11 @@ importers: components/mem: {} - components/membado: {} + components/membado: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/memberful: dependencies: @@ -12886,8 +12890,7 @@ importers: components/systeme_io: {} - components/szybkisms: - specifiers: {} + components/szybkisms: {} components/t2m_url_shortener: {}