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