diff --git a/components/mumble/actions/add-new-customer/add-new-customer.mjs b/components/mumble/actions/add-new-customer/add-new-customer.mjs new file mode 100644 index 0000000000000..4a832bf8e2511 --- /dev/null +++ b/components/mumble/actions/add-new-customer/add-new-customer.mjs @@ -0,0 +1,84 @@ +import app from "../../mumble.app.mjs"; + +export default { + key: "mumble-add-new-customer", + name: "Add New Customer", + description: "Adds a new customer. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)", + version: "0.0.1", + type: "action", + props: { + app, + customerPhone: { + propDefinition: [ + app, + "customerPhone", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + source: { + propDefinition: [ + app, + "source", + ], + }, + utmSource: { + propDefinition: [ + app, + "utmSource", + ], + }, + utmMedium: { + propDefinition: [ + app, + "utmMedium", + ], + }, + utmCampaign: { + propDefinition: [ + app, + "utmCampaign", + ], + }, + gclid: { + propDefinition: [ + app, + "gclid", + ], + }, + currentUrl: { + propDefinition: [ + app, + "currentUrl", + ], + }, + }, + async run({ $ }) { + const response = await this.app.addNewCustomer({ + $, + data: { + customer_phone: this.customerPhone, + name: this.name, + email: this.email, + source: this.source, + utm_source: this.utmSource, + utm_medium: this.utmMedium, + utm_campaign: this.utmCampaign, + gclid: this.gclid, + current_url: this.currentUrl, + }, + }); + $.export("$summary", "Successfully sent the request to add a new customer: " + response.message); + return response; + }, +}; diff --git a/components/mumble/actions/add-new-label/add-new-label.mjs b/components/mumble/actions/add-new-label/add-new-label.mjs new file mode 100644 index 0000000000000..0cd52123188a8 --- /dev/null +++ b/components/mumble/actions/add-new-label/add-new-label.mjs @@ -0,0 +1,28 @@ +import app from "../../mumble.app.mjs"; + +export default { + key: "mumble-add-new-label", + name: "Add New Label", + description: "Adds a new label. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)", + version: "0.0.1", + type: "action", + props: { + app, + labelName: { + propDefinition: [ + app, + "labelName", + ], + }, + }, + async run({ $ }) { + const response = await this.app.addNewLabel({ + $, + data: { + label_name: this.labelName, + }, + }); + $.export("$summary", "Successfully sent the request to add a new label: " + response.message); + return response; + }, +}; diff --git a/components/mumble/actions/delete-label/delete-label.mjs b/components/mumble/actions/delete-label/delete-label.mjs new file mode 100644 index 0000000000000..834cd4295c18f --- /dev/null +++ b/components/mumble/actions/delete-label/delete-label.mjs @@ -0,0 +1,28 @@ +import app from "../../mumble.app.mjs"; + +export default { + key: "mumble-delete-label", + name: "Delete Label", + description: "Deletes a label. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)", + version: "0.0.1", + type: "action", + props: { + app, + labelNameList: { + propDefinition: [ + app, + "labelNameList", + ], + }, + }, + async run({ $ }) { + const response = await this.app.deleteLabel({ + $, + data: { + label_name: this.labelNameList, + }, + }); + $.export("$summary", "Successfully sent the request to delete a label: " + response.message); + return response; + }, +}; diff --git a/components/mumble/actions/edit-customer/edit-customer.mjs b/components/mumble/actions/edit-customer/edit-customer.mjs new file mode 100644 index 0000000000000..5329e6b2432e8 --- /dev/null +++ b/components/mumble/actions/edit-customer/edit-customer.mjs @@ -0,0 +1,84 @@ +import app from "../../mumble.app.mjs"; + +export default { + key: "mumble-edit-customer", + name: "Edit Customer", + description: "Edits the customer with the specified phone number. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)", + version: "0.0.1", + type: "action", + props: { + app, + customerPhone: { + propDefinition: [ + app, + "customerPhone", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + source: { + propDefinition: [ + app, + "source", + ], + }, + utmSource: { + propDefinition: [ + app, + "utmSource", + ], + }, + utmMedium: { + propDefinition: [ + app, + "utmMedium", + ], + }, + utmCampaign: { + propDefinition: [ + app, + "utmCampaign", + ], + }, + gclid: { + propDefinition: [ + app, + "gclid", + ], + }, + currentUrl: { + propDefinition: [ + app, + "currentUrl", + ], + }, + }, + async run({ $ }) { + const response = await this.app.editCustomer({ + $, + data: { + customer_phone: this.customerPhone, + name: this.name, + email: this.email, + source: this.source, + utm_source: this.utmSource, + utm_medium: this.utmMedium, + utm_campaign: this.utmCampaign, + gclid: this.gclid, + current_url: this.currentUrl, + }, + }); + $.export("$summary", "Successfully sent the request to edit a customer: " + response.message); + return response; + }, +}; diff --git a/components/mumble/mumble.app.mjs b/components/mumble/mumble.app.mjs index 544d2c1b11131..204bb1565be83 100644 --- a/components/mumble/mumble.app.mjs +++ b/components/mumble/mumble.app.mjs @@ -1,11 +1,134 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "mumble", - propDefinitions: {}, + propDefinitions: { + labelName: { + type: "string", + label: "Label Name", + description: "Name of the label", + }, + customerPhone: { + type: "string", + label: "Customer Phone", + description: "Phone number of the customer", + }, + name: { + type: "string", + label: "Name", + description: "Name of the customer", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Email address", + optional: true, + }, + source: { + type: "string", + label: "Source", + description: "Source identifier", + optional: true, + }, + utmSource: { + type: "string", + label: "UTM Source", + description: "UTM source value", + optional: true, + }, + utmMedium: { + type: "string", + label: "UTM Medium", + description: "UTM medium value", + optional: true, + }, + utmCampaign: { + type: "string", + label: "UTM Campaign", + description: "UTM campaign value", + optional: true, + }, + gclid: { + type: "string", + label: "GCLID", + description: "Google Ads click ID", + optional: true, + }, + currentUrl: { + type: "string", + label: "Current URL", + description: "Current URL", + optional: true, + }, + labelNameList: { + type: "string", + label: "Label Name", + description: "Name of the label", + async options() { + const response = await this.getLabels(); + const labelsArray = response.labels; + return labelsArray.map((label) => ({ + value: label, + label: label, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://app.mumble.co.il/mumbleapi"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "mumble-api-key": `${this.$auth.api_key}`, + ...headers, + }, + }); + }, + async addNewLabel(args = {}) { + return this._makeRequest({ + path: "/add-new-label", + method: "post", + ...args, + }); + }, + async deleteLabel(args = {}) { + return this._makeRequest({ + path: "/delete-label", + method: "delete", + ...args, + }); + }, + async addNewCustomer(args = {}) { + return this._makeRequest({ + path: "/add-new-customer", + method: "post", + ...args, + }); + }, + async editCustomer(args = {}) { + return this._makeRequest({ + path: "/edit-customer", + method: "post", + ...args, + }); + }, + async getLabels(args = {}) { + return this._makeRequest({ + path: "/get-labels", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/mumble/package.json b/components/mumble/package.json index 3e1dc25554e20..028f1c0ab7b31 100644 --- a/components/mumble/package.json +++ b/components/mumble/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/mumble", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Mumble Components", "main": "mumble.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 630b6b82f6a0d..f40c6323545f5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8670,7 +8670,11 @@ importers: components/mumara: {} - components/mumble: {} + components/mumble: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/mural: dependencies: