mp-js-api 0.0.3 → 0.0.5
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/dist/api.d.ts +74 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +158 -0
- package/dist/index.d.ts +56 -48
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -306
- package/dist/tables/addresses.d.ts +0 -2
- package/dist/tables/addresses.d.ts.map +1 -1
- package/dist/tables/addresses.js +0 -58
- package/dist/tables/contact-attributes.d.ts +0 -2
- package/dist/tables/contact-attributes.d.ts.map +1 -1
- package/dist/tables/contact-attributes.js +0 -22
- package/dist/tables/contacts.d.ts +0 -2
- package/dist/tables/contacts.d.ts.map +1 -1
- package/dist/tables/contacts.js +0 -112
- package/dist/tables/event-participants.d.ts +0 -2
- package/dist/tables/event-participants.d.ts.map +1 -1
- package/dist/tables/event-participants.js +0 -50
- package/dist/tables/events.d.ts +0 -2
- package/dist/tables/events.d.ts.map +1 -1
- package/dist/tables/events.js +0 -120
- package/dist/tables/form-responses.d.ts +49 -0
- package/dist/tables/form-responses.d.ts.map +1 -0
- package/dist/tables/form-responses.js +2 -0
- package/dist/tables/from-response-answers.d.ts +21 -0
- package/dist/tables/from-response-answers.d.ts.map +1 -0
- package/dist/tables/from-response-answers.js +2 -0
- package/dist/tables/group-participants.d.ts +0 -2
- package/dist/tables/group-participants.d.ts.map +1 -1
- package/dist/tables/group-participants.js +0 -64
- package/dist/tables/groups.d.ts +0 -2
- package/dist/tables/groups.d.ts.map +1 -1
- package/dist/tables/groups.js +0 -106
- package/dist/tables/households.d.ts +0 -2
- package/dist/tables/households.d.ts.map +1 -1
- package/dist/tables/households.js +0 -58
- package/dist/tables/participants.d.ts +0 -2
- package/dist/tables/participants.d.ts.map +1 -1
- package/dist/tables/participants.js +0 -66
- package/dist/utils/strings.d.ts +14 -0
- package/dist/utils/strings.d.ts.map +1 -1
- package/dist/utils/strings.js +54 -0
- package/package.json +1 -1
- package/src/api.ts +266 -0
- package/src/index.ts +207 -424
- package/src/tables/addresses.ts +1 -59
- package/src/tables/contact-attributes.ts +0 -23
- package/src/tables/contacts.ts +0 -118
- package/src/tables/event-participants.ts +1 -51
- package/src/tables/events.ts +0 -119
- package/src/tables/form-responses.ts +51 -0
- package/src/tables/from-response-answers.ts +23 -0
- package/src/tables/group-participants.ts +55 -119
- package/src/tables/groups.ts +1 -107
- package/src/tables/households.ts +0 -58
- package/src/tables/participants.ts +1 -67
- package/src/utils/strings.ts +60 -1
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
export type APIGetOneInstance = <T, R>({ id, path, mpOptions, config }: APIGetParameter & {
|
|
3
|
+
id: number;
|
|
4
|
+
}) => Promise<R | undefined | {
|
|
5
|
+
error: ErrorDetails;
|
|
6
|
+
}>;
|
|
7
|
+
export type APIGetMultipleInstance = <T, R>({ path, mpOptions, config }: APIGetParameter) => Promise<R[] | {
|
|
8
|
+
error: ErrorDetails;
|
|
9
|
+
}>;
|
|
10
|
+
export type APICreateInstance = <T, R>({ path, mpOptions, params, config }: APICreateParameter<T>) => Promise<R | {
|
|
11
|
+
error: ErrorDetails;
|
|
12
|
+
}>;
|
|
13
|
+
export type APIUpdateInstance = <T, R>({ path, mpOptions, params, config }: APIUpdateParameter<T>) => Promise<R[] | {
|
|
14
|
+
error: ErrorDetails;
|
|
15
|
+
}>;
|
|
16
|
+
export interface MPApiBase {
|
|
17
|
+
getOne: APIGetOneInstance;
|
|
18
|
+
getMultiple: APIGetMultipleInstance;
|
|
19
|
+
create: APICreateInstance;
|
|
20
|
+
update: APIUpdateInstance;
|
|
21
|
+
get: AxiosInstance['get'];
|
|
22
|
+
post: AxiosInstance['post'];
|
|
23
|
+
put: AxiosInstance['put'];
|
|
24
|
+
getError: (error: AxiosError) => ErrorDetails;
|
|
25
|
+
}
|
|
26
|
+
export interface ErrorDetails {
|
|
27
|
+
message: string;
|
|
28
|
+
name: string;
|
|
29
|
+
code?: string;
|
|
30
|
+
status?: number;
|
|
31
|
+
method?: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
data: string;
|
|
34
|
+
error: true;
|
|
35
|
+
}
|
|
36
|
+
export declare const createApiBase: ({ auth }: {
|
|
37
|
+
auth: {
|
|
38
|
+
username: string;
|
|
39
|
+
password: string;
|
|
40
|
+
};
|
|
41
|
+
}) => MPApiBase;
|
|
42
|
+
export type MPGetOptions = {
|
|
43
|
+
select?: string;
|
|
44
|
+
filter?: string;
|
|
45
|
+
orderBy?: string;
|
|
46
|
+
groupBy?: string;
|
|
47
|
+
top?: number;
|
|
48
|
+
skip?: number;
|
|
49
|
+
distinct?: boolean;
|
|
50
|
+
};
|
|
51
|
+
export type MPCreateOptions = {
|
|
52
|
+
userId?: number;
|
|
53
|
+
select?: string;
|
|
54
|
+
};
|
|
55
|
+
export type MPUpdateOptions = MPCreateOptions;
|
|
56
|
+
interface APIGetParameter {
|
|
57
|
+
path: string;
|
|
58
|
+
mpOptions?: MPGetOptions;
|
|
59
|
+
config?: AxiosRequestConfig;
|
|
60
|
+
}
|
|
61
|
+
interface APICreateParameter<T> {
|
|
62
|
+
path: string;
|
|
63
|
+
params: T;
|
|
64
|
+
mpOptions?: MPCreateOptions;
|
|
65
|
+
config?: AxiosRequestConfig;
|
|
66
|
+
}
|
|
67
|
+
interface APIUpdateParameter<T> {
|
|
68
|
+
path: string;
|
|
69
|
+
params: T[];
|
|
70
|
+
mpOptions?: MPCreateOptions;
|
|
71
|
+
config?: AxiosRequestConfig;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MA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;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,UAAU,kBAAkB,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createApiBase = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
const strings_1 = require("./utils/strings");
|
|
10
|
+
const createTokenGetter = (auth) => {
|
|
11
|
+
let token;
|
|
12
|
+
return async () => {
|
|
13
|
+
// If the token is near expiration, get a new one.
|
|
14
|
+
if (!token || token.expiration - 60000 < Date.now()) {
|
|
15
|
+
const tokenRes = await axios_1.default.post('https://mp.revival.com/ministryplatformapi/oauth/connect/token', new url_1.URLSearchParams({
|
|
16
|
+
grant_type: 'client_credentials',
|
|
17
|
+
scope: 'http://www.thinkministry.com/dataplatform/scopes/all',
|
|
18
|
+
}).toString(), { auth });
|
|
19
|
+
const [, payload] = tokenRes.data.access_token.split('.');
|
|
20
|
+
try {
|
|
21
|
+
const jsonPayload = JSON.parse(Buffer.from(payload, 'base64url').toString());
|
|
22
|
+
token = {
|
|
23
|
+
digest: tokenRes.data.access_token,
|
|
24
|
+
expiration: jsonPayload.exp * 1000,
|
|
25
|
+
};
|
|
26
|
+
return token.digest;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
console.error(err);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return token.digest;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const createApiBase = ({ auth }) => {
|
|
38
|
+
/**
|
|
39
|
+
* Gets MP oauth token.
|
|
40
|
+
* @returns token
|
|
41
|
+
*/
|
|
42
|
+
const getToken = createTokenGetter(auth);
|
|
43
|
+
const api = axios_1.default.create({
|
|
44
|
+
baseURL: 'https://mp.revival.com/ministryplatformapi',
|
|
45
|
+
});
|
|
46
|
+
const getOne = async ({ id, path, mpOptions, config }) => {
|
|
47
|
+
try {
|
|
48
|
+
const url = `${path}/${id}` + (0, strings_1.stringifyURLParams)(mpOptions);
|
|
49
|
+
const res = await api.get(url, {
|
|
50
|
+
...config,
|
|
51
|
+
headers: {
|
|
52
|
+
...config?.headers,
|
|
53
|
+
Authorization: `Bearer ${await getToken()}`,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return res.data[0] ? (0, strings_1.convertToCamelCase)(res.data[0]) : undefined;
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
return { error: getError(err) };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const getMultiple = async ({ path, mpOptions, config }) => {
|
|
63
|
+
try {
|
|
64
|
+
const url = path + (0, strings_1.stringifyURLParams)(mpOptions);
|
|
65
|
+
const res = await api.get(url, {
|
|
66
|
+
...config,
|
|
67
|
+
headers: {
|
|
68
|
+
...config?.headers,
|
|
69
|
+
Authorization: `Bearer ${await getToken()}`,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
return res.data.map(record => (0, strings_1.convertToCamelCase)(record));
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return { error: getError(err) };
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const create = async ({ path, mpOptions, params, config }) => {
|
|
79
|
+
const query = (0, strings_1.stringifyURLParams)(mpOptions);
|
|
80
|
+
const data = [(0, strings_1.convertToSnakeCase)(params)];
|
|
81
|
+
try {
|
|
82
|
+
const res = await api.post(path + query, data, {
|
|
83
|
+
...config,
|
|
84
|
+
headers: {
|
|
85
|
+
...config?.headers,
|
|
86
|
+
Authorization: `Bearer ${await getToken()}`,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
return (0, strings_1.convertToCamelCase)(res.data[0]);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
return { error: getError(err) };
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const update = async ({ path, mpOptions, params, config }) => {
|
|
96
|
+
const query = (0, strings_1.stringifyURLParams)(mpOptions);
|
|
97
|
+
const data = params.map(r => (0, strings_1.convertToSnakeCase)(r));
|
|
98
|
+
try {
|
|
99
|
+
const res = await api.put(path + query, data, {
|
|
100
|
+
...config,
|
|
101
|
+
headers: {
|
|
102
|
+
...config?.headers,
|
|
103
|
+
Authorization: `Bearer ${await getToken()}`,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
return res.data.map(record => (0, strings_1.convertToCamelCase)(record));
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
return { error: getError(err) };
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const get = async (url, config) => api.get(url, {
|
|
113
|
+
...config,
|
|
114
|
+
headers: {
|
|
115
|
+
...config?.headers,
|
|
116
|
+
Authorization: `Bearer ${await getToken()}`,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
const post = async (url, data, config) => api.post(url, data, {
|
|
120
|
+
...config,
|
|
121
|
+
headers: {
|
|
122
|
+
...config?.headers,
|
|
123
|
+
Authorization: `Bearer ${await getToken()}`,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
const put = async (url, data, config) => api.put(url, data, {
|
|
127
|
+
...config,
|
|
128
|
+
headers: {
|
|
129
|
+
...config?.headers,
|
|
130
|
+
Authorization: `Bearer ${await getToken()}`,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const getError = function (error) {
|
|
134
|
+
return {
|
|
135
|
+
error: true,
|
|
136
|
+
message: error.message,
|
|
137
|
+
name: error.name,
|
|
138
|
+
code: error.code,
|
|
139
|
+
status: error.status,
|
|
140
|
+
method: error.config?.method,
|
|
141
|
+
url: error.config?.url,
|
|
142
|
+
data: error.config?.data
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
create,
|
|
147
|
+
update,
|
|
148
|
+
get,
|
|
149
|
+
put,
|
|
150
|
+
post,
|
|
151
|
+
getOne,
|
|
152
|
+
getMultiple,
|
|
153
|
+
getError
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
exports.createApiBase = createApiBase;
|
|
157
|
+
;
|
|
158
|
+
;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,113 +1,121 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MPApiBase, ErrorDetails, MPGetOptions, MPCreateOptions, MPUpdateOptions } from './api';
|
|
2
|
+
import { convertToCamelCase, convertToSnakeCase, escapeSql, stringifyURLParams } from './utils/strings';
|
|
2
3
|
import { Contact } from './tables/contacts';
|
|
3
|
-
import { Participant } from './tables/participants';
|
|
4
|
-
import { EventParticipant } from './tables/event-participants';
|
|
5
|
-
import { GroupParticipant } from './tables/group-participants';
|
|
6
4
|
import { Event } from './tables/events';
|
|
7
5
|
import { Group } from './tables/groups';
|
|
8
|
-
import { Household } from './tables/households';
|
|
9
6
|
import { Address } from './tables/addresses';
|
|
7
|
+
import { Household } from './tables/households';
|
|
8
|
+
import { Participant } from './tables/participants';
|
|
9
|
+
import { EventParticipant } from './tables/event-participants';
|
|
10
|
+
import { GroupParticipant } from './tables/group-participants';
|
|
10
11
|
import { ContactAttribute } from './tables/contact-attributes';
|
|
12
|
+
import { FormResponse } from './tables/form-responses';
|
|
13
|
+
import { FormResponseAnswer } from './tables/from-response-answers';
|
|
14
|
+
import { AxiosInstance } from 'axios';
|
|
11
15
|
type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
12
|
-
export type CreateContactParams = WithRequired<Partial<Contact>, 'company' | 'displayName'>;
|
|
16
|
+
export type CreateContactParams = WithRequired<Omit<Partial<Contact>, 'contactID'>, 'company' | 'displayName'>;
|
|
13
17
|
export type CreateHouseholdParams = WithRequired<Partial<Household>, 'householdName'>;
|
|
14
18
|
export type CreateAddressParams = WithRequired<Partial<Address>, 'addressLine1'>;
|
|
15
19
|
export type CreateParticipantParams = WithRequired<Partial<Participant>, 'contactID' | 'participantTypeID' | 'participantStartDate'>;
|
|
16
20
|
export type CreateEventParticipantParams = WithRequired<Partial<EventParticipant>, 'eventID' | 'participantID' | 'participationStatusID'>;
|
|
17
21
|
export type CreateGroupParticipantParams = WithRequired<Partial<GroupParticipant>, 'groupID' | 'participantID' | 'groupRoleID' | 'startDate'>;
|
|
18
22
|
export type CreateContactAttributeParams = WithRequired<Partial<ContactAttribute>, 'attributeID' | 'contactID' | 'startDate'>;
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
filter?: string;
|
|
22
|
-
orderBy?: string;
|
|
23
|
-
groupBy?: string;
|
|
24
|
-
top?: number;
|
|
25
|
-
skip?: number;
|
|
26
|
-
distinct?: boolean;
|
|
27
|
-
};
|
|
28
|
-
export type MPCreateOptions = {
|
|
29
|
-
user?: number;
|
|
30
|
-
};
|
|
31
|
-
export type MPUpdateOptions = MPCreateOptions;
|
|
32
|
-
export type MPGetInstance = <T = any, R = AxiosResponse<T, any>>(url: string, mpOptions?: MPGetOptions, config?: AxiosRequestConfig) => Promise<R>;
|
|
23
|
+
export type CreateFormResponseParams = WithRequired<Omit<Partial<FormResponse>, 'formResponseID'>, 'formID' | 'responseDate'>;
|
|
24
|
+
export type CreateFormResponseAnswerParams = WithRequired<Omit<Partial<FormResponseAnswer>, 'formResponseAnswerID'>, 'formFieldID' | 'formResponseID'>;
|
|
33
25
|
export type MPInstance = {
|
|
34
|
-
get:
|
|
35
|
-
post: AxiosInstance['post'];
|
|
26
|
+
get: AxiosInstance['get'];
|
|
36
27
|
put: AxiosInstance['put'];
|
|
28
|
+
post: AxiosInstance['post'];
|
|
29
|
+
create: MPApiBase['create'];
|
|
30
|
+
update: MPApiBase['update'];
|
|
31
|
+
getOne: MPApiBase['getOne'];
|
|
32
|
+
getMultiple: MPApiBase['getMultiple'];
|
|
37
33
|
getContact(id: number, options?: MPGetOptions): Promise<Contact | undefined | {
|
|
38
|
-
error:
|
|
34
|
+
error: ErrorDetails;
|
|
39
35
|
}>;
|
|
40
36
|
getHousehold(id: number, options?: MPGetOptions): Promise<Household | undefined | {
|
|
41
|
-
error:
|
|
37
|
+
error: ErrorDetails;
|
|
42
38
|
}>;
|
|
43
39
|
getAddress(id: number, options?: MPGetOptions): Promise<Address | undefined | {
|
|
44
|
-
error:
|
|
40
|
+
error: ErrorDetails;
|
|
45
41
|
}>;
|
|
46
42
|
getParticipant(id: number, options?: MPGetOptions): Promise<Participant | undefined | {
|
|
47
|
-
error:
|
|
43
|
+
error: ErrorDetails;
|
|
44
|
+
}>;
|
|
45
|
+
getContactAttribute(id: number, options?: MPGetOptions): Promise<ContactAttribute | undefined | {
|
|
46
|
+
error: ErrorDetails;
|
|
48
47
|
}>;
|
|
49
48
|
getEvent(id: number, options?: MPGetOptions): Promise<Event | undefined | {
|
|
50
|
-
error:
|
|
49
|
+
error: ErrorDetails;
|
|
51
50
|
}>;
|
|
52
51
|
getGroup(id: number, options?: MPGetOptions): Promise<Group | undefined | {
|
|
53
|
-
error:
|
|
52
|
+
error: ErrorDetails;
|
|
54
53
|
}>;
|
|
55
54
|
getEventParticipant(id: number, options?: MPGetOptions): Promise<EventParticipant | undefined | {
|
|
56
|
-
error:
|
|
55
|
+
error: ErrorDetails;
|
|
57
56
|
}>;
|
|
58
57
|
getGroupParticipant(id: number, options?: MPGetOptions): Promise<GroupParticipant | undefined | {
|
|
59
|
-
error:
|
|
58
|
+
error: ErrorDetails;
|
|
59
|
+
}>;
|
|
60
|
+
getFormResponse(id: number, options?: MPGetOptions): Promise<FormResponse | undefined | {
|
|
61
|
+
error: ErrorDetails;
|
|
60
62
|
}>;
|
|
61
63
|
getContacts(options?: MPGetOptions): Promise<Contact[] | {
|
|
62
|
-
error:
|
|
64
|
+
error: ErrorDetails;
|
|
63
65
|
}>;
|
|
64
66
|
getHouseholds(options?: MPGetOptions): Promise<Household[] | {
|
|
65
|
-
error:
|
|
67
|
+
error: ErrorDetails;
|
|
66
68
|
}>;
|
|
67
69
|
getAddresses(options?: MPGetOptions): Promise<Address[] | {
|
|
68
|
-
error:
|
|
70
|
+
error: ErrorDetails;
|
|
69
71
|
}>;
|
|
70
72
|
getParticipants(options?: MPGetOptions): Promise<Participant[] | {
|
|
71
|
-
error:
|
|
73
|
+
error: ErrorDetails;
|
|
72
74
|
}>;
|
|
73
75
|
getEvents(options?: MPGetOptions): Promise<Event[] | {
|
|
74
|
-
error:
|
|
76
|
+
error: ErrorDetails;
|
|
75
77
|
}>;
|
|
76
78
|
getGroups(options?: MPGetOptions): Promise<Group[] | {
|
|
77
|
-
error:
|
|
79
|
+
error: ErrorDetails;
|
|
78
80
|
}>;
|
|
79
81
|
getEventParticipants(options?: MPGetOptions): Promise<EventParticipant[] | {
|
|
80
|
-
error:
|
|
82
|
+
error: ErrorDetails;
|
|
81
83
|
}>;
|
|
82
84
|
getGroupParticipants(options?: MPGetOptions): Promise<GroupParticipant[] | {
|
|
83
|
-
error:
|
|
85
|
+
error: ErrorDetails;
|
|
84
86
|
}>;
|
|
85
87
|
createContact(params: CreateContactParams, options?: MPCreateOptions): Promise<Contact | {
|
|
86
|
-
error:
|
|
88
|
+
error: ErrorDetails;
|
|
87
89
|
}>;
|
|
88
90
|
createHousehold(params: CreateHouseholdParams, options?: MPCreateOptions): Promise<Household | {
|
|
89
|
-
error:
|
|
91
|
+
error: ErrorDetails;
|
|
90
92
|
}>;
|
|
91
93
|
createAddress(params: CreateAddressParams, options?: MPCreateOptions): Promise<Address | {
|
|
92
|
-
error:
|
|
94
|
+
error: ErrorDetails;
|
|
93
95
|
}>;
|
|
94
96
|
createParticipant(params: CreateParticipantParams, options?: MPCreateOptions): Promise<Participant | {
|
|
95
|
-
error:
|
|
97
|
+
error: ErrorDetails;
|
|
96
98
|
}>;
|
|
97
99
|
createEventParticipant(params: CreateEventParticipantParams, options?: MPCreateOptions): Promise<EventParticipant | {
|
|
98
|
-
error:
|
|
100
|
+
error: ErrorDetails;
|
|
99
101
|
}>;
|
|
100
102
|
createGroupParticipant(params: CreateGroupParticipantParams, options?: MPCreateOptions): Promise<GroupParticipant | {
|
|
101
|
-
error:
|
|
103
|
+
error: ErrorDetails;
|
|
102
104
|
}>;
|
|
103
105
|
createContactAttribute(params: CreateContactAttributeParams, options?: MPCreateOptions): Promise<ContactAttribute | {
|
|
104
|
-
error:
|
|
106
|
+
error: ErrorDetails;
|
|
107
|
+
}>;
|
|
108
|
+
createFormResponse(params: CreateFormResponseParams, options?: MPCreateOptions): Promise<FormResponse | {
|
|
109
|
+
error: ErrorDetails;
|
|
110
|
+
}>;
|
|
111
|
+
createFormResponseAnswers(params: CreateFormResponseAnswerParams, options?: MPCreateOptions): Promise<FormResponseAnswer | {
|
|
112
|
+
error: ErrorDetails;
|
|
105
113
|
}>;
|
|
106
114
|
updateContacts(contacts: WithRequired<Partial<Contact>, 'contactID'>[], options?: MPUpdateOptions): Promise<Contact[] | {
|
|
107
|
-
error:
|
|
115
|
+
error: ErrorDetails;
|
|
108
116
|
}>;
|
|
109
117
|
updateEventParticipants(participants: WithRequired<Partial<EventParticipant>, 'eventParticipantID'>[], options?: MPUpdateOptions): Promise<EventParticipant[] | {
|
|
110
|
-
error:
|
|
118
|
+
error: ErrorDetails;
|
|
111
119
|
}>;
|
|
112
120
|
};
|
|
113
121
|
export declare const createMPInstance: ({ auth }: {
|
|
@@ -116,5 +124,5 @@ export declare const createMPInstance: ({ auth }: {
|
|
|
116
124
|
password: string;
|
|
117
125
|
};
|
|
118
126
|
}) => MPInstance;
|
|
119
|
-
export { Contact, Participant, Event, Group, EventParticipant, GroupParticipant, Household, Address,
|
|
127
|
+
export { Contact, Participant, Event, Group, EventParticipant, GroupParticipant, ContactAttribute, Household, Address, FormResponse, ErrorDetails, convertToCamelCase, convertToSnakeCase, stringifyURLParams, escapeSql };
|
|
120
128
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAC/G,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAiB,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAe,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAe,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAiB,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAmB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAA0B,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAA0B,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAA0B,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAsB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,KAAK,YAAY,CAAC,CAAC,EAAE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