# coding: utf-8

"""
    Moosend API

    TODO: Add a description

    OpenAPI spec version: 1.0
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..configuration import Configuration
from ..api_client import ApiClient


class MailingListsApi(object):
    """
    NOTE: This class is auto generated by the swagger code generator program.
    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient()
            self.api_client = config.api_client

    def creating_a_custom_field(self, format, apikey, mailing_list_id, body, **kwargs):
        """
        Creating a custom field
        Creates a new custom field in the specified mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.creating_a_custom_field(format, apikey, mailing_list_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list where the custom field will belong. (required)
        :param CreatingACustomFieldRequest body:  (required)
        :return: CreatingACustomFieldResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.creating_a_custom_field_with_http_info(format, apikey, mailing_list_id, body, **kwargs)
        else:
            (data) = self.creating_a_custom_field_with_http_info(format, apikey, mailing_list_id, body, **kwargs)
            return data

    def creating_a_custom_field_with_http_info(self, format, apikey, mailing_list_id, body, **kwargs):
        """
        Creating a custom field
        Creates a new custom field in the specified mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.creating_a_custom_field_with_http_info(format, apikey, mailing_list_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list where the custom field will belong. (required)
        :param CreatingACustomFieldRequest body:  (required)
        :return: CreatingACustomFieldResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'apikey', 'mailing_list_id', 'body']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method creating_a_custom_field" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `creating_a_custom_field`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `creating_a_custom_field`")
        # verify the required parameter 'mailing_list_id' is set
        if ('mailing_list_id' not in params) or (params['mailing_list_id'] is None):
            raise ValueError("Missing the required parameter `mailing_list_id` when calling `creating_a_custom_field`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `creating_a_custom_field`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']
        if 'mailing_list_id' in params:
            path_params['MailingListID'] = params['mailing_list_id']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/{MailingListID}/customfields/create.{Format}', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='CreatingACustomFieldResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def creating_a_mailing_list(self, format, apikey, body, **kwargs):
        """
        Creating a mailing list
        Creates a new empty mailing list in your account.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.creating_a_mailing_list(format, apikey, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param CreatingAMailingListRequest body:  (required)
        :return: CreatingAMailingListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.creating_a_mailing_list_with_http_info(format, apikey, body, **kwargs)
        else:
            (data) = self.creating_a_mailing_list_with_http_info(format, apikey, body, **kwargs)
            return data

    def creating_a_mailing_list_with_http_info(self, format, apikey, body, **kwargs):
        """
        Creating a mailing list
        Creates a new empty mailing list in your account.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.creating_a_mailing_list_with_http_info(format, apikey, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param CreatingAMailingListRequest body:  (required)
        :return: CreatingAMailingListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'apikey', 'body']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method creating_a_mailing_list" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `creating_a_mailing_list`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `creating_a_mailing_list`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `creating_a_mailing_list`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/create.{Format}', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='CreatingAMailingListResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def deleting_a_mailing_list(self, format, apikey, mailing_list_id, **kwargs):
        """
        Deleting a mailing list
        Deletes a mailing list from your account.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.deleting_a_mailing_list(format, apikey, mailing_list_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list to be deleted. (required)
        :return: DeletingAMailingListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.deleting_a_mailing_list_with_http_info(format, apikey, mailing_list_id, **kwargs)
        else:
            (data) = self.deleting_a_mailing_list_with_http_info(format, apikey, mailing_list_id, **kwargs)
            return data

    def deleting_a_mailing_list_with_http_info(self, format, apikey, mailing_list_id, **kwargs):
        """
        Deleting a mailing list
        Deletes a mailing list from your account.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.deleting_a_mailing_list_with_http_info(format, apikey, mailing_list_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list to be deleted. (required)
        :return: DeletingAMailingListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'apikey', 'mailing_list_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method deleting_a_mailing_list" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `deleting_a_mailing_list`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `deleting_a_mailing_list`")
        # verify the required parameter 'mailing_list_id' is set
        if ('mailing_list_id' not in params) or (params['mailing_list_id'] is None):
            raise ValueError("Missing the required parameter `mailing_list_id` when calling `deleting_a_mailing_list`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']
        if 'mailing_list_id' in params:
            path_params['MailingListID'] = params['mailing_list_id']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/{MailingListID}/delete.{Format}', 'DELETE',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='DeletingAMailingListResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def getting_all_active_mailing_lists(self, format, apikey, **kwargs):
        """
        Getting all active mailing lists
        Gets a list of your active mailing lists in your account.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.getting_all_active_mailing_lists(format, apikey, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str with_statistics: Specifies whether to fetch statistics for the subscribers or not. If omitted, results will be returned with statistics by default.
        :param str short_by: The name of the campaign property to sort results by. If not specified, results will be sorted by the CreatedOn property
        :param str sort_method: The method to sort results: ASC for ascending, DESC for descending. If not specified, `ASC` will be assumed
        :return: GettingAllActiveMailingListsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.getting_all_active_mailing_lists_with_http_info(format, apikey, **kwargs)
        else:
            (data) = self.getting_all_active_mailing_lists_with_http_info(format, apikey, **kwargs)
            return data

    def getting_all_active_mailing_lists_with_http_info(self, format, apikey, **kwargs):
        """
        Getting all active mailing lists
        Gets a list of your active mailing lists in your account.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.getting_all_active_mailing_lists_with_http_info(format, apikey, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str with_statistics: Specifies whether to fetch statistics for the subscribers or not. If omitted, results will be returned with statistics by default.
        :param str short_by: The name of the campaign property to sort results by. If not specified, results will be sorted by the CreatedOn property
        :param str sort_method: The method to sort results: ASC for ascending, DESC for descending. If not specified, `ASC` will be assumed
        :return: GettingAllActiveMailingListsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'apikey', 'with_statistics', 'short_by', 'sort_method']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method getting_all_active_mailing_lists" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `getting_all_active_mailing_lists`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `getting_all_active_mailing_lists`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))
        if 'with_statistics' in params:
            query_params.append(('WithStatistics', params['with_statistics']))
        if 'short_by' in params:
            query_params.append(('ShortBy', params['short_by']))
        if 'sort_method' in params:
            query_params.append(('SortMethod', params['sort_method']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists.{Format}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='GettingAllActiveMailingListsResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def getting_all_active_mailing_lists_with_paging(self, format, apikey, page, page_size, **kwargs):
        """
        Getting all active mailing lists with paging
        Gets a list of your active mailing lists in your account. Because the results for this call could be quite big, paging information is required as input.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.getting_all_active_mailing_lists_with_paging(format, apikey, page, page_size, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param float page: The page that you want to get. (required)
        :param float page_size: Lists Per Page. (required)
        :param str short_by: The name of the campaign property to sort results by. If not specified, results will be sorted by the CreatedOn property
        :param str sort_method: The method to sort results: ASC for ascending, DESC for descending. If not specified, `ASC` will be assumed
        :return: GettingAllActiveMailingListsWithPagingResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.getting_all_active_mailing_lists_with_paging_with_http_info(format, apikey, page, page_size, **kwargs)
        else:
            (data) = self.getting_all_active_mailing_lists_with_paging_with_http_info(format, apikey, page, page_size, **kwargs)
            return data

    def getting_all_active_mailing_lists_with_paging_with_http_info(self, format, apikey, page, page_size, **kwargs):
        """
        Getting all active mailing lists with paging
        Gets a list of your active mailing lists in your account. Because the results for this call could be quite big, paging information is required as input.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.getting_all_active_mailing_lists_with_paging_with_http_info(format, apikey, page, page_size, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param float page: The page that you want to get. (required)
        :param float page_size: Lists Per Page. (required)
        :param str short_by: The name of the campaign property to sort results by. If not specified, results will be sorted by the CreatedOn property
        :param str sort_method: The method to sort results: ASC for ascending, DESC for descending. If not specified, `ASC` will be assumed
        :return: GettingAllActiveMailingListsWithPagingResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'apikey', 'page', 'page_size', 'short_by', 'sort_method']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method getting_all_active_mailing_lists_with_paging" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `getting_all_active_mailing_lists_with_paging`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `getting_all_active_mailing_lists_with_paging`")
        # verify the required parameter 'page' is set
        if ('page' not in params) or (params['page'] is None):
            raise ValueError("Missing the required parameter `page` when calling `getting_all_active_mailing_lists_with_paging`")
        # verify the required parameter 'page_size' is set
        if ('page_size' not in params) or (params['page_size'] is None):
            raise ValueError("Missing the required parameter `page_size` when calling `getting_all_active_mailing_lists_with_paging`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']
        if 'page' in params:
            path_params['Page'] = params['page']
        if 'page_size' in params:
            path_params['PageSize'] = params['page_size']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))
        if 'short_by' in params:
            query_params.append(('ShortBy', params['short_by']))
        if 'sort_method' in params:
            query_params.append(('SortMethod', params['sort_method']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/{Page}/{PageSize}.{Format}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='GettingAllActiveMailingListsWithPagingResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def getting_mailing_list_details(self, format, mailing_list_id, apikey, **kwargs):
        """
        Getting mailing list details
        Gets details for a given mailing list. You may include subscriber statistics in your results or not. Any segments existing for the requested mailing list will not be included in the results.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.getting_mailing_list_details(format, mailing_list_id, apikey, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str mailing_list_id: The ID of the mailing list to be returned. (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str with_statistics: Specifies whether to fetch statistics for the subscribers or not. If omitted, results will be returned with statistics by default.
        :return: GettingMailingListDetailsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.getting_mailing_list_details_with_http_info(format, mailing_list_id, apikey, **kwargs)
        else:
            (data) = self.getting_mailing_list_details_with_http_info(format, mailing_list_id, apikey, **kwargs)
            return data

    def getting_mailing_list_details_with_http_info(self, format, mailing_list_id, apikey, **kwargs):
        """
        Getting mailing list details
        Gets details for a given mailing list. You may include subscriber statistics in your results or not. Any segments existing for the requested mailing list will not be included in the results.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.getting_mailing_list_details_with_http_info(format, mailing_list_id, apikey, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str mailing_list_id: The ID of the mailing list to be returned. (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str with_statistics: Specifies whether to fetch statistics for the subscribers or not. If omitted, results will be returned with statistics by default.
        :return: GettingMailingListDetailsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'mailing_list_id', 'apikey', 'with_statistics']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method getting_mailing_list_details" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `getting_mailing_list_details`")
        # verify the required parameter 'mailing_list_id' is set
        if ('mailing_list_id' not in params) or (params['mailing_list_id'] is None):
            raise ValueError("Missing the required parameter `mailing_list_id` when calling `getting_mailing_list_details`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `getting_mailing_list_details`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']
        if 'mailing_list_id' in params:
            path_params['MailingListID'] = params['mailing_list_id']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))
        if 'with_statistics' in params:
            query_params.append(('WithStatistics', params['with_statistics']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/{MailingListID}/details.{Format}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='GettingMailingListDetailsResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def removing_a_custom_field(self, format, custom_field_id, apikey, mailing_list_id, **kwargs):
        """
        Removing a custom field
        Removes a custom field definition from the specified mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.removing_a_custom_field(format, custom_field_id, apikey, mailing_list_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str custom_field_id: The ID of the custom field to be deleted. (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list where the custom field belongs. (required)
        :return: RemovingACustomFieldResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.removing_a_custom_field_with_http_info(format, custom_field_id, apikey, mailing_list_id, **kwargs)
        else:
            (data) = self.removing_a_custom_field_with_http_info(format, custom_field_id, apikey, mailing_list_id, **kwargs)
            return data

    def removing_a_custom_field_with_http_info(self, format, custom_field_id, apikey, mailing_list_id, **kwargs):
        """
        Removing a custom field
        Removes a custom field definition from the specified mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.removing_a_custom_field_with_http_info(format, custom_field_id, apikey, mailing_list_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str custom_field_id: The ID of the custom field to be deleted. (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list where the custom field belongs. (required)
        :return: RemovingACustomFieldResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'custom_field_id', 'apikey', 'mailing_list_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method removing_a_custom_field" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `removing_a_custom_field`")
        # verify the required parameter 'custom_field_id' is set
        if ('custom_field_id' not in params) or (params['custom_field_id'] is None):
            raise ValueError("Missing the required parameter `custom_field_id` when calling `removing_a_custom_field`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `removing_a_custom_field`")
        # verify the required parameter 'mailing_list_id' is set
        if ('mailing_list_id' not in params) or (params['mailing_list_id'] is None):
            raise ValueError("Missing the required parameter `mailing_list_id` when calling `removing_a_custom_field`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']
        if 'custom_field_id' in params:
            path_params['CustomFieldID'] = params['custom_field_id']
        if 'mailing_list_id' in params:
            path_params['MailingListID'] = params['mailing_list_id']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/{MailingListID}/customfields/{CustomFieldID}/delete.{Format}', 'DELETE',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='RemovingACustomFieldResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def updating_a_custom_field(self, format, custom_field_id, apikey, mailing_list_id, body, **kwargs):
        """
        Updating a custom field
        Updates the properties of an existing custom field in the specified mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.updating_a_custom_field(format, custom_field_id, apikey, mailing_list_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str custom_field_id: The ID of the custom field to be updated. (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list where the custom field belongs. (required)
        :param UpdatingACustomFieldRequest body:  (required)
        :return: UpdatingACustomFieldResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.updating_a_custom_field_with_http_info(format, custom_field_id, apikey, mailing_list_id, body, **kwargs)
        else:
            (data) = self.updating_a_custom_field_with_http_info(format, custom_field_id, apikey, mailing_list_id, body, **kwargs)
            return data

    def updating_a_custom_field_with_http_info(self, format, custom_field_id, apikey, mailing_list_id, body, **kwargs):
        """
        Updating a custom field
        Updates the properties of an existing custom field in the specified mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.updating_a_custom_field_with_http_info(format, custom_field_id, apikey, mailing_list_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str custom_field_id: The ID of the custom field to be updated. (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list where the custom field belongs. (required)
        :param UpdatingACustomFieldRequest body:  (required)
        :return: UpdatingACustomFieldResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'custom_field_id', 'apikey', 'mailing_list_id', 'body']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method updating_a_custom_field" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `updating_a_custom_field`")
        # verify the required parameter 'custom_field_id' is set
        if ('custom_field_id' not in params) or (params['custom_field_id'] is None):
            raise ValueError("Missing the required parameter `custom_field_id` when calling `updating_a_custom_field`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `updating_a_custom_field`")
        # verify the required parameter 'mailing_list_id' is set
        if ('mailing_list_id' not in params) or (params['mailing_list_id'] is None):
            raise ValueError("Missing the required parameter `mailing_list_id` when calling `updating_a_custom_field`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `updating_a_custom_field`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']
        if 'custom_field_id' in params:
            path_params['CustomFieldID'] = params['custom_field_id']
        if 'mailing_list_id' in params:
            path_params['MailingListID'] = params['mailing_list_id']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/{MailingListID}/customfields/{CustomFieldID}/update.{Format}', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='UpdatingACustomFieldResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def updating_a_mailing_list(self, format, apikey, mailing_list_id, body, **kwargs):
        """
        Updating a mailing list
        Updates the properties of an existing mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.updating_a_mailing_list(format, apikey, mailing_list_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list to be updated. (required)
        :param UpdatingAMailingListRequest body:  (required)
        :return: UpdatingAMailingListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.updating_a_mailing_list_with_http_info(format, apikey, mailing_list_id, body, **kwargs)
        else:
            (data) = self.updating_a_mailing_list_with_http_info(format, apikey, mailing_list_id, body, **kwargs)
            return data

    def updating_a_mailing_list_with_http_info(self, format, apikey, mailing_list_id, body, **kwargs):
        """
        Updating a mailing list
        Updates the properties of an existing mailing list.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.updating_a_mailing_list_with_http_info(format, apikey, mailing_list_id, body, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str format:  (required)
        :param str apikey: You may find your API Key or generate a new one in your account settings. (required)
        :param str mailing_list_id: The ID of the mailing list to be updated. (required)
        :param UpdatingAMailingListRequest body:  (required)
        :return: UpdatingAMailingListResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['format', 'apikey', 'mailing_list_id', 'body']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method updating_a_mailing_list" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'format' is set
        if ('format' not in params) or (params['format'] is None):
            raise ValueError("Missing the required parameter `format` when calling `updating_a_mailing_list`")
        # verify the required parameter 'apikey' is set
        if ('apikey' not in params) or (params['apikey'] is None):
            raise ValueError("Missing the required parameter `apikey` when calling `updating_a_mailing_list`")
        # verify the required parameter 'mailing_list_id' is set
        if ('mailing_list_id' not in params) or (params['mailing_list_id'] is None):
            raise ValueError("Missing the required parameter `mailing_list_id` when calling `updating_a_mailing_list`")
        # verify the required parameter 'body' is set
        if ('body' not in params) or (params['body'] is None):
            raise ValueError("Missing the required parameter `body` when calling `updating_a_mailing_list`")


        collection_formats = {}

        path_params = {}
        if 'format' in params:
            path_params['Format'] = params['format']
        if 'mailing_list_id' in params:
            path_params['MailingListID'] = params['mailing_list_id']

        query_params = []
        if 'apikey' in params:
            query_params.append(('apikey', params['apikey']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.\
            select_header_content_type(['application/json'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/lists/{MailingListID}/update.{Format}', 'POST',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='UpdatingAMailingListResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)
