# -*- coding: utf-8 -*-

"""
restapisdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""

from restapisdk.api_helper import APIHelper
from restapisdk.configuration import Server
from restapisdk.controllers.base_controller import BaseController


class APIController(BaseController):

    """A Controller to access Endpoints in the restapisdk API."""
    def __init__(self, config, auth_managers, call_back=None):
        super(APIController, self).__init__(config, auth_managers, call_back)

    def export(self,
               x_requested_by,
               body=None):
        """Does a POST request to /callosum/v1/data/v2/answerbook/export/pdf.

        export

        Args:
            x_requested_by (string): TODO: type description here.
            body (CallosumV1DataV2AnswerbookExportPdfRequest, optional): TODO:
                type description here.

        Returns:
            binary: Response from the API.

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/callosum/v1/data/v2/answerbook/export/pdf'
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'X-Requested-By': x_requested_by,
            'Content-Type': 'application/json'
        }

        # Prepare and execute request
        _request = self.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
        # Apply authentication scheme on request
        self.apply_auth_schemes(_request, 'global')

        _response = self.execute_request(_request, binary=True)
        self.validate_response(_response)

        decoded = _response.text

        return decoded
