-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Added actions * Update components/unthread/actions/create-customer/create-customer.mjs Co-authored-by: Guilherme Falcão <[email protected]> * Update components/unthread/actions/update-customer/update-customer.mjs Co-authored-by: Guilherme Falcão <[email protected]> * ESLint --------- Co-authored-by: Guilherme Falcão <[email protected]> Co-authored-by: GTFalcao <[email protected]>
- Loading branch information
1 parent
a472ad8
commit 0748914
Showing
6 changed files
with
264 additions
and
7 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
components/unthread/actions/create-customer/create-customer.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import app from "../../unthread.app.mjs"; | ||
|
||
export default { | ||
key: "unthread-create-customer", | ||
name: "Create Customer", | ||
description: "Create a new Customer. [See the documentation](https://docs.unthread.io/api-introduction/using-api#create-customer)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
slackChannelId: { | ||
propDefinition: [ | ||
app, | ||
"slackChannelId", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
emailDomains: { | ||
propDefinition: [ | ||
app, | ||
"emailDomains", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, ...data | ||
} = this; | ||
const response = await app.createCustomer({ | ||
$, | ||
data, | ||
}); | ||
|
||
$.export("$summary", `Successfully created Customer with ID '${response.id}'`); | ||
|
||
return response; | ||
}, | ||
}; |
28 changes: 28 additions & 0 deletions
28
components/unthread/actions/delete-customer/delete-customer.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import app from "../../unthread.app.mjs"; | ||
|
||
export default { | ||
key: "unthread-delete-customer", | ||
name: "Delete Customer", | ||
description: "Delete a Customer. [See the documentation](https://docs.unthread.io/api-introduction/using-api#delete-customer)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
customerId: { | ||
propDefinition: [ | ||
app, | ||
"customerId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.deleteCustomer({ | ||
$, | ||
customerId: this.customerId, | ||
}); | ||
|
||
$.export("$summary", `Successfully deleted Customer with ID '${this.customerId}'`); | ||
|
||
return response; | ||
}, | ||
}; |
71 changes: 71 additions & 0 deletions
71
components/unthread/actions/update-customer/update-customer.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import app from "../../unthread.app.mjs"; | ||
|
||
export default { | ||
key: "unthread-update-customer", | ||
name: "Update Customer", | ||
description: "Update a Customer. [See the documentation](https://docs.unthread.io/api-introduction/using-api#update-customer)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
customerId: { | ||
propDefinition: [ | ||
app, | ||
"customerId", | ||
], | ||
}, | ||
slackChannelId: { | ||
propDefinition: [ | ||
app, | ||
"slackChannelId", | ||
], | ||
optional: true, | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
optional: true, | ||
}, | ||
emailDomains: { | ||
propDefinition: [ | ||
app, | ||
"emailDomains", | ||
], | ||
optional: true, | ||
}, | ||
disableAutomatedTicketing: { | ||
propDefinition: [ | ||
app, | ||
"disableAutomatedTicketing", | ||
], | ||
}, | ||
slackTeamId: { | ||
propDefinition: [ | ||
app, | ||
"slackTeamId", | ||
], | ||
}, | ||
defaultTriageChannelId: { | ||
propDefinition: [ | ||
app, | ||
"defaultTriageChannelId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, customerId, ...data | ||
} = this; | ||
const response = await app.updateCustomer({ | ||
$, | ||
customerId, | ||
data, | ||
}); | ||
|
||
$.export("$summary", `Successfully updated Customer with ID '${response.id}'`); | ||
|
||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/unthread", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Unthread Components", | ||
"main": "unthread.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^1.6.6" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,109 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "unthread", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
customerId: { | ||
type: "string", | ||
label: "Customer ID", | ||
description: "ID of the Customer", | ||
async options() { | ||
const response = await this.listCustomers(); | ||
const customersIds = response.data; | ||
return customersIds.map(({ | ||
id, name, | ||
}) => ({ | ||
value: id, | ||
label: name, | ||
})); | ||
}, | ||
}, | ||
slackChannelId: { | ||
type: "string", | ||
label: "Slack Channel ID", | ||
description: "ID the customer's Slack Channel", | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "Name of the customer", | ||
}, | ||
emailDomains: { | ||
type: "string[]", | ||
label: "Email Domains", | ||
description: "Email Domains of the customer, i.e.: `gmail.com`", | ||
}, | ||
defaultTriageChannelId: { | ||
type: "string", | ||
label: "Default Triage Channel", | ||
description: "ID of the default triage Channel of this customer", | ||
optional: true, | ||
}, | ||
disableAutomatedTicketing: { | ||
type: "boolean", | ||
label: "Automated Ticketing", | ||
description: "Disable Automated Ticketing for this customer", | ||
optional: true, | ||
}, | ||
slackTeamId: { | ||
type: "string", | ||
label: "Slack Team ID", | ||
description: "ID of the Slack Team", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return "https://api.unthread.io/api"; | ||
}, | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, | ||
path, | ||
headers, | ||
...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
url: this._baseUrl() + path, | ||
headers: { | ||
...headers, | ||
"X-Api-Key": `${this.$auth.api_key}`, | ||
}, | ||
}); | ||
}, | ||
async createCustomer(args = {}) { | ||
return this._makeRequest({ | ||
method: "post", | ||
path: "/customers", | ||
...args, | ||
}); | ||
}, | ||
async updateCustomer({ | ||
customerId, ...args | ||
}) { | ||
return this._makeRequest({ | ||
method: "patch", | ||
path: `/customers/${customerId}`, | ||
...args, | ||
}); | ||
}, | ||
async deleteCustomer({ | ||
customerId, ...args | ||
}) { | ||
return this._makeRequest({ | ||
method: "delete", | ||
path: `/customers/${customerId}`, | ||
...args, | ||
}); | ||
}, | ||
async listCustomers(args = {}) { | ||
return this._makeRequest({ | ||
method: "post", | ||
path: "/customers/list", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.