@openfn/language-mailchimp 0.7.0 → 0.7.1

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.
@@ -2,24 +2,26 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "properties": {
4
4
  "server": {
5
- "title": "Server URL",
5
+ "title": "Data Center",
6
6
  "type": "string",
7
- "description": "Mailchimp API domain URL",
8
- "format": "uri",
9
- "minLength": 1,
7
+ "description": "Mailchimp Data Center for your account",
8
+ "minLength": 3,
10
9
  "examples": [
11
- "https://mailchimp.com/api"
12
- ]
10
+ "us11",
11
+ "uk8",
12
+ "in10"
13
+ ],
14
+ "pattern": "^[a-zA-Z]{2}\\d{1,2}$"
13
15
  },
14
16
  "apiKey": {
15
17
  "title": "API Key",
16
18
  "type": "string",
17
19
  "description": "Mailchimp API Key",
18
- "writeOnly": true,
19
- "minLength": 1,
20
+ "minLength": 32,
20
21
  "examples": [
21
- "somEThINGkeyish"
22
- ]
22
+ "0eb22c7b4a1c5bcd789379bf8a92902d-us13"
23
+ ],
24
+ "pattern": "^[a-zA-Z0-9]{20}-[a-zA-Z]{2}\\d{1,2}$"
23
25
  }
24
26
  },
25
27
  "type": "object",
package/dist/index.cjs CHANGED
@@ -265,7 +265,7 @@ var assertOK = (response, fullUrl) => {
265
265
  throw error;
266
266
  }
267
267
  };
268
- var request = (method, path, options, callback) => {
268
+ function request(method, path, options, callback) {
269
269
  return async (state) => {
270
270
  const apiVersion = "3.0";
271
271
  const { apiKey, server } = state.configuration;
@@ -291,6 +291,7 @@ var request = (method, path, options, callback) => {
291
291
  query,
292
292
  body: body ? JSON.stringify(body) : void 0
293
293
  });
294
+ console.log("Mailchimp says", response.statusCode);
294
295
  const responseBody = await response.body.json();
295
296
  assertOK(responseBody, `https://${server}.api.mailchimp.com${urlPath}`);
296
297
  const nextState = {
@@ -302,9 +303,13 @@ var request = (method, path, options, callback) => {
302
303
  return callback(nextState);
303
304
  return nextState;
304
305
  };
305
- };
306
- var get = (path, query, callback) => request("GET", path, { query }, callback);
307
- var post = (path, body, query, callback) => request("POST", path, { body, query }, callback);
306
+ }
307
+ function get(path, query, callback) {
308
+ return request("GET", path, { query }, callback);
309
+ }
310
+ function post(path, body, query, callback) {
311
+ return request("POST", path, { body, query }, callback);
312
+ }
308
313
 
309
314
  // src/index.js
310
315
  var src_default = Adaptor_exports;
package/dist/index.js CHANGED
@@ -223,7 +223,7 @@ var assertOK = (response, fullUrl) => {
223
223
  throw error;
224
224
  }
225
225
  };
226
- var request = (method, path, options, callback) => {
226
+ function request(method, path, options, callback) {
227
227
  return async (state) => {
228
228
  const apiVersion = "3.0";
229
229
  const { apiKey, server } = state.configuration;
@@ -249,6 +249,7 @@ var request = (method, path, options, callback) => {
249
249
  query,
250
250
  body: body ? JSON.stringify(body) : void 0
251
251
  });
252
+ console.log("Mailchimp says", response.statusCode);
252
253
  const responseBody = await response.body.json();
253
254
  assertOK(responseBody, `https://${server}.api.mailchimp.com${urlPath}`);
254
255
  const nextState = {
@@ -260,9 +261,13 @@ var request = (method, path, options, callback) => {
260
261
  return callback(nextState);
261
262
  return nextState;
262
263
  };
263
- };
264
- var get = (path, query, callback) => request("GET", path, { query }, callback);
265
- var post = (path, body, query, callback) => request("POST", path, { body, query }, callback);
264
+ }
265
+ function get(path, query, callback) {
266
+ return request("GET", path, { query }, callback);
267
+ }
268
+ function post(path, body, query, callback) {
269
+ return request("POST", path, { body, query }, callback);
270
+ }
266
271
 
267
272
  // src/index.js
268
273
  var src_default = Adaptor_exports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-mailchimp",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "An OpenFn adaptor for use with Mailchimp",
5
5
  "main": "dist/index.cjs",
6
6
  "author": "Open Function Group",
@@ -133,8 +133,43 @@ export function listAudiences(query: object, callback?: Function): Operation;
133
133
  * @returns {Operation}
134
134
  */
135
135
  export function listAudienceInfo(query: object, callback?: Function): Operation;
136
+ /**
137
+ * Make an HTTP request to Mailchimp API
138
+ * @example <caption>Get list to all other resources available in the API</caption>
139
+ * request('GET','/');
140
+ * @example <caption>Create a new account export in your Mailchimp account</caption>
141
+ * request('POST','/accounts-export', {include_stages:[]});
142
+ * @function
143
+ * @param {string} method - The HTTP method for the request (e.g., 'GET', 'POST', 'PUT', 'DELETE').
144
+ * @param {string} path - The endpoint of the api to which the request should be made.
145
+ * @param {Object} options - Additional options for the request (query, body only).
146
+ * @param {function} [callback] - (Optional) callback function to handle the response.
147
+ * @returns {Operation}
148
+ */
136
149
  export function request(method: string, path: string, options: any, callback?: Function): Operation;
150
+ /**
151
+ * The get function is used to make a GET request to the Mailchimp API.
152
+ * @example <caption>Get a list of account exports for a given account</caption>
153
+ * get('/account-exports');
154
+ * @function
155
+ * @param {string} path - The endpoint of the api to which the request should be made
156
+ * @param {object} query - An object containing query parameters to be included in the request
157
+ * @param {function} [callback] - (Optional) callback to handle the response
158
+ * @returns {Operation}
159
+ */
137
160
  export function get(path: string, query: object, callback?: Function): Operation;
161
+ /**
162
+ * The post function is used to make a POST request to the Mailchimp API.
163
+ *
164
+ * @example <caption>Create a new account export in your Mailchimp account</caption>
165
+ * post('/accounts-export', {include_stages:[]});
166
+ * @function
167
+ * @param {string} path - The endpoint of the api to which the request should be made.
168
+ * @param {object} body - The data to be sent in the body of the request
169
+ * @param {object} query - An object containing query parameters to be included in the request
170
+ * @param {function} [callback] - (Optional) callback to handle the response
171
+ * @returns {Operation}
172
+ */
138
173
  export function post(path: string, body: object, query: object, callback?: Function): Operation;
139
174
  import axios from "axios";
140
175
  export { axios, md5 };