@rachelallyson/planning-center-people-ts 1.0.0 → 2.0.0
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/CHANGELOG.md +248 -1
- package/README.md +28 -0
- package/dist/auth.d.ts +64 -0
- package/dist/auth.js +98 -0
- package/dist/batch.d.ts +47 -0
- package/dist/batch.js +376 -0
- package/dist/client-manager.d.ts +66 -0
- package/dist/client-manager.js +150 -0
- package/dist/client.d.ts +71 -0
- package/dist/client.js +123 -0
- package/dist/core/http.d.ts +47 -0
- package/dist/core/http.js +242 -0
- package/dist/core/pagination.d.ts +34 -0
- package/dist/core/pagination.js +164 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.js +12 -0
- package/dist/helpers.d.ts +125 -100
- package/dist/helpers.js +315 -275
- package/dist/index.d.ts +17 -5
- package/dist/index.js +39 -5
- package/dist/matching/matcher.d.ts +41 -0
- package/dist/matching/matcher.js +161 -0
- package/dist/matching/scoring.d.ts +35 -0
- package/dist/matching/scoring.js +141 -0
- package/dist/matching/strategies.d.ts +35 -0
- package/dist/matching/strategies.js +79 -0
- package/dist/modules/base.d.ts +46 -0
- package/dist/modules/base.js +82 -0
- package/dist/modules/contacts.d.ts +103 -0
- package/dist/modules/contacts.js +130 -0
- package/dist/modules/fields.d.ts +157 -0
- package/dist/modules/fields.js +294 -0
- package/dist/modules/households.d.ts +42 -0
- package/dist/modules/households.js +74 -0
- package/dist/modules/lists.d.ts +62 -0
- package/dist/modules/lists.js +92 -0
- package/dist/modules/notes.d.ts +74 -0
- package/dist/modules/notes.js +125 -0
- package/dist/modules/people.d.ts +196 -0
- package/dist/modules/people.js +221 -0
- package/dist/modules/workflows.d.ts +131 -0
- package/dist/modules/workflows.js +221 -0
- package/dist/monitoring.d.ts +53 -0
- package/dist/monitoring.js +142 -0
- package/dist/people/contacts.d.ts +43 -0
- package/dist/people/contacts.js +122 -0
- package/dist/people/core.d.ts +28 -0
- package/dist/people/core.js +69 -0
- package/dist/people/fields.d.ts +62 -0
- package/dist/people/fields.js +293 -0
- package/dist/people/households.d.ts +15 -0
- package/dist/people/households.js +31 -0
- package/dist/people/index.d.ts +8 -0
- package/dist/people/index.js +25 -0
- package/dist/people/lists.d.ts +30 -0
- package/dist/people/lists.js +37 -0
- package/dist/people/notes.d.ts +30 -0
- package/dist/people/notes.js +37 -0
- package/dist/people/organization.d.ts +12 -0
- package/dist/people/organization.js +15 -0
- package/dist/people/workflows.d.ts +37 -0
- package/dist/people/workflows.js +75 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.js +24 -0
- package/dist/testing/recorder.d.ts +58 -0
- package/dist/testing/recorder.js +195 -0
- package/dist/testing/simple-builders.d.ts +33 -0
- package/dist/testing/simple-builders.js +124 -0
- package/dist/testing/simple-factories.d.ts +91 -0
- package/dist/testing/simple-factories.js +279 -0
- package/dist/testing/types.d.ts +160 -0
- package/dist/testing/types.js +5 -0
- package/dist/types/batch.d.ts +50 -0
- package/dist/types/batch.js +5 -0
- package/dist/types/client.d.ts +81 -0
- package/dist/types/client.js +5 -0
- package/dist/types/events.d.ts +85 -0
- package/dist/types/events.js +5 -0
- package/dist/types/people.d.ts +73 -79
- package/package.json +14 -3
- package/dist/people.d.ts +0 -205
- package/dist/people.js +0 -598
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v2.0.0 Notes Module
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NotesModule = void 0;
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
class NotesModule extends base_1.BaseModule {
|
|
9
|
+
/**
|
|
10
|
+
* Get all notes
|
|
11
|
+
*/
|
|
12
|
+
async getAll(options = {}) {
|
|
13
|
+
const params = {};
|
|
14
|
+
if (options.where) {
|
|
15
|
+
Object.entries(options.where).forEach(([key, value]) => {
|
|
16
|
+
params[`where[${key}]`] = value;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (options.include) {
|
|
20
|
+
params.include = options.include.join(',');
|
|
21
|
+
}
|
|
22
|
+
if (options.perPage) {
|
|
23
|
+
params.per_page = options.perPage;
|
|
24
|
+
}
|
|
25
|
+
if (options.page) {
|
|
26
|
+
params.page = options.page;
|
|
27
|
+
}
|
|
28
|
+
return this.getList('/notes', params);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all notes across all pages
|
|
32
|
+
*/
|
|
33
|
+
async getAllPagesPaginated(options = {}, paginationOptions) {
|
|
34
|
+
const params = {};
|
|
35
|
+
if (options.where) {
|
|
36
|
+
Object.entries(options.where).forEach(([key, value]) => {
|
|
37
|
+
params[`where[${key}]`] = value;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (options.include) {
|
|
41
|
+
params.include = options.include.join(',');
|
|
42
|
+
}
|
|
43
|
+
return this.getAllPages('/notes', params, paginationOptions);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a single note by ID
|
|
47
|
+
*/
|
|
48
|
+
async getById(id, include) {
|
|
49
|
+
const params = {};
|
|
50
|
+
if (include) {
|
|
51
|
+
params.include = include.join(',');
|
|
52
|
+
}
|
|
53
|
+
return this.getSingle(`/notes/${id}`, params);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get notes for a specific person
|
|
57
|
+
*/
|
|
58
|
+
async getNotesForPerson(personId, options = {}) {
|
|
59
|
+
const params = {};
|
|
60
|
+
if (options.where) {
|
|
61
|
+
Object.entries(options.where).forEach(([key, value]) => {
|
|
62
|
+
params[`where[${key}]`] = value;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (options.include) {
|
|
66
|
+
params.include = options.include.join(',');
|
|
67
|
+
}
|
|
68
|
+
if (options.perPage) {
|
|
69
|
+
params.per_page = options.perPage;
|
|
70
|
+
}
|
|
71
|
+
if (options.page) {
|
|
72
|
+
params.page = options.page;
|
|
73
|
+
}
|
|
74
|
+
return this.getList(`/people/${personId}/notes`, params);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a note for a person
|
|
78
|
+
*/
|
|
79
|
+
async create(personId, data) {
|
|
80
|
+
return this.createResource(`/people/${personId}/notes`, data);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Update a note
|
|
84
|
+
*/
|
|
85
|
+
async update(id, data) {
|
|
86
|
+
return this.updateResource(`/notes/${id}`, data);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Delete a note
|
|
90
|
+
*/
|
|
91
|
+
async delete(id) {
|
|
92
|
+
return this.deleteResource(`/notes/${id}`);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get all note categories
|
|
96
|
+
*/
|
|
97
|
+
async getNoteCategories() {
|
|
98
|
+
return this.getList('/note_categories');
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get a single note category by ID
|
|
102
|
+
*/
|
|
103
|
+
async getNoteCategoryById(id) {
|
|
104
|
+
return this.getSingle(`/note_categories/${id}`);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create a note category
|
|
108
|
+
*/
|
|
109
|
+
async createNoteCategory(data) {
|
|
110
|
+
return this.createResource('/note_categories', data);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Update a note category
|
|
114
|
+
*/
|
|
115
|
+
async updateNoteCategory(id, data) {
|
|
116
|
+
return this.updateResource(`/note_categories/${id}`, data);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Delete a note category
|
|
120
|
+
*/
|
|
121
|
+
async deleteNoteCategory(id) {
|
|
122
|
+
return this.deleteResource(`/note_categories/${id}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.NotesModule = NotesModule;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 People Module
|
|
3
|
+
*/
|
|
4
|
+
import { BaseModule } from './base';
|
|
5
|
+
import type { PcoHttpClient } from '../core/http';
|
|
6
|
+
import type { PaginationHelper } from '../core/pagination';
|
|
7
|
+
import type { PcoEventEmitter } from '../monitoring';
|
|
8
|
+
import type { PaginationOptions, PaginationResult } from '../core/pagination';
|
|
9
|
+
import type { PersonResource, EmailResource, EmailAttributes, PhoneNumberResource, PhoneNumberAttributes, AddressResource, AddressAttributes, SocialProfileResource, SocialProfileAttributes } from '../types';
|
|
10
|
+
export interface PeopleListOptions {
|
|
11
|
+
where?: Record<string, any>;
|
|
12
|
+
include?: string[];
|
|
13
|
+
perPage?: number;
|
|
14
|
+
page?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface PersonCreateOptions {
|
|
17
|
+
firstName?: string;
|
|
18
|
+
lastName?: string;
|
|
19
|
+
givenName?: string;
|
|
20
|
+
middleName?: string;
|
|
21
|
+
nickname?: string;
|
|
22
|
+
birthdate?: string;
|
|
23
|
+
anniversary?: string;
|
|
24
|
+
gender?: string;
|
|
25
|
+
grade?: string;
|
|
26
|
+
child?: boolean;
|
|
27
|
+
status?: string;
|
|
28
|
+
medicalNotes?: string;
|
|
29
|
+
jobTitle?: string;
|
|
30
|
+
employer?: string;
|
|
31
|
+
school?: string;
|
|
32
|
+
graduationYear?: string;
|
|
33
|
+
avatar?: string;
|
|
34
|
+
siteAdministrator?: boolean;
|
|
35
|
+
accountingAdministrator?: boolean;
|
|
36
|
+
peoplePermissions?: string;
|
|
37
|
+
directoryStatus?: string;
|
|
38
|
+
loginIdentifier?: string;
|
|
39
|
+
membership?: string;
|
|
40
|
+
remoteId?: string;
|
|
41
|
+
demographicAvatarUrl?: string;
|
|
42
|
+
inactivatedAt?: string;
|
|
43
|
+
resourcePermissionFlags?: Record<string, boolean>;
|
|
44
|
+
}
|
|
45
|
+
export interface PersonMatchOptions {
|
|
46
|
+
firstName?: string;
|
|
47
|
+
lastName?: string;
|
|
48
|
+
email?: string;
|
|
49
|
+
phone?: string;
|
|
50
|
+
matchStrategy?: 'exact' | 'fuzzy' | 'aggressive';
|
|
51
|
+
campus?: string;
|
|
52
|
+
createIfNotFound?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare class PeopleModule extends BaseModule {
|
|
55
|
+
private personMatcher;
|
|
56
|
+
constructor(httpClient: PcoHttpClient, paginationHelper: PaginationHelper, eventEmitter: PcoEventEmitter);
|
|
57
|
+
/**
|
|
58
|
+
* Get all people with optional filtering
|
|
59
|
+
*/
|
|
60
|
+
getAll(options?: PeopleListOptions): Promise<{
|
|
61
|
+
data: PersonResource[];
|
|
62
|
+
meta?: any;
|
|
63
|
+
links?: any;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Get all people across all pages
|
|
67
|
+
*/
|
|
68
|
+
getAllPagesPaginated(options?: PeopleListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<PersonResource>>;
|
|
69
|
+
/**
|
|
70
|
+
* Get a single person by ID
|
|
71
|
+
*/
|
|
72
|
+
getById(id: string, include?: string[]): Promise<PersonResource>;
|
|
73
|
+
/**
|
|
74
|
+
* Create a new person
|
|
75
|
+
*/
|
|
76
|
+
create(data: PersonCreateOptions): Promise<PersonResource>;
|
|
77
|
+
/**
|
|
78
|
+
* Update a person
|
|
79
|
+
*/
|
|
80
|
+
update(id: string, data: Partial<PersonCreateOptions>): Promise<PersonResource>;
|
|
81
|
+
/**
|
|
82
|
+
* Delete a person
|
|
83
|
+
*/
|
|
84
|
+
delete(id: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Find or create a person with smart matching
|
|
87
|
+
*/
|
|
88
|
+
findOrCreate(options: PersonMatchOptions): Promise<PersonResource>;
|
|
89
|
+
/**
|
|
90
|
+
* Search people by multiple criteria
|
|
91
|
+
*/
|
|
92
|
+
search(criteria: {
|
|
93
|
+
name?: string;
|
|
94
|
+
email?: string;
|
|
95
|
+
phone?: string;
|
|
96
|
+
status?: string;
|
|
97
|
+
perPage?: number;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
data: PersonResource[];
|
|
100
|
+
meta?: any;
|
|
101
|
+
links?: any;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Get person's emails
|
|
105
|
+
*/
|
|
106
|
+
getEmails(personId: string): Promise<{
|
|
107
|
+
data: EmailResource[];
|
|
108
|
+
meta?: any;
|
|
109
|
+
links?: any;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Add an email to a person
|
|
113
|
+
*/
|
|
114
|
+
addEmail(personId: string, data: EmailAttributes): Promise<EmailResource>;
|
|
115
|
+
/**
|
|
116
|
+
* Update a person's email
|
|
117
|
+
*/
|
|
118
|
+
updateEmail(personId: string, emailId: string, data: Partial<EmailAttributes>): Promise<EmailResource>;
|
|
119
|
+
/**
|
|
120
|
+
* Delete a person's email
|
|
121
|
+
*/
|
|
122
|
+
deleteEmail(personId: string, emailId: string): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Get person's phone numbers
|
|
125
|
+
*/
|
|
126
|
+
getPhoneNumbers(personId: string): Promise<{
|
|
127
|
+
data: PhoneNumberResource[];
|
|
128
|
+
meta?: any;
|
|
129
|
+
links?: any;
|
|
130
|
+
}>;
|
|
131
|
+
/**
|
|
132
|
+
* Add a phone number to a person
|
|
133
|
+
*/
|
|
134
|
+
addPhoneNumber(personId: string, data: PhoneNumberAttributes): Promise<PhoneNumberResource>;
|
|
135
|
+
/**
|
|
136
|
+
* Update a person's phone number
|
|
137
|
+
*/
|
|
138
|
+
updatePhoneNumber(personId: string, phoneId: string, data: Partial<PhoneNumberAttributes>): Promise<PhoneNumberResource>;
|
|
139
|
+
/**
|
|
140
|
+
* Delete a person's phone number
|
|
141
|
+
*/
|
|
142
|
+
deletePhoneNumber(personId: string, phoneId: string): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Get person's addresses
|
|
145
|
+
*/
|
|
146
|
+
getAddresses(personId: string): Promise<{
|
|
147
|
+
data: AddressResource[];
|
|
148
|
+
meta?: any;
|
|
149
|
+
links?: any;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Add an address to a person
|
|
153
|
+
*/
|
|
154
|
+
addAddress(personId: string, data: AddressAttributes): Promise<AddressResource>;
|
|
155
|
+
/**
|
|
156
|
+
* Update a person's address
|
|
157
|
+
*/
|
|
158
|
+
updateAddress(personId: string, addressId: string, data: Partial<AddressAttributes>): Promise<AddressResource>;
|
|
159
|
+
/**
|
|
160
|
+
* Delete a person's address
|
|
161
|
+
*/
|
|
162
|
+
deleteAddress(personId: string, addressId: string): Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* Get person's social profiles
|
|
165
|
+
*/
|
|
166
|
+
getSocialProfiles(personId: string): Promise<{
|
|
167
|
+
data: SocialProfileResource[];
|
|
168
|
+
meta?: any;
|
|
169
|
+
links?: any;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Add a social profile to a person
|
|
173
|
+
*/
|
|
174
|
+
addSocialProfile(personId: string, data: SocialProfileAttributes): Promise<SocialProfileResource>;
|
|
175
|
+
/**
|
|
176
|
+
* Update a person's social profile
|
|
177
|
+
*/
|
|
178
|
+
updateSocialProfile(personId: string, profileId: string, data: Partial<SocialProfileAttributes>): Promise<SocialProfileResource>;
|
|
179
|
+
/**
|
|
180
|
+
* Delete a person's social profile
|
|
181
|
+
*/
|
|
182
|
+
deleteSocialProfile(personId: string, profileId: string): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Create a person with contact information
|
|
185
|
+
*/
|
|
186
|
+
createWithContacts(personData: PersonCreateOptions, contacts?: {
|
|
187
|
+
email?: EmailAttributes;
|
|
188
|
+
phone?: PhoneNumberAttributes;
|
|
189
|
+
address?: AddressAttributes;
|
|
190
|
+
}): Promise<{
|
|
191
|
+
person: PersonResource;
|
|
192
|
+
email?: EmailResource;
|
|
193
|
+
phone?: PhoneNumberResource;
|
|
194
|
+
address?: AddressResource;
|
|
195
|
+
}>;
|
|
196
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v2.0.0 People Module
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PeopleModule = void 0;
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
const matcher_1 = require("../matching/matcher");
|
|
9
|
+
class PeopleModule extends base_1.BaseModule {
|
|
10
|
+
constructor(httpClient, paginationHelper, eventEmitter) {
|
|
11
|
+
super(httpClient, paginationHelper, eventEmitter);
|
|
12
|
+
this.personMatcher = new matcher_1.PersonMatcher(this);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get all people with optional filtering
|
|
16
|
+
*/
|
|
17
|
+
async getAll(options = {}) {
|
|
18
|
+
const params = {};
|
|
19
|
+
if (options.where) {
|
|
20
|
+
Object.entries(options.where).forEach(([key, value]) => {
|
|
21
|
+
params[`where[${key}]`] = value;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (options.include) {
|
|
25
|
+
params.include = options.include.join(',');
|
|
26
|
+
}
|
|
27
|
+
if (options.perPage) {
|
|
28
|
+
params.per_page = options.perPage;
|
|
29
|
+
}
|
|
30
|
+
if (options.page) {
|
|
31
|
+
params.page = options.page;
|
|
32
|
+
}
|
|
33
|
+
return this.getList('/people', params);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get all people across all pages
|
|
37
|
+
*/
|
|
38
|
+
async getAllPagesPaginated(options = {}, paginationOptions) {
|
|
39
|
+
const params = {};
|
|
40
|
+
if (options.where) {
|
|
41
|
+
Object.entries(options.where).forEach(([key, value]) => {
|
|
42
|
+
params[`where[${key}]`] = value;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (options.include) {
|
|
46
|
+
params.include = options.include.join(',');
|
|
47
|
+
}
|
|
48
|
+
return this.getAllPages('/people', params, paginationOptions);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get a single person by ID
|
|
52
|
+
*/
|
|
53
|
+
async getById(id, include) {
|
|
54
|
+
const params = {};
|
|
55
|
+
if (include) {
|
|
56
|
+
params.include = include.join(',');
|
|
57
|
+
}
|
|
58
|
+
return this.getSingle(`/people/${id}`, params);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a new person
|
|
62
|
+
*/
|
|
63
|
+
async create(data) {
|
|
64
|
+
return this.createResource('/people', data);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Update a person
|
|
68
|
+
*/
|
|
69
|
+
async update(id, data) {
|
|
70
|
+
return this.updateResource(`/people/${id}`, data);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Delete a person
|
|
74
|
+
*/
|
|
75
|
+
async delete(id) {
|
|
76
|
+
return this.deleteResource(`/people/${id}`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Find or create a person with smart matching
|
|
80
|
+
*/
|
|
81
|
+
async findOrCreate(options) {
|
|
82
|
+
return this.personMatcher.findOrCreate(options);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Search people by multiple criteria
|
|
86
|
+
*/
|
|
87
|
+
async search(criteria) {
|
|
88
|
+
const where = {};
|
|
89
|
+
if (criteria.name) {
|
|
90
|
+
where.name = criteria.name;
|
|
91
|
+
}
|
|
92
|
+
if (criteria.email) {
|
|
93
|
+
where.email = criteria.email;
|
|
94
|
+
}
|
|
95
|
+
if (criteria.phone) {
|
|
96
|
+
where.phone = criteria.phone;
|
|
97
|
+
}
|
|
98
|
+
if (criteria.status) {
|
|
99
|
+
where.status = criteria.status;
|
|
100
|
+
}
|
|
101
|
+
return this.getAll({
|
|
102
|
+
where,
|
|
103
|
+
perPage: criteria.perPage || 25,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// Contact methods
|
|
107
|
+
/**
|
|
108
|
+
* Get person's emails
|
|
109
|
+
*/
|
|
110
|
+
async getEmails(personId) {
|
|
111
|
+
return this.getList(`/people/${personId}/emails`);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Add an email to a person
|
|
115
|
+
*/
|
|
116
|
+
async addEmail(personId, data) {
|
|
117
|
+
return this.createResource(`/people/${personId}/emails`, data);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Update a person's email
|
|
121
|
+
*/
|
|
122
|
+
async updateEmail(personId, emailId, data) {
|
|
123
|
+
return this.updateResource(`/people/${personId}/emails/${emailId}`, data);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Delete a person's email
|
|
127
|
+
*/
|
|
128
|
+
async deleteEmail(personId, emailId) {
|
|
129
|
+
return this.deleteResource(`/people/${personId}/emails/${emailId}`);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get person's phone numbers
|
|
133
|
+
*/
|
|
134
|
+
async getPhoneNumbers(personId) {
|
|
135
|
+
return this.getList(`/people/${personId}/phone_numbers`);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Add a phone number to a person
|
|
139
|
+
*/
|
|
140
|
+
async addPhoneNumber(personId, data) {
|
|
141
|
+
return this.createResource(`/people/${personId}/phone_numbers`, data);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Update a person's phone number
|
|
145
|
+
*/
|
|
146
|
+
async updatePhoneNumber(personId, phoneId, data) {
|
|
147
|
+
return this.updateResource(`/people/${personId}/phone_numbers/${phoneId}`, data);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Delete a person's phone number
|
|
151
|
+
*/
|
|
152
|
+
async deletePhoneNumber(personId, phoneId) {
|
|
153
|
+
return this.deleteResource(`/people/${personId}/phone_numbers/${phoneId}`);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get person's addresses
|
|
157
|
+
*/
|
|
158
|
+
async getAddresses(personId) {
|
|
159
|
+
return this.getList(`/people/${personId}/addresses`);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Add an address to a person
|
|
163
|
+
*/
|
|
164
|
+
async addAddress(personId, data) {
|
|
165
|
+
return this.createResource(`/people/${personId}/addresses`, data);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Update a person's address
|
|
169
|
+
*/
|
|
170
|
+
async updateAddress(personId, addressId, data) {
|
|
171
|
+
return this.updateResource(`/people/${personId}/addresses/${addressId}`, data);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Delete a person's address
|
|
175
|
+
*/
|
|
176
|
+
async deleteAddress(personId, addressId) {
|
|
177
|
+
return this.deleteResource(`/people/${personId}/addresses/${addressId}`);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get person's social profiles
|
|
181
|
+
*/
|
|
182
|
+
async getSocialProfiles(personId) {
|
|
183
|
+
return this.getList(`/people/${personId}/social_profiles`);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Add a social profile to a person
|
|
187
|
+
*/
|
|
188
|
+
async addSocialProfile(personId, data) {
|
|
189
|
+
return this.createResource(`/people/${personId}/social_profiles`, data);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Update a person's social profile
|
|
193
|
+
*/
|
|
194
|
+
async updateSocialProfile(personId, profileId, data) {
|
|
195
|
+
return this.updateResource(`/people/${personId}/social_profiles/${profileId}`, data);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Delete a person's social profile
|
|
199
|
+
*/
|
|
200
|
+
async deleteSocialProfile(personId, profileId) {
|
|
201
|
+
return this.deleteResource(`/people/${personId}/social_profiles/${profileId}`);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Create a person with contact information
|
|
205
|
+
*/
|
|
206
|
+
async createWithContacts(personData, contacts) {
|
|
207
|
+
const person = await this.create(personData);
|
|
208
|
+
const result = { person };
|
|
209
|
+
if (contacts?.email) {
|
|
210
|
+
result.email = await this.addEmail(person.id, contacts.email);
|
|
211
|
+
}
|
|
212
|
+
if (contacts?.phone) {
|
|
213
|
+
result.phone = await this.addPhoneNumber(person.id, contacts.phone);
|
|
214
|
+
}
|
|
215
|
+
if (contacts?.address) {
|
|
216
|
+
result.address = await this.addAddress(person.id, contacts.address);
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.PeopleModule = PeopleModule;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Workflows Module
|
|
3
|
+
*/
|
|
4
|
+
import { BaseModule } from './base';
|
|
5
|
+
import type { PaginationOptions, PaginationResult } from '../core/pagination';
|
|
6
|
+
import type { WorkflowResource, WorkflowAttributes, WorkflowCardResource, WorkflowCardAssignableAttributes, WorkflowCardSnoozeAttributes, WorkflowCardEmailAttributes, WorkflowCardNoteResource, WorkflowCardNoteAttributes } from '../types';
|
|
7
|
+
export interface WorkflowListOptions {
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
include?: string[];
|
|
10
|
+
perPage?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface AddPersonToWorkflowOptions {
|
|
14
|
+
note?: string;
|
|
15
|
+
skipIfExists?: boolean;
|
|
16
|
+
skipIfActive?: boolean;
|
|
17
|
+
noteTemplate?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class WorkflowsModule extends BaseModule {
|
|
20
|
+
/**
|
|
21
|
+
* Get all workflows
|
|
22
|
+
*/
|
|
23
|
+
getAll(options?: WorkflowListOptions): Promise<{
|
|
24
|
+
data: WorkflowResource[];
|
|
25
|
+
meta?: any;
|
|
26
|
+
links?: any;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Get all workflows across all pages
|
|
30
|
+
*/
|
|
31
|
+
getAllPagesPaginated(options?: WorkflowListOptions, paginationOptions?: PaginationOptions): Promise<PaginationResult<WorkflowResource>>;
|
|
32
|
+
/**
|
|
33
|
+
* Get a single workflow by ID
|
|
34
|
+
*/
|
|
35
|
+
getById(id: string, include?: string[]): Promise<WorkflowResource>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a workflow
|
|
38
|
+
*/
|
|
39
|
+
create(data: WorkflowAttributes): Promise<WorkflowResource>;
|
|
40
|
+
/**
|
|
41
|
+
* Update a workflow
|
|
42
|
+
*/
|
|
43
|
+
update(id: string, data: Partial<WorkflowAttributes>): Promise<WorkflowResource>;
|
|
44
|
+
/**
|
|
45
|
+
* Delete a workflow
|
|
46
|
+
*/
|
|
47
|
+
delete(id: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Get workflow cards for a person
|
|
50
|
+
*/
|
|
51
|
+
getPersonWorkflowCards(personId: string): Promise<{
|
|
52
|
+
data: WorkflowCardResource[];
|
|
53
|
+
meta?: any;
|
|
54
|
+
links?: any;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Add a person to a workflow with smart duplicate detection
|
|
58
|
+
*/
|
|
59
|
+
addPersonToWorkflow(personId: string, workflowId: string, options?: AddPersonToWorkflowOptions): Promise<WorkflowCardResource>;
|
|
60
|
+
/**
|
|
61
|
+
* Create a workflow card
|
|
62
|
+
*/
|
|
63
|
+
createWorkflowCard(workflowId: string, personId: string): Promise<WorkflowCardResource>;
|
|
64
|
+
/**
|
|
65
|
+
* Update a workflow card
|
|
66
|
+
*/
|
|
67
|
+
updateWorkflowCard(workflowCardId: string, data: Partial<WorkflowCardAssignableAttributes>, personId?: string): Promise<WorkflowCardResource>;
|
|
68
|
+
/**
|
|
69
|
+
* Get workflow card notes
|
|
70
|
+
*/
|
|
71
|
+
getWorkflowCardNotes(personId: string, workflowCardId: string): Promise<{
|
|
72
|
+
data: WorkflowCardNoteResource[];
|
|
73
|
+
meta?: any;
|
|
74
|
+
links?: any;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Create a workflow card note
|
|
78
|
+
*/
|
|
79
|
+
createWorkflowCardNote(personId: string, workflowCardId: string, data: WorkflowCardNoteAttributes): Promise<WorkflowCardNoteResource>;
|
|
80
|
+
/**
|
|
81
|
+
* Update a workflow card note
|
|
82
|
+
*/
|
|
83
|
+
updateWorkflowCardNote(personId: string, workflowCardId: string, noteId: string, data: Partial<WorkflowCardNoteAttributes>): Promise<WorkflowCardNoteResource>;
|
|
84
|
+
/**
|
|
85
|
+
* Delete a workflow card note
|
|
86
|
+
*/
|
|
87
|
+
deleteWorkflowCardNote(personId: string, workflowCardId: string, noteId: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Create a workflow card with a note
|
|
90
|
+
*/
|
|
91
|
+
createWorkflowCardWithNote(workflowId: string, personId: string, noteData: WorkflowCardNoteAttributes): Promise<{
|
|
92
|
+
workflowCard: WorkflowCardResource;
|
|
93
|
+
note: WorkflowCardNoteResource;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Move a workflow card back to the previous step
|
|
97
|
+
*/
|
|
98
|
+
goBackWorkflowCard(personId: string, workflowCardId: string): Promise<WorkflowCardResource>;
|
|
99
|
+
/**
|
|
100
|
+
* Move a workflow card to the next step
|
|
101
|
+
*/
|
|
102
|
+
promoteWorkflowCard(personId: string, workflowCardId: string): Promise<WorkflowCardResource>;
|
|
103
|
+
/**
|
|
104
|
+
* Remove a workflow card
|
|
105
|
+
*/
|
|
106
|
+
removeWorkflowCard(personId: string, workflowCardId: string): Promise<WorkflowCardResource>;
|
|
107
|
+
/**
|
|
108
|
+
* Restore a workflow card
|
|
109
|
+
*/
|
|
110
|
+
restoreWorkflowCard(personId: string, workflowCardId: string): Promise<WorkflowCardResource>;
|
|
111
|
+
/**
|
|
112
|
+
* Send an email to the subject of the workflow card
|
|
113
|
+
*/
|
|
114
|
+
sendEmailWorkflowCard(personId: string, workflowCardId: string, data: WorkflowCardEmailAttributes): Promise<WorkflowCardResource>;
|
|
115
|
+
/**
|
|
116
|
+
* Move a workflow card to the next step without completing the current step
|
|
117
|
+
*/
|
|
118
|
+
skipStepWorkflowCard(personId: string, workflowCardId: string): Promise<WorkflowCardResource>;
|
|
119
|
+
/**
|
|
120
|
+
* Snooze a workflow card for a specific duration
|
|
121
|
+
*/
|
|
122
|
+
snoozeWorkflowCard(personId: string, workflowCardId: string, data: WorkflowCardSnoozeAttributes): Promise<WorkflowCardResource>;
|
|
123
|
+
/**
|
|
124
|
+
* Unsnooze a workflow card
|
|
125
|
+
*/
|
|
126
|
+
unsnoozeWorkflowCard(personId: string, workflowCardId: string): Promise<WorkflowCardResource>;
|
|
127
|
+
/**
|
|
128
|
+
* Format note template with variables
|
|
129
|
+
*/
|
|
130
|
+
private formatNoteTemplate;
|
|
131
|
+
}
|