mp-js-api 0.0.26 → 0.0.29
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/.gitattributes +2 -2
- package/dist/api.d.ts +44 -22
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +75 -75
- package/dist/index.d.ts +65 -52
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +109 -91
- package/dist/tables/addresses.d.ts.map +1 -1
- package/dist/tables/contacts.d.ts +6 -0
- package/dist/tables/contacts.d.ts.map +1 -1
- package/dist/tables/files.d.ts +17 -0
- package/dist/tables/files.d.ts.map +1 -0
- package/dist/tables/files.js +2 -0
- package/dist/tables/form-responses.d.ts +1 -1
- package/dist/tables/groups.d.ts.map +1 -1
- package/dist/tables/households.d.ts.map +1 -1
- package/dist/tables/participants.d.ts.map +1 -1
- package/dist/utils/converters.d.ts +2 -2
- package/dist/utils/converters.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/api.ts +135 -116
- package/src/index.ts +233 -195
- package/src/tables/addresses.ts +48 -48
- package/src/tables/contacts.ts +8 -0
- package/src/tables/files.ts +16 -0
- package/src/tables/form-responses.ts +1 -1
- package/src/tables/groups.ts +96 -96
- package/src/tables/households.ts +48 -48
- package/src/tables/participants.ts +56 -56
- package/src/utils/converters.ts +2 -2
- package/tsconfig.json +4 -3
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { createApiBase, MPApiBase, ErrorDetails,
|
|
2
|
+
import { createApiBase, MPApiBase, ErrorDetails, MPGetQuery, MPCreateQuery, MPUpdateQuery, DateTimeIsoString } from './api';
|
|
3
3
|
import { convertToCamelCase, convertToSnakeCase, escapeSql, stringifyURLParams } from './utils/converters';
|
|
4
4
|
import { Contact, ContactRecord } from './tables/contacts';
|
|
5
5
|
import { Event, EventRecord } from './tables/events';
|
|
@@ -13,52 +13,56 @@ import { ContactAttribute, ContactAttributeRecord, ContactWithAttribute } from '
|
|
|
13
13
|
import { FormResponse, FormResponseRecord } from './tables/form-responses';
|
|
14
14
|
import { FormResponseAnswer, FormResponseAnswerRecord } from './tables/from-response-answers';
|
|
15
15
|
import { ContactEmailAddress, ContactEmailAddressRecord, ContactWithEmailAddress, ContactWithEmailAddresses } from './tables/contact-email-addresses';
|
|
16
|
+
import { AttachedFile } from './tables/files';
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
19
20
|
export type AtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> }[keyof T];
|
|
20
21
|
|
|
21
|
-
export type
|
|
22
|
+
export type CreateContactPayload = WithRequired<
|
|
22
23
|
Omit<Partial<Contact>, 'contactID'>,
|
|
23
24
|
'company' | 'displayName'
|
|
24
25
|
>;
|
|
25
|
-
export type
|
|
26
|
+
export type CreateHouseholdPayload = WithRequired<
|
|
26
27
|
Partial<Household>,
|
|
27
28
|
'householdName'
|
|
28
29
|
>;
|
|
29
|
-
export type
|
|
30
|
+
export type CreateAddressPayload = WithRequired<
|
|
30
31
|
Partial<Address>,
|
|
31
32
|
'addressLine1'
|
|
32
33
|
>;
|
|
33
|
-
export type
|
|
34
|
+
export type CreateParticipantPayload = WithRequired<
|
|
34
35
|
Partial<Participant>,
|
|
35
36
|
'contactID' | 'participantTypeID' | 'participantStartDate'
|
|
36
37
|
>;
|
|
37
|
-
export type
|
|
38
|
+
export type CreateEventParticipantPayload = WithRequired<
|
|
38
39
|
Partial<EventParticipant>,
|
|
39
40
|
'eventID' | 'participantID' | 'participationStatusID'
|
|
40
41
|
>;
|
|
41
|
-
export type
|
|
42
|
+
export type CreateGroupParticipantPayload = WithRequired<
|
|
42
43
|
Partial<GroupParticipant>,
|
|
43
44
|
'groupID' | 'participantID' | 'groupRoleID' | 'startDate'
|
|
44
45
|
>;
|
|
45
|
-
export type
|
|
46
|
+
export type CreateContactAttributePayload = WithRequired<
|
|
46
47
|
Partial<ContactAttribute>,
|
|
47
48
|
'attributeID' | 'contactID' | 'startDate'
|
|
48
49
|
>;
|
|
49
|
-
export type
|
|
50
|
+
export type CreateFormResponsePayload = WithRequired<
|
|
50
51
|
Omit<Partial<FormResponse>, 'formResponseID'>,
|
|
51
52
|
'formID' | 'responseDate'
|
|
52
53
|
>;
|
|
53
|
-
export type
|
|
54
|
+
export type CreateFormResponseAnswerPayload = WithRequired<
|
|
54
55
|
Omit<Partial<FormResponseAnswer>, 'formResponseAnswerID'>,
|
|
55
56
|
'formFieldID' | 'formResponseID'
|
|
56
57
|
>;
|
|
57
|
-
export type
|
|
58
|
+
export type CreateContactEmailAddressPayload = WithRequired<
|
|
58
59
|
Omit<Partial<ContactEmailAddress>, 'emailAddressID'>,
|
|
59
60
|
'emailAddress' | 'contactID'
|
|
60
61
|
>;
|
|
61
|
-
|
|
62
|
+
export type CreateFilePayload = WithRequired<
|
|
63
|
+
Omit<Partial<AttachedFile>, 'FileId'>,
|
|
64
|
+
'Description' | 'IsDefaultImage'
|
|
65
|
+
>;
|
|
62
66
|
|
|
63
67
|
|
|
64
68
|
export interface ContactDetails extends Contact, Participant, Household {
|
|
@@ -77,383 +81,417 @@ export type MPInstance = {
|
|
|
77
81
|
post: AxiosInstance['post'];
|
|
78
82
|
createOne: MPApiBase['createOne'];
|
|
79
83
|
createMany: MPApiBase['createMany'];
|
|
80
|
-
|
|
84
|
+
updateMany: MPApiBase['updateMany'];
|
|
81
85
|
getOne: MPApiBase['getOne'];
|
|
82
86
|
getMany: MPApiBase['getMany'];
|
|
87
|
+
createFile: MPApiBase['createFile'];
|
|
88
|
+
updateFile: MPApiBase['updateFile'];
|
|
83
89
|
|
|
84
90
|
getContact(
|
|
85
91
|
id: number,
|
|
86
|
-
|
|
92
|
+
mpQuery?: MPGetQuery
|
|
87
93
|
): Promise<Contact | undefined | { error: ErrorDetails; }>;
|
|
88
94
|
getContactDetails(
|
|
89
95
|
id: number,
|
|
90
|
-
|
|
96
|
+
mpQuery?: MPGetQuery
|
|
91
97
|
): Promise<ContactDetails | undefined | { error: ErrorDetails; }>;
|
|
92
98
|
getContactAttribute(
|
|
93
99
|
id: number,
|
|
94
|
-
|
|
100
|
+
mpQuery?: MPGetQuery
|
|
95
101
|
): Promise<ContactAttribute | undefined | { error: ErrorDetails; }>;
|
|
96
102
|
getContactEmailAddress(
|
|
97
103
|
id: number,
|
|
98
|
-
|
|
104
|
+
mpQuery?: MPGetQuery
|
|
99
105
|
): Promise<ContactEmailAddress | undefined | { error: ErrorDetails; }>;
|
|
100
106
|
getHousehold(
|
|
101
107
|
id: number,
|
|
102
|
-
|
|
108
|
+
mpQuery?: MPGetQuery
|
|
103
109
|
): Promise<Household | undefined | { error: ErrorDetails; }>;
|
|
104
110
|
getAddress(
|
|
105
111
|
id: number,
|
|
106
|
-
|
|
112
|
+
mpQuery?: MPGetQuery
|
|
107
113
|
): Promise<Address | undefined | { error: ErrorDetails; }>;
|
|
108
114
|
getParticipant(
|
|
109
115
|
id: number,
|
|
110
|
-
|
|
116
|
+
mpQuery?: MPGetQuery
|
|
111
117
|
): Promise<Participant | undefined | { error: ErrorDetails; }>;
|
|
112
118
|
getEvent(
|
|
113
119
|
id: number,
|
|
114
|
-
|
|
120
|
+
mpQuery?: MPGetQuery
|
|
115
121
|
): Promise<Event | undefined | { error: ErrorDetails; }>;
|
|
116
122
|
getGroup(
|
|
117
123
|
id: number,
|
|
118
|
-
|
|
124
|
+
mpQuery?: MPGetQuery
|
|
119
125
|
): Promise<Group | undefined | { error: ErrorDetails; }>;
|
|
120
126
|
getEventParticipant(
|
|
121
127
|
id: number,
|
|
122
|
-
|
|
128
|
+
mpQuery?: MPGetQuery
|
|
123
129
|
): Promise<EventParticipant | undefined | { error: ErrorDetails; }>;
|
|
124
130
|
getGroupParticipant(
|
|
125
131
|
id: number,
|
|
126
|
-
|
|
132
|
+
mpQuery?: MPGetQuery
|
|
127
133
|
): Promise<GroupParticipant | undefined | { error: ErrorDetails; }>;
|
|
128
134
|
getFormResponse(
|
|
129
135
|
id: number,
|
|
130
|
-
|
|
136
|
+
mpQuery?: MPGetQuery
|
|
131
137
|
): Promise<FormResponse | undefined | { error: ErrorDetails; }>;
|
|
132
138
|
|
|
133
139
|
getContacts(
|
|
134
|
-
|
|
140
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
135
141
|
): Promise<Contact[] | { error: ErrorDetails; }>;
|
|
136
142
|
getContactAttributes(
|
|
137
|
-
|
|
143
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
138
144
|
): Promise<ContactAttribute[] | { error: ErrorDetails; }>;
|
|
139
145
|
getContactsWithAttributes(
|
|
140
|
-
|
|
146
|
+
mpQuery: AtLeastOne<Omit<MPGetQuery, "select">>
|
|
141
147
|
): Promise<ContactWithAttribute[] | { error: ErrorDetails; }>;
|
|
142
148
|
getContactEmailAddresses(
|
|
143
|
-
|
|
149
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
144
150
|
): Promise<ContactEmailAddress[] | { error: ErrorDetails; }>;
|
|
145
151
|
getContactsWithEmailAddress(
|
|
146
|
-
|
|
152
|
+
mpQuery: AtLeastOne<Omit<MPGetQuery, "select">>
|
|
147
153
|
): Promise<ContactWithEmailAddress[] | { error: ErrorDetails; }>;
|
|
148
154
|
getHouseholds(
|
|
149
|
-
|
|
155
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
150
156
|
): Promise<Household[] | { error: ErrorDetails; }>;
|
|
151
157
|
getAddresses(
|
|
152
|
-
|
|
158
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
153
159
|
): Promise<Address[] | { error: ErrorDetails; }>;
|
|
154
160
|
getParticipants(
|
|
155
|
-
|
|
161
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
156
162
|
): Promise<Participant[] | { error: ErrorDetails; }>;
|
|
157
163
|
getEvents(
|
|
158
|
-
|
|
164
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
159
165
|
): Promise<Event[] | { error: ErrorDetails; }>;
|
|
160
166
|
getGroups(
|
|
161
|
-
|
|
167
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
162
168
|
): Promise<Group[] | { error: ErrorDetails; }>;
|
|
163
169
|
getEventParticipants(
|
|
164
|
-
|
|
170
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
165
171
|
): Promise<EventParticipant[] | { error: ErrorDetails; }>;
|
|
166
172
|
getGroupParticipants(
|
|
167
|
-
|
|
173
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
168
174
|
): Promise<GroupParticipant[] | { error: ErrorDetails; }>;
|
|
169
175
|
getFormResponseAnswers(
|
|
170
|
-
|
|
176
|
+
mpQuery: AtLeastOne<MPGetQuery>
|
|
171
177
|
): Promise<FormResponseAnswer[] | { error: ErrorDetails; }>;
|
|
172
178
|
|
|
173
179
|
createContact(
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
data: CreateContactPayload,
|
|
181
|
+
mpQuery?: MPCreateQuery
|
|
176
182
|
): Promise<Contact | { error: ErrorDetails; }>;
|
|
177
183
|
createHousehold(
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
data: CreateHouseholdPayload,
|
|
185
|
+
mpQuery?: MPCreateQuery
|
|
180
186
|
): Promise<Household | { error: ErrorDetails; }>;
|
|
181
187
|
createAddress(
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
data: CreateAddressPayload,
|
|
189
|
+
mpQuery?: MPCreateQuery
|
|
184
190
|
): Promise<Address | { error: ErrorDetails; }>;
|
|
185
191
|
createParticipant(
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
data: CreateParticipantPayload,
|
|
193
|
+
mpQuery?: MPCreateQuery
|
|
188
194
|
): Promise<Participant | { error: ErrorDetails; }>;
|
|
189
195
|
createEventParticipant(
|
|
190
|
-
|
|
191
|
-
|
|
196
|
+
data: CreateEventParticipantPayload,
|
|
197
|
+
mpQuery?: MPCreateQuery
|
|
192
198
|
): Promise<EventParticipant | { error: ErrorDetails; }>;
|
|
193
199
|
createGroupParticipant(
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
data: CreateGroupParticipantPayload,
|
|
201
|
+
mpQuery?: MPCreateQuery
|
|
196
202
|
): Promise<GroupParticipant | { error: ErrorDetails; }>;
|
|
197
203
|
createContactAttribute(
|
|
198
|
-
|
|
199
|
-
|
|
204
|
+
data: CreateContactAttributePayload,
|
|
205
|
+
mpQuery?: MPCreateQuery
|
|
200
206
|
): Promise<ContactAttribute | { error: ErrorDetails; }>;
|
|
201
207
|
createFormResponse(
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
data: CreateFormResponsePayload,
|
|
209
|
+
mpQuery?: MPCreateQuery
|
|
204
210
|
): Promise<FormResponse | { error: ErrorDetails; }>;
|
|
205
211
|
createFormResponseAnswers(
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
data: CreateFormResponseAnswerPayload[],
|
|
213
|
+
mpQuery?: MPCreateQuery
|
|
208
214
|
): Promise<FormResponseAnswer[] | { error: ErrorDetails; }>;
|
|
209
215
|
createContactEmailAddress(
|
|
210
|
-
|
|
211
|
-
|
|
216
|
+
data: CreateContactEmailAddressPayload[],
|
|
217
|
+
mpQuery?: MPCreateQuery
|
|
212
218
|
): Promise<ContactEmailAddress[] | { error: ErrorDetails; }>;
|
|
213
219
|
|
|
214
220
|
updateContacts(
|
|
215
221
|
contacts: WithRequired<Partial<Contact>, 'contactID'>[],
|
|
216
|
-
|
|
222
|
+
mpQuery?: MPUpdateQuery
|
|
217
223
|
): Promise<Contact[] | { error: ErrorDetails; }>;
|
|
218
224
|
updateHouseholds(
|
|
219
225
|
households: WithRequired<Partial<Household>, 'householdID'>[],
|
|
220
|
-
|
|
226
|
+
mpQuery?: MPUpdateQuery
|
|
221
227
|
): Promise<Household[] | { error: ErrorDetails; }>;
|
|
222
228
|
updateEventParticipants(
|
|
223
229
|
participants: WithRequired<Partial<EventParticipant>, 'eventParticipantID'>[],
|
|
224
|
-
|
|
230
|
+
mpQuery?: MPUpdateQuery
|
|
225
231
|
): Promise<EventParticipant[] | { error: ErrorDetails; }>;
|
|
226
232
|
updateGroupParticipants(
|
|
227
233
|
participants: WithRequired<Partial<GroupParticipant>, 'groupParticipantID'>[],
|
|
228
|
-
|
|
234
|
+
mpQuery?: MPUpdateQuery
|
|
229
235
|
): Promise<GroupParticipant[] | { error: ErrorDetails; }>;
|
|
230
236
|
updateFormResponseAnswers(
|
|
231
237
|
participants: WithRequired<Partial<FormResponseAnswer>, 'formResponseAnswerID'>[],
|
|
232
|
-
|
|
238
|
+
mpQuery?: MPUpdateQuery
|
|
233
239
|
): Promise<FormResponseAnswer[] | { error: ErrorDetails; }>;
|
|
240
|
+
|
|
241
|
+
getFiles(table: string, recordId: number, mpQuery?: MPGetQuery)
|
|
242
|
+
: Promise<AttachedFile[] | { error: ErrorDetails; }>;
|
|
243
|
+
uploadFiles(table: string, recordId: number, data: CreateFilePayload[])
|
|
244
|
+
: Promise<AttachedFile | { error: ErrorDetails; }>;
|
|
245
|
+
updateFiles(table: string, fileId: number, data: WithRequired<Partial<AttachedFile>, 'FileId'>[])
|
|
246
|
+
: Promise<AttachedFile[] | { error: ErrorDetails; }>;
|
|
234
247
|
};
|
|
235
248
|
|
|
236
249
|
|
|
237
250
|
export const createMPInstance = ({ auth }: { auth: { username: string; password: string; }; }): MPInstance => {
|
|
238
251
|
|
|
239
|
-
const { getOne, getMany, createOne, createMany,
|
|
252
|
+
const { getOne, getMany, createOne, createMany, updateMany, createFile, updateFile, get, post, put } = createApiBase({ auth });
|
|
240
253
|
|
|
241
254
|
return {
|
|
255
|
+
get,
|
|
256
|
+
post,
|
|
257
|
+
put,
|
|
242
258
|
getOne,
|
|
243
259
|
getMany,
|
|
244
260
|
createOne,
|
|
245
261
|
createMany,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
262
|
+
updateMany,
|
|
263
|
+
createFile,
|
|
264
|
+
updateFile,
|
|
265
|
+
async getContact(id, mpQuery = {}) {
|
|
266
|
+
return getOne<Contact>(
|
|
267
|
+
{ path: `/tables/contacts`, id, mpQuery }
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
async getContactDetails(id, mpQuery) {
|
|
271
|
+
return getOne<ContactDetails>(
|
|
272
|
+
{
|
|
273
|
+
path: `/tables/contacts`, id,
|
|
274
|
+
mpQuery: {
|
|
275
|
+
...mpQuery,
|
|
276
|
+
select: 'Contacts.*, Participant_Record_Table.*, Household_ID_Table.*, Gender_ID_Table.Gender, Participant_Record_Table_Member_Status_ID_Table.Member_Status, Participant_Record_Table_Participant_Type_ID_Table.Participant_Type, Marital_Status_ID_Table.Marital_Status, dp_fileUniqueId as Image_ID'
|
|
277
|
+
}
|
|
260
278
|
}
|
|
261
279
|
);
|
|
262
280
|
},
|
|
263
|
-
async getContactAttribute(id,
|
|
264
|
-
return getOne<
|
|
265
|
-
{ path: `/tables/contact_attributes`, id,
|
|
281
|
+
async getContactAttribute(id, mpQuery = {}) {
|
|
282
|
+
return getOne<ContactAttribute>(
|
|
283
|
+
{ path: `/tables/contact_attributes`, id, mpQuery }
|
|
266
284
|
);
|
|
267
285
|
},
|
|
268
|
-
async getContactEmailAddress(id,
|
|
269
|
-
return getOne<
|
|
270
|
-
{ path: `/tables/contact_email_addresses`, id,
|
|
286
|
+
async getContactEmailAddress(id, mpQuery = {}) {
|
|
287
|
+
return getOne<ContactEmailAddress>(
|
|
288
|
+
{ path: `/tables/contact_email_addresses`, id, mpQuery }
|
|
271
289
|
);
|
|
272
290
|
},
|
|
273
|
-
async getHousehold(id,
|
|
274
|
-
return getOne<
|
|
275
|
-
{ path: `/tables/households`, id,
|
|
291
|
+
async getHousehold(id, mpQuery = {}) {
|
|
292
|
+
return getOne<Household>(
|
|
293
|
+
{ path: `/tables/households`, id, mpQuery }
|
|
276
294
|
);
|
|
277
295
|
},
|
|
278
|
-
async getAddress(id,
|
|
279
|
-
return getOne<
|
|
280
|
-
{ path: `/tables/addresses`, id,
|
|
296
|
+
async getAddress(id, mpQuery = {}) {
|
|
297
|
+
return getOne<Address>(
|
|
298
|
+
{ path: `/tables/addresses`, id, mpQuery }
|
|
281
299
|
);
|
|
282
300
|
},
|
|
283
|
-
async getParticipant(id,
|
|
284
|
-
return getOne<
|
|
285
|
-
{ path: `/tables/participants`, id,
|
|
301
|
+
async getParticipant(id, mpQuery = {}) {
|
|
302
|
+
return getOne<Participant>(
|
|
303
|
+
{ path: `/tables/participants`, id, mpQuery }
|
|
286
304
|
);
|
|
287
305
|
},
|
|
288
|
-
async getEvent(id,
|
|
289
|
-
return getOne<
|
|
290
|
-
{ path: `/tables/events`, id,
|
|
306
|
+
async getEvent(id, mpQuery = {}) {
|
|
307
|
+
return getOne<Event>(
|
|
308
|
+
{ path: `/tables/events`, id, mpQuery }
|
|
291
309
|
);
|
|
292
310
|
},
|
|
293
|
-
async getGroup(id,
|
|
294
|
-
return getOne<
|
|
295
|
-
{ path: `/tables/groups`, id,
|
|
311
|
+
async getGroup(id, mpQuery = {}) {
|
|
312
|
+
return getOne<Group>(
|
|
313
|
+
{ path: `/tables/groups`, id, mpQuery }
|
|
296
314
|
);
|
|
297
315
|
},
|
|
298
|
-
async getEventParticipant(id,
|
|
299
|
-
return getOne<
|
|
300
|
-
{ path: `/tables/event_participants`, id,
|
|
316
|
+
async getEventParticipant(id, mpQuery = {}) {
|
|
317
|
+
return getOne<EventParticipant>(
|
|
318
|
+
{ path: `/tables/event_participants`, id, mpQuery }
|
|
301
319
|
);
|
|
302
320
|
},
|
|
303
|
-
async getGroupParticipant(id,
|
|
304
|
-
return getOne<
|
|
305
|
-
{ path: `/tables/group_participants`, id,
|
|
321
|
+
async getGroupParticipant(id, mpQuery = {}) {
|
|
322
|
+
return getOne<GroupParticipant>(
|
|
323
|
+
{ path: `/tables/group_participants`, id, mpQuery }
|
|
306
324
|
);
|
|
307
325
|
},
|
|
308
|
-
async getFormResponse(id,
|
|
309
|
-
return getOne<
|
|
310
|
-
{ path: `/tables/form_responses`, id,
|
|
326
|
+
async getFormResponse(id, mpQuery = {}) {
|
|
327
|
+
return getOne<FormResponse>(
|
|
328
|
+
{ path: `/tables/form_responses`, id, mpQuery }
|
|
311
329
|
);
|
|
312
330
|
},
|
|
313
|
-
async getContacts(
|
|
314
|
-
return getMany<
|
|
315
|
-
{ path: `/tables/contacts`,
|
|
331
|
+
async getContacts(mpQuery) {
|
|
332
|
+
return getMany<Contact>(
|
|
333
|
+
{ path: `/tables/contacts`, mpQuery }
|
|
316
334
|
);
|
|
317
335
|
},
|
|
318
|
-
async getContactAttributes(
|
|
319
|
-
return getMany<
|
|
320
|
-
{ path: `/tables/contact_attributes`,
|
|
336
|
+
async getContactAttributes(mpQuery) {
|
|
337
|
+
return getMany<ContactAttribute>(
|
|
338
|
+
{ path: `/tables/contact_attributes`, mpQuery }
|
|
321
339
|
);
|
|
322
340
|
},
|
|
323
|
-
async getContactsWithAttributes(
|
|
324
|
-
return getMany<
|
|
325
|
-
{
|
|
326
|
-
|
|
341
|
+
async getContactsWithAttributes(mpQuery) {
|
|
342
|
+
return getMany<ContactWithAttribute>(
|
|
343
|
+
{
|
|
344
|
+
path: `/tables/contact_attributes`,
|
|
345
|
+
mpQuery: { ...mpQuery, select: 'Contact_ID_Table.*, Contact_Attributes.*' }
|
|
327
346
|
}
|
|
328
347
|
);
|
|
329
348
|
},
|
|
330
|
-
async getContactEmailAddresses(
|
|
331
|
-
return getMany<
|
|
332
|
-
{ path: `/tables/contact_email_addresses`,
|
|
349
|
+
async getContactEmailAddresses(mpQuery) {
|
|
350
|
+
return getMany<ContactEmailAddress>(
|
|
351
|
+
{ path: `/tables/contact_email_addresses`, mpQuery }
|
|
333
352
|
);
|
|
334
353
|
},
|
|
335
|
-
async getContactsWithEmailAddress(
|
|
336
|
-
return getMany<
|
|
337
|
-
{
|
|
338
|
-
|
|
339
|
-
|
|
354
|
+
async getContactsWithEmailAddress(mpQuery) {
|
|
355
|
+
return getMany<ContactWithEmailAddress>(
|
|
356
|
+
{
|
|
357
|
+
path: `/tables/contact_email_addresses`,
|
|
358
|
+
mpQuery: {
|
|
359
|
+
...mpQuery,
|
|
360
|
+
select: 'Contact_ID_Table.*, Contact_Email_Addresses.Email_Address As Alternate_Email, Contact_Email_Addresses.*'
|
|
361
|
+
}
|
|
340
362
|
}
|
|
341
363
|
);
|
|
342
364
|
},
|
|
343
|
-
async getHouseholds(
|
|
344
|
-
return getMany<
|
|
345
|
-
{ path: `/tables/households`,
|
|
365
|
+
async getHouseholds(mpQuery) {
|
|
366
|
+
return getMany<Household>(
|
|
367
|
+
{ path: `/tables/households`, mpQuery }
|
|
346
368
|
);
|
|
347
369
|
},
|
|
348
|
-
async getAddresses(
|
|
349
|
-
return getMany<
|
|
350
|
-
{ path: `/tables/addresses`,
|
|
370
|
+
async getAddresses(mpQuery) {
|
|
371
|
+
return getMany<Address>(
|
|
372
|
+
{ path: `/tables/addresses`, mpQuery }
|
|
351
373
|
);
|
|
352
374
|
},
|
|
353
|
-
async getParticipants(
|
|
354
|
-
return getMany<
|
|
355
|
-
{ path: `/tables/participants`,
|
|
375
|
+
async getParticipants(mpQuery) {
|
|
376
|
+
return getMany<Participant>(
|
|
377
|
+
{ path: `/tables/participants`, mpQuery }
|
|
356
378
|
);
|
|
357
379
|
},
|
|
358
|
-
async getEvents(
|
|
359
|
-
return getMany<
|
|
360
|
-
{ path: `/tables/events`,
|
|
380
|
+
async getEvents(mpQuery) {
|
|
381
|
+
return getMany<Event>(
|
|
382
|
+
{ path: `/tables/events`, mpQuery }
|
|
361
383
|
);
|
|
362
384
|
},
|
|
363
|
-
async getGroups(
|
|
364
|
-
return getMany<
|
|
365
|
-
{ path: `/tables/groups`,
|
|
385
|
+
async getGroups(mpQuery) {
|
|
386
|
+
return getMany<Group>(
|
|
387
|
+
{ path: `/tables/groups`, mpQuery }
|
|
366
388
|
);
|
|
367
389
|
},
|
|
368
|
-
async getEventParticipants(
|
|
369
|
-
return getMany<
|
|
370
|
-
{ path: `/tables/event_participants`,
|
|
390
|
+
async getEventParticipants(mpQuery) {
|
|
391
|
+
return getMany<EventParticipant>(
|
|
392
|
+
{ path: `/tables/event_participants`, mpQuery }
|
|
371
393
|
);
|
|
372
394
|
},
|
|
373
|
-
async getGroupParticipants(
|
|
374
|
-
return getMany<
|
|
375
|
-
{ path: `/tables/group_participants`,
|
|
395
|
+
async getGroupParticipants(mpQuery) {
|
|
396
|
+
return getMany<GroupParticipant>(
|
|
397
|
+
{ path: `/tables/group_participants`, mpQuery }
|
|
376
398
|
);
|
|
377
399
|
},
|
|
378
|
-
async getFormResponseAnswers(
|
|
379
|
-
return getMany<
|
|
380
|
-
{ path: `/tables/form_response_answers`,
|
|
400
|
+
async getFormResponseAnswers(mpQuery) {
|
|
401
|
+
return getMany<FormResponseAnswer>(
|
|
402
|
+
{ path: `/tables/form_response_answers`, mpQuery }
|
|
381
403
|
);
|
|
382
404
|
},
|
|
383
405
|
|
|
384
|
-
async createContact(
|
|
385
|
-
return createOne<
|
|
386
|
-
{ path: `/tables/contacts`,
|
|
406
|
+
async createContact(data, mpQuery = {}) {
|
|
407
|
+
return createOne<Contact>(
|
|
408
|
+
{ path: `/tables/contacts`, mpQuery, data }
|
|
387
409
|
);
|
|
388
410
|
},
|
|
389
|
-
async createHousehold(
|
|
390
|
-
return createOne<
|
|
391
|
-
{ path: `/tables/households`,
|
|
411
|
+
async createHousehold(data, mpQuery) {
|
|
412
|
+
return createOne<Household>(
|
|
413
|
+
{ path: `/tables/households`, mpQuery, data }
|
|
392
414
|
);
|
|
393
415
|
},
|
|
394
|
-
async createAddress(
|
|
395
|
-
return createOne<
|
|
396
|
-
{ path: `/tables/addresses`,
|
|
416
|
+
async createAddress(data, mpQuery) {
|
|
417
|
+
return createOne<Address>(
|
|
418
|
+
{ path: `/tables/addresses`, mpQuery, data }
|
|
397
419
|
);
|
|
398
420
|
},
|
|
399
|
-
async createParticipant(
|
|
400
|
-
return createOne<
|
|
401
|
-
{ path: `/tables/participants`,
|
|
421
|
+
async createParticipant(data, mpQuery) {
|
|
422
|
+
return createOne<Participant>(
|
|
423
|
+
{ path: `/tables/participants`, mpQuery, data }
|
|
402
424
|
);
|
|
403
425
|
},
|
|
404
|
-
async createEventParticipant(
|
|
405
|
-
return createOne<
|
|
406
|
-
{ path: `/tables/event_participants`,
|
|
426
|
+
async createEventParticipant(data, mpQuery) {
|
|
427
|
+
return createOne<EventParticipant>(
|
|
428
|
+
{ path: `/tables/event_participants`, mpQuery, data }
|
|
407
429
|
);
|
|
408
430
|
},
|
|
409
|
-
async createGroupParticipant(
|
|
410
|
-
return createOne<
|
|
411
|
-
{ path: `/tables/group_participants`,
|
|
431
|
+
async createGroupParticipant(data, mpQuery) {
|
|
432
|
+
return createOne<GroupParticipant>(
|
|
433
|
+
{ path: `/tables/group_participants`, mpQuery, data }
|
|
412
434
|
);
|
|
413
435
|
},
|
|
414
|
-
async createContactAttribute(
|
|
415
|
-
return createOne<
|
|
416
|
-
{ path: `/tables/contact_attributes`,
|
|
436
|
+
async createContactAttribute(data, mpQuery) {
|
|
437
|
+
return createOne<ContactAttribute>(
|
|
438
|
+
{ path: `/tables/contact_attributes`, mpQuery, data }
|
|
417
439
|
);
|
|
418
440
|
},
|
|
419
|
-
async createFormResponse(
|
|
420
|
-
return createOne<
|
|
421
|
-
{ path: `/tables/form_responses`,
|
|
441
|
+
async createFormResponse(data: CreateFormResponsePayload, mpQuery) {
|
|
442
|
+
return createOne<FormResponse>(
|
|
443
|
+
{ path: `/tables/form_responses`, mpQuery, data }
|
|
422
444
|
);
|
|
423
445
|
},
|
|
424
|
-
async createFormResponseAnswers(
|
|
425
|
-
return createMany<
|
|
426
|
-
{ path: `/tables/form_response_answers`,
|
|
446
|
+
async createFormResponseAnswers(data, mpQuery) {
|
|
447
|
+
return createMany<FormResponseAnswer>(
|
|
448
|
+
{ path: `/tables/form_response_answers`, mpQuery, data }
|
|
427
449
|
);
|
|
428
450
|
},
|
|
429
|
-
async createContactEmailAddress(
|
|
430
|
-
return createMany<
|
|
431
|
-
{ path: `/tables/contact_email_addresses`,
|
|
451
|
+
async createContactEmailAddress(data, mpQuery) {
|
|
452
|
+
return createMany<ContactEmailAddress>(
|
|
453
|
+
{ path: `/tables/contact_email_addresses`, mpQuery, data }
|
|
432
454
|
);
|
|
433
455
|
},
|
|
434
|
-
async updateContacts(
|
|
435
|
-
return
|
|
436
|
-
{ path: `/tables/contacts`,
|
|
456
|
+
async updateContacts(data, mpQuery) {
|
|
457
|
+
return updateMany<Contact>(
|
|
458
|
+
{ path: `/tables/contacts`, mpQuery, data }
|
|
437
459
|
);
|
|
438
460
|
},
|
|
439
|
-
async updateHouseholds(
|
|
440
|
-
return
|
|
441
|
-
{ path: `/tables/households`,
|
|
461
|
+
async updateHouseholds(data, mpQuery) {
|
|
462
|
+
return updateMany<Household>(
|
|
463
|
+
{ path: `/tables/households`, mpQuery, data }
|
|
442
464
|
);
|
|
443
465
|
},
|
|
444
|
-
async updateEventParticipants(
|
|
445
|
-
return
|
|
446
|
-
{ path: `/tables/event_participants`,
|
|
466
|
+
async updateEventParticipants(data, mpQuery) {
|
|
467
|
+
return updateMany<EventParticipant>(
|
|
468
|
+
{ path: `/tables/event_participants`, mpQuery, data }
|
|
469
|
+
);
|
|
470
|
+
},
|
|
471
|
+
async updateGroupParticipants(data, mpQuery) {
|
|
472
|
+
return updateMany<GroupParticipant>(
|
|
473
|
+
{ path: `/tables/group_participants`, mpQuery, data }
|
|
474
|
+
);
|
|
475
|
+
},
|
|
476
|
+
async updateFormResponseAnswers(data, mpQuery) {
|
|
477
|
+
return updateMany<FormResponseAnswer>(
|
|
478
|
+
{ path: `/tables/form_response_answers`, mpQuery, data }
|
|
479
|
+
);
|
|
480
|
+
},
|
|
481
|
+
|
|
482
|
+
async getFiles(table, recordId) {
|
|
483
|
+
return getMany<AttachedFile>(
|
|
484
|
+
{ path: `/files/${table}/${recordId}`, mpQuery: {} }
|
|
447
485
|
);
|
|
448
486
|
},
|
|
449
|
-
async
|
|
450
|
-
return
|
|
451
|
-
{ path: `/
|
|
487
|
+
async uploadFiles(table, recordId, data) {
|
|
488
|
+
return createFile<AttachedFile>(
|
|
489
|
+
{ path: `/files/${table}/${recordId}`, data }
|
|
452
490
|
);
|
|
453
491
|
},
|
|
454
|
-
async
|
|
455
|
-
return
|
|
456
|
-
{ path: `/
|
|
492
|
+
async updateFiles(table, fileId, data) {
|
|
493
|
+
return updateMany<AttachedFile>(
|
|
494
|
+
{ path: `/files/${table}/${fileId}`, data }
|
|
457
495
|
);
|
|
458
496
|
},
|
|
459
497
|
};
|