@ixiam/n8n-nodes-civicrm 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,43 +39,17 @@ export class CiviCrmApi {
39
39
  },
40
40
  };
41
41
 
42
- async test(
43
- this: ICredentialTestFunctions,
44
- credentials: ICredentialsDecrypted<ICredentialDataDecryptedObject>,
45
- ) {
46
- const data = credentials.data as { baseUrl: string; apiToken: string };
47
-
48
- const baseUrl = data.baseUrl.replace(/\/$/, '');
49
- const token = data.apiToken;
50
-
51
- try {
52
- const response = await this.helpers.request({
53
- method: 'POST',
54
- url: `${baseUrl}/civicrm/ajax/api4/Contact/get`,
55
- json: true,
56
- body: { limit: 1 },
57
- headers: {
58
- 'X-Civi-Auth': `Bearer ${token}`,
59
- 'Content-Type': 'application/json',
60
- },
61
- });
62
-
63
- if (response?.values !== undefined) {
64
- return {
65
- status: 'OK',
66
- message: 'Connection successful.',
67
- };
68
- }
69
-
70
- return {
71
- status: 'Error',
72
- message: 'Unexpected API response.',
73
- };
74
- } catch (error: any) {
75
- return {
76
- status: 'Error',
77
- message: error.message,
78
- };
79
- }
80
- }
42
+ test = {
43
+ httpRequest: {
44
+ method: 'POST',
45
+ url: '={{ $credentials.baseUrl.replace(/\\/$/, "") }}/civicrm/ajax/api4/Contact/get',
46
+ headers: {
47
+ 'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
48
+ 'Content-Type': 'application/json',
49
+ },
50
+ body: {
51
+ limit: 1,
52
+ },
53
+ },
54
+ };
81
55
  }
@@ -1,4 +1,4 @@
1
- import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, ICredentialsDecrypted, INodeProperties } from 'n8n-workflow';
1
+ import type { INodeProperties } from 'n8n-workflow';
2
2
  export declare class CiviCrmApi {
3
3
  name: string;
4
4
  displayName: string;
@@ -12,8 +12,17 @@ export declare class CiviCrmApi {
12
12
  };
13
13
  };
14
14
  };
15
- test(this: ICredentialTestFunctions, credentials: ICredentialsDecrypted<ICredentialDataDecryptedObject>): Promise<{
16
- status: string;
17
- message: any;
18
- }>;
15
+ test: {
16
+ httpRequest: {
17
+ method: string;
18
+ url: string;
19
+ headers: {
20
+ 'X-Civi-Auth': string;
21
+ 'Content-Type': string;
22
+ };
23
+ body: {
24
+ limit: number;
25
+ };
26
+ };
27
+ };
19
28
  }
@@ -32,39 +32,19 @@ class CiviCrmApi {
32
32
  },
33
33
  },
34
34
  };
35
- }
36
- async test(credentials) {
37
- const data = credentials.data;
38
- const baseUrl = data.baseUrl.replace(/\/$/, '');
39
- const token = data.apiToken;
40
- try {
41
- const response = await this.helpers.request({
35
+ this.test = {
36
+ httpRequest: {
42
37
  method: 'POST',
43
- url: `${baseUrl}/civicrm/ajax/api4/Contact/get`,
44
- json: true,
45
- body: { limit: 1 },
38
+ url: '={{ $credentials.baseUrl.replace(/\\/$/, "") }}/civicrm/ajax/api4/Contact/get',
46
39
  headers: {
47
- 'X-Civi-Auth': `Bearer ${token}`,
40
+ 'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
48
41
  'Content-Type': 'application/json',
49
42
  },
50
- });
51
- if (response?.values !== undefined) {
52
- return {
53
- status: 'OK',
54
- message: 'Connection successful.',
55
- };
56
- }
57
- return {
58
- status: 'Error',
59
- message: 'Unexpected API response.',
60
- };
61
- }
62
- catch (error) {
63
- return {
64
- status: 'Error',
65
- message: error.message,
66
- };
67
- }
43
+ body: {
44
+ limit: 1,
45
+ },
46
+ },
47
+ };
68
48
  }
69
49
  }
70
50
  exports.CiviCrmApi = CiviCrmApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ixiam/n8n-nodes-civicrm",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Full-featured CiviCRM API v4 integration for n8n with support for Contacts, Memberships, Groups, Relationships, Activities and structured sub-entities like Email, Phone, and Address.",
5
5
  "license": "MIT",
6
6
  "keywords": [