# coding: utf-8

"""
    Listing API

    <span class=\"tablenote\"><b>Note:</b> This is a <a href=\"https://developer.ebay.com/api-docs/static/versioning.html#limited\" target=\"_blank\"> <img src=\"/cms/img/docs/partners-api.svg\" class=\"legend-icon partners-icon\" title=\"Limited Release\"  alt=\"Limited Release\" />(Limited Release)</a> API available only to select developers approved by business units.</span><br /><br />Enables a seller adding an ad or item on a Partner's site to automatically create an eBay listing draft using the item details from the Partner's site.  # noqa: E501

    OpenAPI spec version: v1_beta.3.1
    
    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_listing.api_client import ApiClient


class ItemDraftApi(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_item_draft(self, x_ebay_c_marketplace_id, **kwargs):  # noqa: E501
        """create_item_draft  # noqa: E501

        This call gives Partners the ability to create an eBay draft of a item for their seller using information from their site. <br /><br />This lets the Partner increase the exposure of items on their site and leverage the eBay user listing experience seamlessly. This experience provides guidance on pricing, aspects, etc. and recommendations that help create a listing that is complete and improves the exposure of the listing in search results. <br /><br />After the listing draft is created, the seller logs into their eBay account and uses the listing experience to finish the listing and publish the item on eBay.  # 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_item_draft(x_ebay_c_marketplace_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str x_ebay_c_marketplace_id: Use this header to specify an eBay marketplace ID. For a list of supported sites, see <a href=\"/api-docs/sell/listing/overview.html#API\">API Restrictions</a> in the Listing API overview.  (required)
        :param ItemDraft body:
        :param str content_language: Use this header to specify the natural language of the seller. For details, see Content-Language in <a href=\"/api-docs/static/rest-request-components.html#headers\">HTTP request headers</a>. <br /><br /><b> Required: </b>For EBAY_CA in French. <br /><br />(Content-Language = <code>fr-CA</code>)
        :return: ItemDraftResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.create_item_draft_with_http_info(x_ebay_c_marketplace_id, **kwargs)  # noqa: E501
        else:
            (data) = self.create_item_draft_with_http_info(x_ebay_c_marketplace_id, **kwargs)  # noqa: E501
            return data

    def create_item_draft_with_http_info(self, x_ebay_c_marketplace_id, **kwargs):  # noqa: E501
        """create_item_draft  # noqa: E501

        This call gives Partners the ability to create an eBay draft of a item for their seller using information from their site. <br /><br />This lets the Partner increase the exposure of items on their site and leverage the eBay user listing experience seamlessly. This experience provides guidance on pricing, aspects, etc. and recommendations that help create a listing that is complete and improves the exposure of the listing in search results. <br /><br />After the listing draft is created, the seller logs into their eBay account and uses the listing experience to finish the listing and publish the item on eBay.  # 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_item_draft_with_http_info(x_ebay_c_marketplace_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str x_ebay_c_marketplace_id: Use this header to specify an eBay marketplace ID. For a list of supported sites, see <a href=\"/api-docs/sell/listing/overview.html#API\">API Restrictions</a> in the Listing API overview.  (required)
        :param ItemDraft body:
        :param str content_language: Use this header to specify the natural language of the seller. For details, see Content-Language in <a href=\"/api-docs/static/rest-request-components.html#headers\">HTTP request headers</a>. <br /><br /><b> Required: </b>For EBAY_CA in French. <br /><br />(Content-Language = <code>fr-CA</code>)
        :return: ItemDraftResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['x_ebay_c_marketplace_id', 'body', 'content_language']  # 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_item_draft" % key
                )
            params[key] = val
        del params['kwargs']
        # 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_item_draft`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}
        if 'content_language' in params:
            header_params['Content-Language'] = params['content_language']  # noqa: E501
        if 'x_ebay_c_marketplace_id' in params:
            header_params['X-EBAY-C-MARKETPLACE-ID'] = params['x_ebay_c_marketplace_id']  # 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(
            '/item_draft/', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ItemDraftResponse',  # 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)
