UNPKG

@industriousoffice/mailchimp_marketing

Version:

This is a modified version of the official Node client library for the Mailchimp Marketing API meant to be usesd for both production and testing purposes.

1,067 lines (944 loc) 221 kB
/* * Mailchimp Marketing API * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: 3.0.80 * Contact: apihelp@mailchimp.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * * Swagger Codegen version: 2.4.12 * * Do not edit the class manually. * */ var ApiClient = require('../ApiClient'); /** * Lists service. * @module api/ListsApi */ /** * Constructs a new ListsApi. * @alias module:api/ListsApi * @class * @param {module:ApiClient} apiClient Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ module.exports = function(apiClient) { this.apiClient = apiClient || ApiClient.instance; /** * Delete list * Delete a list from your Mailchimp account. If you delete a list, you'll lose the list history—including subscriber activity, unsubscribes, complaints, and bounces. You’ll also lose subscribers’ email addresses, unless you exported and backed up your list. * @param {String} listId The unique ID for the list. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteListWithHttpInfo = function(listId) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } var pathParams = { 'list_id': listId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete list * Delete a list from your Mailchimp account. If you delete a list, you'll lose the list history—including subscriber activity, unsubscribes, complaints, and bounces. You’ll also lose subscribers’ email addresses, unless you exported and backed up your list. * @param {String} listId The unique ID for the list. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteList = function(listId) { return this.deleteListWithHttpInfo(listId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Delete interest category * Delete a specific interest category. * @param {String} listId The unique ID for the list. * @param {String} interestCategoryId The unique ID for the interest category. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteInterestCategoryWithHttpInfo = function(listId, interestCategoryId) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'interestCategoryId' is set if (interestCategoryId === undefined || interestCategoryId === null) { throw new Error("Missing the required parameter 'interestCategoryId' when calling "); } var pathParams = { 'list_id': listId, 'interest_category_id': interestCategoryId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/interest-categories/{interest_category_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete interest category * Delete a specific interest category. * @param {String} listId The unique ID for the list. * @param {String} interestCategoryId The unique ID for the interest category. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteInterestCategory = function(listId, interestCategoryId) { return this.deleteInterestCategoryWithHttpInfo(listId, interestCategoryId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Delete interest in category * Delete interests or group names in a specific category. * @param {String} listId The unique ID for the list. * @param {String} interestCategoryId The unique ID for the interest category. * @param {String} interestId The specific interest or 'group name'. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteInterestCategoryInterestWithHttpInfo = function(listId, interestCategoryId, interestId) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'interestCategoryId' is set if (interestCategoryId === undefined || interestCategoryId === null) { throw new Error("Missing the required parameter 'interestCategoryId' when calling "); } // verify the required parameter 'interestId' is set if (interestId === undefined || interestId === null) { throw new Error("Missing the required parameter 'interestId' when calling "); } var pathParams = { 'list_id': listId, 'interest_category_id': interestCategoryId, 'interest_id': interestId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete interest in category * Delete interests or group names in a specific category. * @param {String} listId The unique ID for the list. * @param {String} interestCategoryId The unique ID for the interest category. * @param {String} interestId The specific interest or 'group name'. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteInterestCategoryInterest = function(listId, interestCategoryId, interestId) { return this.deleteInterestCategoryInterestWithHttpInfo(listId, interestCategoryId, interestId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Archive list member * Archive a list member. To permanently delete, use the delete-permanent action. * @param {String} listId The unique ID for the list. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. This endpoint also accepts a list member's email address or contact_id. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteListMemberWithHttpInfo = function(listId, subscriberHash) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'subscriberHash' is set if (subscriberHash === undefined || subscriberHash === null) { throw new Error("Missing the required parameter 'subscriberHash' when calling "); } var pathParams = { 'list_id': listId, 'subscriber_hash': subscriberHash }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/members/{subscriber_hash}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Archive list member * Archive a list member. To permanently delete, use the delete-permanent action. * @param {String} listId The unique ID for the list. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. This endpoint also accepts a list member's email address or contact_id. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteListMember = function(listId, subscriberHash) { return this.deleteListMemberWithHttpInfo(listId, subscriberHash) .then(function(response_and_data) { return response_and_data.data; }); } /** * Delete note * Delete a specific note for a specific list member. * @param {String} listId The unique ID for the list. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. This endpoint also accepts a list member's email address or contact_id. * @param {String} noteId The id for the note. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteListMemberNoteWithHttpInfo = function(listId, subscriberHash, noteId) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'subscriberHash' is set if (subscriberHash === undefined || subscriberHash === null) { throw new Error("Missing the required parameter 'subscriberHash' when calling "); } // verify the required parameter 'noteId' is set if (noteId === undefined || noteId === null) { throw new Error("Missing the required parameter 'noteId' when calling "); } var pathParams = { 'list_id': listId, 'subscriber_hash': subscriberHash, 'note_id': noteId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/members/{subscriber_hash}/notes/{note_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete note * Delete a specific note for a specific list member. * @param {String} listId The unique ID for the list. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. This endpoint also accepts a list member's email address or contact_id. * @param {String} noteId The id for the note. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteListMemberNote = function(listId, subscriberHash, noteId) { return this.deleteListMemberNoteWithHttpInfo(listId, subscriberHash, noteId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Delete merge field * Delete a specific merge field. * @param {String} listId The unique ID for the list. * @param {String} mergeId The id for the merge field. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteListMergeFieldWithHttpInfo = function(listId, mergeId) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'mergeId' is set if (mergeId === undefined || mergeId === null) { throw new Error("Missing the required parameter 'mergeId' when calling "); } var pathParams = { 'list_id': listId, 'merge_id': mergeId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/merge-fields/{merge_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete merge field * Delete a specific merge field. * @param {String} listId The unique ID for the list. * @param {String} mergeId The id for the merge field. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteListMergeField = function(listId, mergeId) { return this.deleteListMergeFieldWithHttpInfo(listId, mergeId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Delete segment * Delete a specific segment in a list. * @param {String} listId The unique ID for the list. * @param {String} segmentId The unique id for the segment. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteSegmentWithHttpInfo = function(listId, segmentId) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'segmentId' is set if (segmentId === undefined || segmentId === null) { throw new Error("Missing the required parameter 'segmentId' when calling "); } var pathParams = { 'list_id': listId, 'segment_id': segmentId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/segments/{segment_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete segment * Delete a specific segment in a list. * @param {String} listId The unique ID for the list. * @param {String} segmentId The unique id for the segment. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteSegment = function(listId, segmentId) { return this.deleteSegmentWithHttpInfo(listId, segmentId) .then(function(response_and_data) { return response_and_data.data; }); } /** * Remove list member from segment * Remove a member from the specified static segment. * @param {String} listId The unique ID for the list. * @param {String} segmentId The unique id for the segment. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.removeSegmentMemberWithHttpInfo = function(listId, segmentId, subscriberHash) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'segmentId' is set if (segmentId === undefined || segmentId === null) { throw new Error("Missing the required parameter 'segmentId' when calling "); } // verify the required parameter 'subscriberHash' is set if (subscriberHash === undefined || subscriberHash === null) { throw new Error("Missing the required parameter 'subscriberHash' when calling "); } var pathParams = { 'list_id': listId, 'segment_id': segmentId, 'subscriber_hash': subscriberHash }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/segments/{segment_id}/members/{subscriber_hash}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Remove list member from segment * Remove a member from the specified static segment. * @param {String} listId The unique ID for the list. * @param {String} segmentId The unique id for the segment. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.removeSegmentMember = function(listId, segmentId, subscriberHash) { return this.removeSegmentMemberWithHttpInfo(listId, segmentId, subscriberHash) .then(function(response_and_data) { return response_and_data.data; }); } /** * Delete webhook * Delete a specific webhook in a list. * @param {String} listId The unique ID for the list. * @param {String} webhookId The webhook's id. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ this.deleteListWebhookWithHttpInfo = function(listId, webhookId) { var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'webhookId' is set if (webhookId === undefined || webhookId === null) { throw new Error("Missing the required parameter 'webhookId' when calling "); } var pathParams = { 'list_id': listId, 'webhook_id': webhookId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/webhooks/{webhook_id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Delete webhook * Delete a specific webhook in a list. * @param {String} listId The unique ID for the list. * @param {String} webhookId The webhook's id. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ this.deleteListWebhook = function(listId, webhookId) { return this.deleteListWebhookWithHttpInfo(listId, webhookId) .then(function(response_and_data) { return response_and_data.data; }); } /** * List member tags * Get the tags on a list member. * @param {String} listId The unique ID for the list. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. This endpoint also accepts a list member's email address or contact_id. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/CollectionOfTags} and HTTP response */ this.getListMemberTagsWithHttpInfo = function(listId, subscriberHash, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'subscriberHash' is set if (subscriberHash === undefined || subscriberHash === null) { throw new Error("Missing the required parameter 'subscriberHash' when calling "); } var pathParams = { 'list_id': listId, 'subscriber_hash': subscriberHash }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { 'fields': this.apiClient.buildCollectionParam(opts['fields'] ? opts['fields'] : opts['fields'], 'csv'), 'exclude_fields': this.apiClient.buildCollectionParam(opts['excludeFields'] ? opts['excludeFields'] : opts['exclude_fields'], 'csv'), 'count': ( opts['count'] ? opts['count'] : opts['count']), 'offset': ( opts['offset'] ? opts['offset'] : opts['offset']) }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/members/{subscriber_hash}/tags', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * List member tags * Get the tags on a list member. * @param {String} listId The unique ID for the list. * @param {String} subscriberHash The MD5 hash of the lowercase version of the list member's email address. This endpoint also accepts a list member's email address or contact_id. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/CollectionOfTags} */ this.getListMemberTags = function(listId, subscriberHash, opts) { return this.getListMemberTagsWithHttpInfo(listId, subscriberHash, opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * Get lists info * Get information about all lists in the account. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @param {String} opts.beforeDateCreated Restrict response to lists created before the set date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.sinceDateCreated Restrict results to lists created after the set date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.beforeCampaignLastSent Restrict results to lists created before the last campaign send date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.sinceCampaignLastSent Restrict results to lists created after the last campaign send date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.email Restrict results to lists that include a specific subscriber's email address. * @param {module:model/String} opts.sortField Returns files sorted by the specified field. * @param {module:model/String} opts.sortDir Determines the order direction for sorted results. * @param {Boolean} opts.hasEcommerceStore Restrict results to lists that contain an active, connected, undeleted ecommerce store. * @param {Boolean} opts.includeTotalContacts Return the total_contacts field in the stats response, which contains an approximate count of all contacts in any state. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriberLists} and HTTP response */ this.getAllListsWithHttpInfo = function(opts) { opts = opts || {}; var postBody = null; var pathParams = { }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { 'fields': this.apiClient.buildCollectionParam(opts['fields'] ? opts['fields'] : opts['fields'], 'csv'), 'exclude_fields': this.apiClient.buildCollectionParam(opts['excludeFields'] ? opts['excludeFields'] : opts['exclude_fields'], 'csv'), 'count': ( opts['count'] ? opts['count'] : opts['count']), 'offset': ( opts['offset'] ? opts['offset'] : opts['offset']), 'before_date_created': ( opts['beforeDateCreated'] ? opts['beforeDateCreated'] : opts['before_date_created']), 'since_date_created': ( opts['sinceDateCreated'] ? opts['sinceDateCreated'] : opts['since_date_created']), 'before_campaign_last_sent': ( opts['beforeCampaignLastSent'] ? opts['beforeCampaignLastSent'] : opts['before_campaign_last_sent']), 'since_campaign_last_sent': ( opts['sinceCampaignLastSent'] ? opts['sinceCampaignLastSent'] : opts['since_campaign_last_sent']), 'email': ( opts['email'] ? opts['email'] : opts['email']), 'sort_field': ( opts['sortField'] ? opts['sortField'] : opts['sort_field']), 'sort_dir': ( opts['sortDir'] ? opts['sortDir'] : opts['sort_dir']), 'has_ecommerce_store': ( opts['hasEcommerceStore'] ? opts['hasEcommerceStore'] : opts['has_ecommerce_store']), 'include_total_contacts': ( opts['includeTotalContacts'] ? opts['includeTotalContacts'] : opts['include_total_contacts']) }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get lists info * Get information about all lists in the account. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @param {String} opts.beforeDateCreated Restrict response to lists created before the set date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.sinceDateCreated Restrict results to lists created after the set date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.beforeCampaignLastSent Restrict results to lists created before the last campaign send date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.sinceCampaignLastSent Restrict results to lists created after the last campaign send date. Uses ISO 8601 time format: 2015-10-21T15:41:36+00:00. * @param {String} opts.email Restrict results to lists that include a specific subscriber's email address. * @param {module:model/String} opts.sortField Returns files sorted by the specified field. * @param {module:model/String} opts.sortDir Determines the order direction for sorted results. * @param {Boolean} opts.hasEcommerceStore Restrict results to lists that contain an active, connected, undeleted ecommerce store. * @param {Boolean} opts.includeTotalContacts Return the total_contacts field in the stats response, which contains an approximate count of all contacts in any state. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriberLists} */ this.getAllLists = function(opts) { return this.getAllListsWithHttpInfo(opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * Get list info * Get information about a specific list in your Mailchimp account. Results include list members who have signed up but haven't confirmed their subscription yet and unsubscribed or cleaned. * @param {String} listId The unique ID for the list. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Boolean} opts.includeTotalContacts Return the total_contacts field in the stats response, which contains an approximate count of all contacts in any state. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriberList} and HTTP response */ this.getListWithHttpInfo = function(listId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } var pathParams = { 'list_id': listId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { 'fields': this.apiClient.buildCollectionParam(opts['fields'] ? opts['fields'] : opts['fields'], 'csv'), 'exclude_fields': this.apiClient.buildCollectionParam(opts['excludeFields'] ? opts['excludeFields'] : opts['exclude_fields'], 'csv'), 'include_total_contacts': ( opts['includeTotalContacts'] ? opts['includeTotalContacts'] : opts['include_total_contacts']) }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get list info * Get information about a specific list in your Mailchimp account. Results include list members who have signed up but haven't confirmed their subscription yet and unsubscribed or cleaned. * @param {String} listId The unique ID for the list. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Boolean} opts.includeTotalContacts Return the total_contacts field in the stats response, which contains an approximate count of all contacts in any state. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriberList} */ this.getList = function(listId, opts) { return this.getListWithHttpInfo(listId, opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * List abuse reports * Get all abuse reports for a specific list. * @param {String} listId The unique ID for the list. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AbuseComplaints} and HTTP response */ this.getListAbuseReportsWithHttpInfo = function(listId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } var pathParams = { 'list_id': listId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { 'fields': this.apiClient.buildCollectionParam(opts['fields'] ? opts['fields'] : opts['fields'], 'csv'), 'exclude_fields': this.apiClient.buildCollectionParam(opts['excludeFields'] ? opts['excludeFields'] : opts['exclude_fields'], 'csv'), 'count': ( opts['count'] ? opts['count'] : opts['count']), 'offset': ( opts['offset'] ? opts['offset'] : opts['offset']) }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/abuse-reports', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * List abuse reports * Get all abuse reports for a specific list. * @param {String} listId The unique ID for the list. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AbuseComplaints} */ this.getListAbuseReports = function(listId, opts) { return this.getListAbuseReportsWithHttpInfo(listId, opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * Get abuse report * Get details about a specific abuse report. * @param {String} listId The unique ID for the list. * @param {String} reportId The id for the abuse report. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/AbuseComplaint} and HTTP response */ this.getListAbuseReportDetailsWithHttpInfo = function(listId, reportId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } // verify the required parameter 'reportId' is set if (reportId === undefined || reportId === null) { throw new Error("Missing the required parameter 'reportId' when calling "); } var pathParams = { 'list_id': listId, 'report_id': reportId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { 'fields': this.apiClient.buildCollectionParam(opts['fields'] ? opts['fields'] : opts['fields'], 'csv'), 'exclude_fields': this.apiClient.buildCollectionParam(opts['excludeFields'] ? opts['excludeFields'] : opts['exclude_fields'], 'csv'), 'count': ( opts['count'] ? opts['count'] : opts['count']), 'offset': ( opts['offset'] ? opts['offset'] : opts['offset']) }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/abuse-reports/{report_id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * Get abuse report * Get details about a specific abuse report. * @param {String} listId The unique ID for the list. * @param {String} reportId The id for the abuse report. * @param {Object} opts Optional parameters * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/AbuseComplaint} */ this.getListAbuseReportDetails = function(listId, reportId, opts) { return this.getListAbuseReportDetailsWithHttpInfo(listId, reportId, opts) .then(function(response_and_data) { return response_and_data.data; }); } /** * List recent activity * Get up to the previous 180 days of daily detailed aggregated activity stats for a list, not including Automation activity. * @param {String} listId The unique ID for the list. * @param {Object} opts Optional parameters * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/ListActivity} and HTTP response */ this.getListRecentActivityWithHttpInfo = function(listId, opts) { opts = opts || {}; var postBody = null; // verify the required parameter 'listId' is set if (listId === undefined || listId === null) { throw new Error("Missing the required parameter 'listId' when calling "); } var pathParams = { 'list_id': listId }; /* The following block building queryParams is going to look a little odd, we're going look for values in $opts with both camelCase and snake_case format (which will be the same if singular word). This is because the API docs use snake_case but early versions of these SDKs used camelCase. So to be backward compatible we'll use both. */ var queryParams = { 'count': ( opts['count'] ? opts['count'] : opts['count']), 'offset': ( opts['offset'] ? opts['offset'] : opts['offset']), 'fields': this.apiClient.buildCollectionParam(opts['fields'] ? opts['fields'] : opts['fields'], 'csv'), 'exclude_fields': this.apiClient.buildCollectionParam(opts['excludeFields'] ? opts['excludeFields'] : opts['exclude_fields'], 'csv') }; var headerParams = { }; var formParams = { }; var authNames = ['basicAuth']; var contentTypes = ['application/json']; var accepts = ['application/json', 'application/problem+json']; var returnType = 'application/json'; return this.apiClient.callApi( '/lists/{list_id}/activity', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType ); } /** * List recent activity * Get up to the previous 180 days of daily detailed aggregated activity stats for a list, not including Automation activity. * @param {String} listId The unique ID for the list. * @param {Object} opts Optional parameters * @param {Number} opts.count The number of records to return. Default value is 10. Maximum value is 1000 (default to 10) * @param {Number} opts.offset Used for [pagination](https://mailchimp.com/developer/marketing/docs/methods-parameters/#pagination), this it the number of records from a collection to skip. Default value is 0. (default to 0) * @param {Array.<String>} opts.fields A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation. * @param {Array.<String>} opts.excludeFields A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ListActivity} */ this.getListRecentActivity = function(listId, opts) { return this.getListRecentActivityWithHttpInfo(listId, opts) .then(function(response_and_data) {