mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Small improvements on Drift-Node
This commit is contained in:
parent
657732ac68
commit
5a608cbf5b
|
@ -65,7 +65,7 @@ export const contactFields = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The email of the Contact',
|
description: 'The email of the contact.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Additional Fields',
|
displayName: 'Additional Fields',
|
||||||
|
@ -89,14 +89,14 @@ export const contactFields = [
|
||||||
name: 'name',
|
name: 'name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The name of the Contact',
|
description: 'The name of the contact.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Phone',
|
displayName: 'Phone',
|
||||||
name: 'phone',
|
name: 'phone',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The phone number associated with the Contact',
|
description: 'The phone number associated with the contact.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -143,21 +143,21 @@ export const contactFields = [
|
||||||
name: 'email',
|
name: 'email',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The email of the Contact',
|
description: 'The email of the contact.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Name',
|
displayName: 'Name',
|
||||||
name: 'name',
|
name: 'name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The name of the Contact',
|
description: 'The name of the contact.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Phone',
|
displayName: 'Phone',
|
||||||
name: 'phone',
|
name: 'phone',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The phone number associated with the Contact',
|
description: 'The phone number associated with the contact.',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -82,7 +82,7 @@ export class Drift implements INodeType {
|
||||||
body.phone = additionalFields.phone as string;
|
body.phone = additionalFields.phone as string;
|
||||||
}
|
}
|
||||||
responseData = await driftApiRequest.call(this, 'POST', '/contacts', { attributes: body });
|
responseData = await driftApiRequest.call(this, 'POST', '/contacts', { attributes: body });
|
||||||
responseData = responseData.data
|
responseData = responseData.data;
|
||||||
}
|
}
|
||||||
//https://devdocs.drift.com/docs/updating-a-contact
|
//https://devdocs.drift.com/docs/updating-a-contact
|
||||||
if (operation === 'update') {
|
if (operation === 'update') {
|
||||||
|
@ -99,13 +99,13 @@ export class Drift implements INodeType {
|
||||||
body.email = updateFields.email as string;
|
body.email = updateFields.email as string;
|
||||||
}
|
}
|
||||||
responseData = await driftApiRequest.call(this, 'PATCH', `/contacts/${contactId}`, { attributes: body });
|
responseData = await driftApiRequest.call(this, 'PATCH', `/contacts/${contactId}`, { attributes: body });
|
||||||
responseData = responseData.data
|
responseData = responseData.data;
|
||||||
}
|
}
|
||||||
//https://devdocs.drift.com/docs/retrieving-contact
|
//https://devdocs.drift.com/docs/retrieving-contact
|
||||||
if (operation === 'get') {
|
if (operation === 'get') {
|
||||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||||
responseData = await driftApiRequest.call(this, 'GET', `/contacts/${contactId}`);
|
responseData = await driftApiRequest.call(this, 'GET', `/contacts/${contactId}`);
|
||||||
responseData = responseData.data
|
responseData = responseData.data;
|
||||||
}
|
}
|
||||||
//https://devdocs.drift.com/docs/listing-custom-attributes
|
//https://devdocs.drift.com/docs/listing-custom-attributes
|
||||||
if (operation === 'getCustomAttributes') {
|
if (operation === 'getCustomAttributes') {
|
||||||
|
|
|
@ -42,7 +42,7 @@ export async function driftApiRequest(this: IExecuteFunctions | IWebhookFunction
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
const errorMessage = error.message || (error.response.body && error.response.body.message )
|
const errorMessage = error.message || (error.response.body && error.response.body.message );
|
||||||
throw new Error(`Drift error response [${error.statusCode}]: ${errorMessage}`);
|
throw new Error(`Drift error response [${error.statusCode}]: ${errorMessage}`);
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 882 B |
|
@ -41,8 +41,8 @@
|
||||||
"dist/credentials/CodaApi.credentials.js",
|
"dist/credentials/CodaApi.credentials.js",
|
||||||
"dist/credentials/CopperApi.credentials.js",
|
"dist/credentials/CopperApi.credentials.js",
|
||||||
"dist/credentials/DisqusApi.credentials.js",
|
"dist/credentials/DisqusApi.credentials.js",
|
||||||
"dist/credentials/DropboxApi.credentials.js",
|
|
||||||
"dist/credentials/DriftApi.credentials.js",
|
"dist/credentials/DriftApi.credentials.js",
|
||||||
|
"dist/credentials/DropboxApi.credentials.js",
|
||||||
"dist/credentials/EventbriteApi.credentials.js",
|
"dist/credentials/EventbriteApi.credentials.js",
|
||||||
"dist/credentials/FreshdeskApi.credentials.js",
|
"dist/credentials/FreshdeskApi.credentials.js",
|
||||||
"dist/credentials/FileMaker.credentials.js",
|
"dist/credentials/FileMaker.credentials.js",
|
||||||
|
@ -126,11 +126,11 @@
|
||||||
"dist/nodes/Copper/CopperTrigger.node.js",
|
"dist/nodes/Copper/CopperTrigger.node.js",
|
||||||
"dist/nodes/Cron.node.js",
|
"dist/nodes/Cron.node.js",
|
||||||
"dist/nodes/Crypto.node.js",
|
"dist/nodes/Crypto.node.js",
|
||||||
|
"dist/nodes/DateTime.node.js",
|
||||||
"dist/nodes/Discord/Discord.node.js",
|
"dist/nodes/Discord/Discord.node.js",
|
||||||
"dist/nodes/Disqus/Disqus.node.js",
|
"dist/nodes/Disqus/Disqus.node.js",
|
||||||
"dist/nodes/Dropbox/Dropbox.node.js",
|
|
||||||
"dist/nodes/DateTime.node.js",
|
|
||||||
"dist/nodes/Drift/Drift.node.js",
|
"dist/nodes/Drift/Drift.node.js",
|
||||||
|
"dist/nodes/Dropbox/Dropbox.node.js",
|
||||||
"dist/nodes/EditImage.node.js",
|
"dist/nodes/EditImage.node.js",
|
||||||
"dist/nodes/EmailReadImap.node.js",
|
"dist/nodes/EmailReadImap.node.js",
|
||||||
"dist/nodes/EmailSend.node.js",
|
"dist/nodes/EmailSend.node.js",
|
||||||
|
|
Loading…
Reference in a new issue