@friggframework/api-module-zoho-crm 2.0.0-next.0 → 2.0.0-next.2
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.
- package/README.md +183 -197
- package/dist/api.d.ts +101 -0
- package/dist/api.js +521 -0
- package/dist/defaultConfig.json +13 -0
- package/dist/definition.d.ts +22 -0
- package/dist/definition.js +75 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +32 -0
- package/dist/types.d.ts +356 -0
- package/dist/types.js +2 -0
- package/package.json +21 -10
- package/.env.example +0 -4
- package/CHANGELOG.md +0 -50
- package/api.js +0 -169
- package/defaultConfig.json +0 -13
- package/definition.js +0 -51
- package/images/image-1.jpg +0 -0
- package/images/image-10.jpg +0 -0
- package/images/image-11.jpg +0 -0
- package/images/image-12.jpg +0 -0
- package/images/image-2.jpg +0 -0
- package/images/image-3.jpg +0 -0
- package/images/image-5.jpg +0 -0
- package/images/image-6.jpg +0 -0
- package/images/image-7.jpg +0 -0
- package/images/image-9.jpg +0 -0
- package/images/image.jpg +0 -0
- package/index.js +0 -9
- package/jest-setup.js +0 -3
- package/jest-teardown.js +0 -2
- package/jest.config.js +0 -22
- package/tests/api.test.js +0 -195
package/images/image-11.jpg
DELETED
|
Binary file
|
package/images/image-12.jpg
DELETED
|
Binary file
|
package/images/image-2.jpg
DELETED
|
Binary file
|
package/images/image-3.jpg
DELETED
|
Binary file
|
package/images/image-5.jpg
DELETED
|
Binary file
|
package/images/image-6.jpg
DELETED
|
Binary file
|
package/images/image-7.jpg
DELETED
|
Binary file
|
package/images/image-9.jpg
DELETED
|
Binary file
|
package/images/image.jpg
DELETED
|
Binary file
|
package/index.js
DELETED
package/jest-setup.js
DELETED
package/jest-teardown.js
DELETED
package/jest.config.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* For a detailed explanation regarding each configuration property, visit:
|
|
3
|
-
* https://jestjs.io/docs/configuration
|
|
4
|
-
*/
|
|
5
|
-
module.exports = {
|
|
6
|
-
// preset: '@friggframework/test-environment',
|
|
7
|
-
coverageThreshold: {
|
|
8
|
-
global: {
|
|
9
|
-
statements: 13,
|
|
10
|
-
branches: 0,
|
|
11
|
-
functions: 1,
|
|
12
|
-
lines: 13,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
// A path to a module which exports an async function that is triggered once before all test suites
|
|
16
|
-
globalSetup: './jest-setup.js',
|
|
17
|
-
|
|
18
|
-
// A path to a module which exports an async function that is triggered once after all test suites
|
|
19
|
-
globalTeardown: './jest-teardown.js',
|
|
20
|
-
|
|
21
|
-
testTimeout: 30000,
|
|
22
|
-
};
|
package/tests/api.test.js
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
const {Authenticator} = require('@friggframework/test');
|
|
2
|
-
const {Api} = require('../api');
|
|
3
|
-
const config = require('../defaultConfig.json');
|
|
4
|
-
const { FetchError } = require('@friggframework/core');
|
|
5
|
-
|
|
6
|
-
const api = new Api({
|
|
7
|
-
client_id: process.env.ZOHO_CRM_CLIENT_ID,
|
|
8
|
-
client_secret: process.env.ZOHO_CRM_CLIENT_SECRET,
|
|
9
|
-
scope: process.env.ZOHO_CRM_SCOPE,
|
|
10
|
-
redirect_uri: `${process.env.REDIRECT_URI}/zoho-crm`,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
beforeAll(async () => {
|
|
14
|
-
const url = api.getAuthUri();
|
|
15
|
-
const response = await Authenticator.oauth2(url);
|
|
16
|
-
const baseArr = response.base.split('/');
|
|
17
|
-
response.entityType = baseArr[baseArr.length - 1];
|
|
18
|
-
delete response.base;
|
|
19
|
-
await api.getTokenFromCode(response.data.code);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe(`${config.label} API tests`, () => {
|
|
23
|
-
let existingRoleId;
|
|
24
|
-
describe('Test Role resource', () => {
|
|
25
|
-
it('should list all Roles', async () => {
|
|
26
|
-
const response = await api.listRoles();
|
|
27
|
-
expect(response).toHaveProperty('roles');
|
|
28
|
-
expect(response.roles).toBeInstanceOf(Array);
|
|
29
|
-
existingRoleId = response.roles[0].id; // needed later, to delete a Role
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
let newRoleId;
|
|
33
|
-
it('should create a new Role', async () => {
|
|
34
|
-
const response = await api.createRole({
|
|
35
|
-
roles: [
|
|
36
|
-
{'name': 'Test Role 1000', 'description': 'Just testing stuff'}
|
|
37
|
-
]
|
|
38
|
-
});
|
|
39
|
-
expect(response).toHaveProperty('roles');
|
|
40
|
-
expect(response.roles[0].code).toBe('SUCCESS');
|
|
41
|
-
expect(response.roles[0].message).toBe('Role added');
|
|
42
|
-
newRoleId = response.roles[0].details.id; // store the id of the newly created Role
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should get the newly created Role by ID', async () => {
|
|
46
|
-
const response = await api.getRole(newRoleId);
|
|
47
|
-
expect(response).toHaveProperty('roles');
|
|
48
|
-
expect(response.roles[0].id).toBe(newRoleId);
|
|
49
|
-
expect(response.roles[0].name).toBe('Test Role 1000');
|
|
50
|
-
expect(response.roles[0].description).toBe('Just testing stuff');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
let updatedName = 'Foo';
|
|
54
|
-
let updatedDescription = 'Bar';
|
|
55
|
-
it('should update the newly created Role by ID', async () => {
|
|
56
|
-
const response = await api.updateRole(
|
|
57
|
-
newRoleId,
|
|
58
|
-
{roles: [{'name': updatedName, 'description': updatedDescription}]},
|
|
59
|
-
);
|
|
60
|
-
expect(response).toHaveProperty('roles');
|
|
61
|
-
expect(response.roles[0].code).toBe('SUCCESS');
|
|
62
|
-
expect(response.roles[0].message).toBe('Role updated');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should receive the updated values when getting the newly created User by ID', async () => {
|
|
66
|
-
const response = await api.getRole(newRoleId);
|
|
67
|
-
expect(response).toHaveProperty('roles');
|
|
68
|
-
expect(response.roles[0].id).toBe(newRoleId);
|
|
69
|
-
expect(response.roles[0].name).toBe(updatedName);
|
|
70
|
-
expect(response.roles[0].description).toBe(updatedDescription);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should delete the newly created Role by ID', async () => {
|
|
74
|
-
// To delete a Role, the api requires that we send it the ID of
|
|
75
|
-
// another Role, to which all users will be transfered after the delete.
|
|
76
|
-
// We rely on one of the existing Roles, whose ID we saved earlier.
|
|
77
|
-
const response = await api.deleteRole(
|
|
78
|
-
newRoleId,
|
|
79
|
-
{'transfer_to_id': existingRoleId}
|
|
80
|
-
);
|
|
81
|
-
expect(response).toHaveProperty('roles');
|
|
82
|
-
expect(response.roles[0].code).toBe('SUCCESS');
|
|
83
|
-
expect(response.roles[0].message).toBe('Role Deleted');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should throw FetchError when trying to create with empty params', () => {
|
|
87
|
-
expect(async () => await api.createRole()).rejects.toThrow(FetchError)
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('Test User resource', () => {
|
|
92
|
-
it('should list all Users', async () => {
|
|
93
|
-
const response = await api.listUsers();
|
|
94
|
-
expect(response).toHaveProperty('users');
|
|
95
|
-
expect(response.users).toBeInstanceOf(Array);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
let newUserId;
|
|
99
|
-
it('should create a new User', async () => {
|
|
100
|
-
// To create a new User in Zoho CRM, we need to specify their
|
|
101
|
-
// Role and Profile by providing the relevant IDs in the request.
|
|
102
|
-
// So we first need to fetch an existing Role and Profile.
|
|
103
|
-
const rolesResponse = await api.listRoles();
|
|
104
|
-
const role = rolesResponse.roles[0];
|
|
105
|
-
const profilesResponse = await api.listProfiles();
|
|
106
|
-
const profile = profilesResponse.profiles[0];
|
|
107
|
-
|
|
108
|
-
const response = await api.createUser({
|
|
109
|
-
users: [{
|
|
110
|
-
first_name: 'Test User 1000',
|
|
111
|
-
email: 'test@friggframework.org',
|
|
112
|
-
role: role.id,
|
|
113
|
-
profile: profile.id,
|
|
114
|
-
}]
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
expect(response).toHaveProperty('users');
|
|
118
|
-
expect(response.users[0].code).toBe('SUCCESS');
|
|
119
|
-
expect(response.users[0].message).toBe('User added');
|
|
120
|
-
newUserId = response.users[0].details.id; // store the id of the newly created User
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should get the newly created User by ID', async () => {
|
|
124
|
-
const response = await api.getUser(newUserId);
|
|
125
|
-
expect(response).toHaveProperty('users');
|
|
126
|
-
expect(response.users[0].id).toBe(newUserId);
|
|
127
|
-
expect(response.users[0].first_name).toBe('Test User 1000');
|
|
128
|
-
expect(response.users[0].email).toBe('test@friggframework.org');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
let updatedFirstName = 'Elon';
|
|
132
|
-
let updatedEmail = 'musk@friggframework.com';
|
|
133
|
-
it('should update the newly created User by ID', async () => {
|
|
134
|
-
const response = await api.updateUser(
|
|
135
|
-
newUserId,
|
|
136
|
-
{users: [{'first_name': updatedFirstName, 'email': updatedEmail}]},
|
|
137
|
-
);
|
|
138
|
-
expect(response).toHaveProperty('users');
|
|
139
|
-
expect(response.users[0].code).toBe('SUCCESS');
|
|
140
|
-
expect(response.users[0].message).toBe('User updated');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('should receive the updated values when getting the newly created User by ID', async () => {
|
|
144
|
-
const response = await api.getUser(newUserId);
|
|
145
|
-
expect(response).toHaveProperty('users');
|
|
146
|
-
expect(response.users[0].id).toBe(newUserId);
|
|
147
|
-
expect(response.users[0].first_name).toBe(updatedFirstName);
|
|
148
|
-
expect(response.users[0].email).toBe(updatedEmail);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('should delete the newly created User by ID', async () => {
|
|
152
|
-
const response = await api.deleteUser(newUserId);
|
|
153
|
-
expect(response).toHaveProperty('users');
|
|
154
|
-
expect(response.users[0].code).toBe('SUCCESS');
|
|
155
|
-
expect(response.users[0].message).toBe('User deleted');
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should throw FetchError when trying to create with empty params', () => {
|
|
159
|
-
expect(async () => await api.createUser()).rejects.toThrow(FetchError)
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('Test Profile resource', () => {
|
|
164
|
-
it('should list all Profiles', async () => {
|
|
165
|
-
const response = await api.listProfiles();
|
|
166
|
-
expect(response).toHaveProperty('profiles');
|
|
167
|
-
expect(response.profiles).toBeInstanceOf(Array);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it.skip('should create a new Profile', async () => {
|
|
171
|
-
// TODO
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it.skip('should get the newly created Profile by ID', async () => {
|
|
175
|
-
// TODO
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it.skip('should update the newly created Profile by ID', async () => {
|
|
179
|
-
// TODO
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it.skip('should receive the updated values when getting the newly created Profile by ID', async () => {
|
|
183
|
-
// TODO
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it.skip('should delete the newly created Profile by ID', async () => {
|
|
187
|
-
// TODO
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it.skip('should throw FetchError when trying to create with empty params', () => {
|
|
191
|
-
// TODO
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
});
|