# coding: utf-8

"""
    Marketing API

    <p>The <i>Marketing API </i> offers two platforms that sellers can use to promote and advertise their products:</p> <ul><li><b>Promoted Listings</b> is an eBay ad service that lets sellers set up <i>ad campaigns </i> for the products they want to promote. eBay displays the ads in search results and in other marketing modules as <b>SPONSORED</b> listings. If an item in a Promoted Listings campaign sells, the seller is assessed a Promoted Listings fee, which is a seller-specified percentage applied to the sales price. For complete details, refer to the <a href=\"/api-docs/sell/static/marketing/pl-landing.html\">Promoted Listings playbook</a>.</li><li><b>Promotions Manager</b> gives sellers a way to offer discounts on specific items as a way to attract buyers to their inventory. Sellers can set up discounts (such as \"20% off\" and other types of offers) on specific items or on an entire customer order. To further attract buyers, eBay prominently displays promotion <i>teasers</i> throughout buyer flows. For complete details, see <a href=\"/api-docs/sell/static/marketing/promotions-manager.html\">Promotions Manager</a>.</li></ul>  <p><b>Marketing reports</b>, on both the Promoted Listings and Promotions Manager platforms, give sellers information that shows the effectiveness of their marketing strategies. The data gives sellers the ability to review and fine tune their marketing efforts.</p><p><b>Store Email Campaign</b> allows sellers to create and send email campaigns to customers who have signed up to receive their newsletter. For more information on email campaigns, see <a href=\"/api-docs/sell/static/marketing/store-email-campaigns.html#email-campain-types\" target=\"_blank\">Store Email Campaigns</a>.<p class=\"tablenote\"><b>Important!</b> Sellers must have an active eBay Store subscription, and they must accept the <b>Terms and Conditions</b> before they can make requests to these APIs in the Production environment. There are also site-specific listings requirements and restrictions associated with these marketing tools, as listed in the \"requirements and restrictions\" sections for <a href=\"/api-docs/sell/marketing/static/overview.html#PL-requirements\">Promoted Listings</a> and <a href=\"/api-docs/sell/marketing/static/overview.html#PM-requirements\">Promotions Manager</a>.</p> <p>The table below lists all the Marketing API calls grouped by resource.</p>  # noqa: E501

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

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from ...sell_marketing.api_client import ApiClient


class EmailCampaignApi(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):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def create_email_campaign(self, body, x_ebay_c_marketplace_id, content_type, **kwargs):  # noqa: E501
        """create_email_campaign  # noqa: E501

        This method creates a new email campaign. An eBay store owner can create six different types of email campaigns: Welcome, New products & collections, Coupon, Sale event + markdown, Order discount, and Volume pricing.<br><br>A successful <b>createEmailCampaign</b> request returns the <b>emailCampaignId</b> assigned to the new email campaign.<br><br>The fields <b>emailCampaignType</b>, <b>audienceCodes</b>, <b>itemSelectMode</b>, <b>subject</b>, and <b>personalizedMessage</b> are required for all email campaign types. <br><br>Specific email campaign types have required values for additional fields. For more information on the email campaign types, see the <a href=\"/api-docs/sell/static/marketing/store-email-campaigns.html#email-campain-types\" target=\"_blank\">Store Email Campaigns</a> section of the Selling Integration Guide.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_email_campaign(body, x_ebay_c_marketplace_id, content_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateEmailCampaignRequest body: Create a new email campaign request. (required)
        :param str x_ebay_c_marketplace_id: The eBay marketplace that the email campaign interfaces with.<br><br>eBay marketplaces correspond to geographical regions or large submarkets of regions. For example, <code>EBAY-US</code> corresponds to the United States market.<br><br>See <a href=\"/api-docs/sell/marketing/types/ba:MarketplaceIdEnum\" target=\"_blank\">MarketplaceIdEnum</a> for supported values. (required)
        :param str content_type: This header indicates the format of the request body provided by the client. Its value should be set to <b>application/json</b>. <br><br> For more information, refer to <a href=\"/api-docs/static/rest-request-components.html#HTTP\" target=\"_blank \">HTTP request headers</a>. (required)
        :return: CreateEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_email_campaign_with_http_info(body, x_ebay_c_marketplace_id, content_type, **kwargs)  # noqa: E501
        else:
            (data) = self.create_email_campaign_with_http_info(body, x_ebay_c_marketplace_id, content_type, **kwargs)  # noqa: E501
            return data

    def create_email_campaign_with_http_info(self, body, x_ebay_c_marketplace_id, content_type, **kwargs):  # noqa: E501
        """create_email_campaign  # noqa: E501

        This method creates a new email campaign. An eBay store owner can create six different types of email campaigns: Welcome, New products & collections, Coupon, Sale event + markdown, Order discount, and Volume pricing.<br><br>A successful <b>createEmailCampaign</b> request returns the <b>emailCampaignId</b> assigned to the new email campaign.<br><br>The fields <b>emailCampaignType</b>, <b>audienceCodes</b>, <b>itemSelectMode</b>, <b>subject</b>, and <b>personalizedMessage</b> are required for all email campaign types. <br><br>Specific email campaign types have required values for additional fields. For more information on the email campaign types, see the <a href=\"/api-docs/sell/static/marketing/store-email-campaigns.html#email-campain-types\" target=\"_blank\">Store Email Campaigns</a> section of the Selling Integration Guide.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.create_email_campaign_with_http_info(body, x_ebay_c_marketplace_id, content_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param CreateEmailCampaignRequest body: Create a new email campaign request. (required)
        :param str x_ebay_c_marketplace_id: The eBay marketplace that the email campaign interfaces with.<br><br>eBay marketplaces correspond to geographical regions or large submarkets of regions. For example, <code>EBAY-US</code> corresponds to the United States market.<br><br>See <a href=\"/api-docs/sell/marketing/types/ba:MarketplaceIdEnum\" target=\"_blank\">MarketplaceIdEnum</a> for supported values. (required)
        :param str content_type: This header indicates the format of the request body provided by the client. Its value should be set to <b>application/json</b>. <br><br> For more information, refer to <a href=\"/api-docs/static/rest-request-components.html#HTTP\" target=\"_blank \">HTTP request headers</a>. (required)
        :return: CreateEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body', 'x_ebay_c_marketplace_id', 'content_type']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_email_campaign" % key
                )
            params[key] = val
        del params['kwargs']
        # 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 `create_email_campaign`")  # noqa: E501
        # verify the required parameter 'x_ebay_c_marketplace_id' is set
        if ('x_ebay_c_marketplace_id' not in params or
                params['x_ebay_c_marketplace_id'] is None):
            raise ValueError("Missing the required parameter `x_ebay_c_marketplace_id` when calling `create_email_campaign`")  # noqa: E501
        # verify the required parameter 'content_type' is set
        if ('content_type' not in params or
                params['content_type'] is None):
            raise ValueError("Missing the required parameter `content_type` when calling `create_email_campaign`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}
        if 'x_ebay_c_marketplace_id' in params:
            header_params['X-EBAY-C-MARKETPLACE-ID'] = params['x_ebay_c_marketplace_id']  # noqa: E501
        if 'content_type' in params:
            header_params['Content-Type'] = params['content_type']  # noqa: E501

        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'])  # noqa: E501

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='CreateEmailCampaignResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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 delete_email_campaign(self, email_campaign_id, **kwargs):  # noqa: E501
        """delete_email_campaign  # noqa: E501

        This method deletes the email campaign specified by the <b>email_campaign_id</b> path parameter.<br><br>Call <a href=\"/api-docs/sell/marketing/resources/email_campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> to retrieve all of the seller's email campaigns. Use the <b>email_campaign_id</b> of the desired email campaign in the response as the path parameter for this request.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_email_campaign(email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_id: This path parameter specifies the unique eBay-assigned identifier for the email campaign being deleted.<br /><br /> You can retrieve the email campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/email_campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> method. (required)
        :return: DeleteEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.delete_email_campaign_with_http_info(email_campaign_id, **kwargs)  # noqa: E501
        else:
            (data) = self.delete_email_campaign_with_http_info(email_campaign_id, **kwargs)  # noqa: E501
            return data

    def delete_email_campaign_with_http_info(self, email_campaign_id, **kwargs):  # noqa: E501
        """delete_email_campaign  # noqa: E501

        This method deletes the email campaign specified by the <b>email_campaign_id</b> path parameter.<br><br>Call <a href=\"/api-docs/sell/marketing/resources/email_campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> to retrieve all of the seller's email campaigns. Use the <b>email_campaign_id</b> of the desired email campaign in the response as the path parameter for this request.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.delete_email_campaign_with_http_info(email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_id: This path parameter specifies the unique eBay-assigned identifier for the email campaign being deleted.<br /><br /> You can retrieve the email campaign IDs for a specified seller using the <a href=\"/api-docs/sell/marketing/resources/email_campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> method. (required)
        :return: DeleteEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['email_campaign_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}
        if 'email_campaign_id' in params:
            path_params['email_campaign_id'] = params['email_campaign_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign/{email_campaign_id}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='DeleteEmailCampaignResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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 get_audiences(self, email_campaign_type, **kwargs):  # noqa: E501
        """get_audiences  # noqa: E501

        This method retrieves all available email newsletter audiences for the <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\">email campaign type</a> specified by the <b>emailCampaignType</b> path parameter.<br><br>Use the optional <b>limit</b> and <b>offset</b> path parameters to paginate the results and to control which records are returned, respectively.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_audiences(email_campaign_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_type: The email campaign type to search against.<br><br>See <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\" target=\"_blank\">CampaignTypeEnum</a> for the full list of available email campaign types and associated enum values. (required)
        :param str limit: The maximum number of audience groups returned per page in the results set.<br><br><b>Min value</b>: 1<br><br><b>Max value</b>: 200<br><br><b>Default value</b>: 100
        :param str offset: The number of results to skip in a pagination query. This value cannot be less than 0.<br><br><b>Default value</b>: 0
        :return: GetEmailCampaignAudiencesResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_audiences_with_http_info(email_campaign_type, **kwargs)  # noqa: E501
        else:
            (data) = self.get_audiences_with_http_info(email_campaign_type, **kwargs)  # noqa: E501
            return data

    def get_audiences_with_http_info(self, email_campaign_type, **kwargs):  # noqa: E501
        """get_audiences  # noqa: E501

        This method retrieves all available email newsletter audiences for the <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\">email campaign type</a> specified by the <b>emailCampaignType</b> path parameter.<br><br>Use the optional <b>limit</b> and <b>offset</b> path parameters to paginate the results and to control which records are returned, respectively.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_audiences_with_http_info(email_campaign_type, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_type: The email campaign type to search against.<br><br>See <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\" target=\"_blank\">CampaignTypeEnum</a> for the full list of available email campaign types and associated enum values. (required)
        :param str limit: The maximum number of audience groups returned per page in the results set.<br><br><b>Min value</b>: 1<br><br><b>Max value</b>: 200<br><br><b>Default value</b>: 100
        :param str offset: The number of results to skip in a pagination query. This value cannot be less than 0.<br><br><b>Default value</b>: 0
        :return: GetEmailCampaignAudiencesResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['email_campaign_type', 'limit', 'offset']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'email_campaign_type' in params:
            query_params.append(('emailCampaignType', params['email_campaign_type']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign/audience', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetEmailCampaignAudiencesResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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 get_email_campaign(self, email_campaign_id, **kwargs):  # noqa: E501
        """get_email_campaign  # noqa: E501

        This method returns the details of a single email campaign specified by the <b>email_campaign_id</b> path parameter.<br><br>Call <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> to retrieve a list of all email campaigns from a seller's eBay store.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_campaign(email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_id: This path parameter specifies the unique eBay-assigned identifier of the email campaign being retrieved.<br><br>Use the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> method to retrieve a list of email campaign IDs for a seller. (required)
        :return: GetEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_email_campaign_with_http_info(email_campaign_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_email_campaign_with_http_info(email_campaign_id, **kwargs)  # noqa: E501
            return data

    def get_email_campaign_with_http_info(self, email_campaign_id, **kwargs):  # noqa: E501
        """get_email_campaign  # noqa: E501

        This method returns the details of a single email campaign specified by the <b>email_campaign_id</b> path parameter.<br><br>Call <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> to retrieve a list of all email campaigns from a seller's eBay store.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_campaign_with_http_info(email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_id: This path parameter specifies the unique eBay-assigned identifier of the email campaign being retrieved.<br><br>Use the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> method to retrieve a list of email campaign IDs for a seller. (required)
        :return: GetEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['email_campaign_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}
        if 'email_campaign_id' in params:
            path_params['email_campaign_id'] = params['email_campaign_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign/{email_campaign_id}', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetEmailCampaignResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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 get_email_campaigns(self, **kwargs):  # noqa: E501
        """get_email_campaigns  # noqa: E501

        This method retrieves a list of email campaigns from a seller's eBay store.<br><br>Users can filter the results by <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\">email campaign type</a>, <a href=\"/api-docs/sell/marketing/types/api:EmailCampaignStatusEnum\">email campaign status</a>, and <a href=\"/api-docs/sell/marketing/types/ba:MarketplaceIdEnum\">marketplace ID</a> using the <code>q</code> query parameter.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_campaigns(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str limit: The maximum number of email campaigns returned in a page.<br><br><b>Min value</b>: 1<br><br><b>Max value</b>: 200
        :param str offset: The number of results to skip in a pagination query. This value cannot be less than zero.<br><br><b>Default value</b>: 0
        :param str q: This field contains filter criteria for the results returned. Filter by <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\">email campaign type</a>, <a href=\"/api-docs/sell/marketing/types/api:EmailCampaignStatusEnum\">email campaign status</a>, and <a href=\"/api-docs/sell/marketing/types/ba:MarketplaceIdEnum\">marketplace ID</a>.<br><br>For example, setting <code>q=campaignType:WELCOME,ITEM_SHOWCASE</code> will return only Welcome and Item Showcase email campaigns.<br><br><span class=\"tablenote\"><b>Note:</b> At least one <code>campaignType</code> value must be set through the <code>q</code> query parameter. If no other filters are set, all email campaigns for the specified campaign type(s) will be returned in the results set.</span>
        :param str sort: The criteria for sorting email campaign results. See <a href=\"/api-docs/sell/marketing/types/api:ItemSortEnum\" target=\"_blank\">ItemSortEnum</a> for sorting options and their enum values.<br><br><b>Default</b>: <code>NEWLY_LISTED</code>
        :return: GetEmailCampaignsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_email_campaigns_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_email_campaigns_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_email_campaigns_with_http_info(self, **kwargs):  # noqa: E501
        """get_email_campaigns  # noqa: E501

        This method retrieves a list of email campaigns from a seller's eBay store.<br><br>Users can filter the results by <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\">email campaign type</a>, <a href=\"/api-docs/sell/marketing/types/api:EmailCampaignStatusEnum\">email campaign status</a>, and <a href=\"/api-docs/sell/marketing/types/ba:MarketplaceIdEnum\">marketplace ID</a> using the <code>q</code> query parameter.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_campaigns_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str limit: The maximum number of email campaigns returned in a page.<br><br><b>Min value</b>: 1<br><br><b>Max value</b>: 200
        :param str offset: The number of results to skip in a pagination query. This value cannot be less than zero.<br><br><b>Default value</b>: 0
        :param str q: This field contains filter criteria for the results returned. Filter by <a href=\"/api-docs/sell/marketing/types/api:CampaignTypeEnum\">email campaign type</a>, <a href=\"/api-docs/sell/marketing/types/api:EmailCampaignStatusEnum\">email campaign status</a>, and <a href=\"/api-docs/sell/marketing/types/ba:MarketplaceIdEnum\">marketplace ID</a>.<br><br>For example, setting <code>q=campaignType:WELCOME,ITEM_SHOWCASE</code> will return only Welcome and Item Showcase email campaigns.<br><br><span class=\"tablenote\"><b>Note:</b> At least one <code>campaignType</code> value must be set through the <code>q</code> query parameter. If no other filters are set, all email campaigns for the specified campaign type(s) will be returned in the results set.</span>
        :param str sort: The criteria for sorting email campaign results. See <a href=\"/api-docs/sell/marketing/types/api:ItemSortEnum\" target=\"_blank\">ItemSortEnum</a> for sorting options and their enum values.<br><br><b>Default</b>: <code>NEWLY_LISTED</code>
        :return: GetEmailCampaignsResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['limit', 'offset', 'q', 'sort']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_email_campaigns" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501
        if 'q' in params:
            query_params.append(('q', params['q']))  # noqa: E501
        if 'sort' in params:
            query_params.append(('sort', params['sort']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetEmailCampaignsResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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 get_email_preview(self, email_campaign_id, **kwargs):  # noqa: E501
        """get_email_preview  # noqa: E501

        This method returns a preview of the email sent by the email campaign indicated by the <b>email_campaign_id</b> path parameter.<br><br>Call <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> to obtain a list of email campaigns. Use the <b>emailCampaignId</b> value of the desired email campaign as the <b>email_campaign_id</b> path parameter value.<br><br>If this call is executed successfully, the response returns a <b>content</b> field that contains the raw HTML code of the email campaign that can then be rendered anywhere.<br><br><span class=\"tablenote\"><b>Note:</b> The eBay listings in the email are sorted according to the email campaign sort criteria. The individual listings can change over time, as well.<br><br>The result of the email preview call can be treated as a snapshot of the email campaign taken at the date and time of the <b>renderDate</b> value found in the results of the call.</span>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_preview(email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_id: This path parameter specifies the unique eBay assigned identifier for the email campaign associated with the preview being retrieved.<br><br>Use the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\" target=\"_blank\">getEmailCampaigns</a> method to retrieve a list of email campaign IDs for a seller. (required)
        :return: GetEmailPreviewResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_email_preview_with_http_info(email_campaign_id, **kwargs)  # noqa: E501
        else:
            (data) = self.get_email_preview_with_http_info(email_campaign_id, **kwargs)  # noqa: E501
            return data

    def get_email_preview_with_http_info(self, email_campaign_id, **kwargs):  # noqa: E501
        """get_email_preview  # noqa: E501

        This method returns a preview of the email sent by the email campaign indicated by the <b>email_campaign_id</b> path parameter.<br><br>Call <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\">getEmailCampaigns</a> to obtain a list of email campaigns. Use the <b>emailCampaignId</b> value of the desired email campaign as the <b>email_campaign_id</b> path parameter value.<br><br>If this call is executed successfully, the response returns a <b>content</b> field that contains the raw HTML code of the email campaign that can then be rendered anywhere.<br><br><span class=\"tablenote\"><b>Note:</b> The eBay listings in the email are sorted according to the email campaign sort criteria. The individual listings can change over time, as well.<br><br>The result of the email preview call can be treated as a snapshot of the email campaign taken at the date and time of the <b>renderDate</b> value found in the results of the call.</span>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_preview_with_http_info(email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str email_campaign_id: This path parameter specifies the unique eBay assigned identifier for the email campaign associated with the preview being retrieved.<br><br>Use the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\" target=\"_blank\">getEmailCampaigns</a> method to retrieve a list of email campaign IDs for a seller. (required)
        :return: GetEmailPreviewResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['email_campaign_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}
        if 'email_campaign_id' in params:
            path_params['email_campaign_id'] = params['email_campaign_id']  # noqa: E501

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign/{email_campaign_id}/email_preview', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetEmailPreviewResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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 get_email_report(self, end_date, start_date, **kwargs):  # noqa: E501
        """get_email_report  # noqa: E501

        This method returns the seller's email campaign performance report for a time period specified by the <b>startDate</b> and <b>endDate</b> path parameters. The maximum date range for a report retrieved by this method is one year. <br><br><span class=\"tablenote\"><b>Note: </b>The <b>startDate</b> and <b>endDate</b> must be given in UTC format, as shown in the following example: <br><code>sell/marketing/v1/email_campaign/report?startDate=2022-11-01T19:09:02.768Z&endDate=2022-12-28T19:09:02.768Z</code></span><br>The email report returns a list of metrics, such as the number of times an email report has been opened and resulted in clicks.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_report(end_date, start_date, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str end_date: The end date for the report, given in UTC format. The maximum date range for a report retrieved by this method is one year. (required)
        :param str start_date: The start date for the report, given in UTC format. The maximum date range for a report retrieved by this method is one year. (required)
        :return: GetEmailReportResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_email_report_with_http_info(end_date, start_date, **kwargs)  # noqa: E501
        else:
            (data) = self.get_email_report_with_http_info(end_date, start_date, **kwargs)  # noqa: E501
            return data

    def get_email_report_with_http_info(self, end_date, start_date, **kwargs):  # noqa: E501
        """get_email_report  # noqa: E501

        This method returns the seller's email campaign performance report for a time period specified by the <b>startDate</b> and <b>endDate</b> path parameters. The maximum date range for a report retrieved by this method is one year. <br><br><span class=\"tablenote\"><b>Note: </b>The <b>startDate</b> and <b>endDate</b> must be given in UTC format, as shown in the following example: <br><code>sell/marketing/v1/email_campaign/report?startDate=2022-11-01T19:09:02.768Z&endDate=2022-12-28T19:09:02.768Z</code></span><br>The email report returns a list of metrics, such as the number of times an email report has been opened and resulted in clicks.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_email_report_with_http_info(end_date, start_date, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str end_date: The end date for the report, given in UTC format. The maximum date range for a report retrieved by this method is one year. (required)
        :param str start_date: The start date for the report, given in UTC format. The maximum date range for a report retrieved by this method is one year. (required)
        :return: GetEmailReportResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['end_date', 'start_date']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'end_date' in params:
            query_params.append(('endDate', params['end_date']))  # noqa: E501
        if 'start_date' in params:
            query_params.append(('startDate', params['start_date']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign/report', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='GetEmailReportResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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 update_email_campaign(self, body, content_type, email_campaign_id, **kwargs):  # noqa: E501
        """update_email_campaign  # noqa: E501

        This method lets users update an existing email campaign. Pass the <b>emailCampaignId</b> in the request URL and specify the changes to field values in the request payload.<br><br><span class=\"tablenote\"><b>Note: </b>You can only update the custom fields of an email campaign. Fixed values, such as the <b>emailCampaignType</b>, cannot be changed. For full specifications of fixed values for each email campaign type, see the <a href=\"/api-docs/sell/marketing/resources/email_campaign/methods/createEmailCampaign\">createEmailCampaign</a> method documentation.</span>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_email_campaign(body, content_type, email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param UpdateCampaignRequest body: update email campaign request (required)
        :param str content_type: This header indicates the format of the request body provided by the client. Its value should be set to <b>application/json</b>. <br><br> For more information, refer to <a href=\"/api-docs/static/rest-request-components.html#HTTP\" target=\"_blank \">HTTP request headers</a>. (required)
        :param str email_campaign_id: This path parameter specifies the unique eBay assigned identifier for the email campaign being updated.<br><br>Use the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\" target=\"_blank\">getEmailCampaigns</a> method to retrieve a list of email campaign IDs for a seller. (required)
        :return: UpdateEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.update_email_campaign_with_http_info(body, content_type, email_campaign_id, **kwargs)  # noqa: E501
        else:
            (data) = self.update_email_campaign_with_http_info(body, content_type, email_campaign_id, **kwargs)  # noqa: E501
            return data

    def update_email_campaign_with_http_info(self, body, content_type, email_campaign_id, **kwargs):  # noqa: E501
        """update_email_campaign  # noqa: E501

        This method lets users update an existing email campaign. Pass the <b>emailCampaignId</b> in the request URL and specify the changes to field values in the request payload.<br><br><span class=\"tablenote\"><b>Note: </b>You can only update the custom fields of an email campaign. Fixed values, such as the <b>emailCampaignType</b>, cannot be changed. For full specifications of fixed values for each email campaign type, see the <a href=\"/api-docs/sell/marketing/resources/email_campaign/methods/createEmailCampaign\">createEmailCampaign</a> method documentation.</span>  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.update_email_campaign_with_http_info(body, content_type, email_campaign_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param UpdateCampaignRequest body: update email campaign request (required)
        :param str content_type: This header indicates the format of the request body provided by the client. Its value should be set to <b>application/json</b>. <br><br> For more information, refer to <a href=\"/api-docs/static/rest-request-components.html#HTTP\" target=\"_blank \">HTTP request headers</a>. (required)
        :param str email_campaign_id: This path parameter specifies the unique eBay assigned identifier for the email campaign being updated.<br><br>Use the <a href=\"/api-docs/sell/marketing/resources/campaign/methods/getEmailCampaigns\" target=\"_blank\">getEmailCampaigns</a> method to retrieve a list of email campaign IDs for a seller. (required)
        :return: UpdateEmailCampaignResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body', 'content_type', 'email_campaign_id']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in six.iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_email_campaign" % key
                )
            params[key] = val
        del params['kwargs']
        # 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 `update_email_campaign`")  # noqa: E501
        # verify the required parameter 'content_type' is set
        if ('content_type' not in params or
                params['content_type'] is None):
            raise ValueError("Missing the required parameter `content_type` when calling `update_email_campaign`")  # noqa: E501
        # verify the required parameter 'email_campaign_id' is set
        if ('email_campaign_id' not in params or
                params['email_campaign_id'] is None):
            raise ValueError("Missing the required parameter `email_campaign_id` when calling `update_email_campaign`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'email_campaign_id' in params:
            path_params['email_campaign_id'] = params['email_campaign_id']  # noqa: E501

        query_params = []

        header_params = {}
        if 'content_type' in params:
            header_params['Content-Type'] = params['content_type']  # noqa: E501

        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'])  # noqa: E501

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

        # Authentication setting
        auth_settings = ['api_auth']  # noqa: E501

        return self.api_client.call_api(
            '/email_campaign/{email_campaign_id}', 'PUT',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='UpdateEmailCampaignResponse',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _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)
