# coding: utf-8

"""
    BombBomb

    We make it easy to build relationships using simple videos.

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

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""

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 TeamsApi(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 cancel_jericho_send(self, jericho_id, **kwargs):
        """
        Cancel a Jericho Send
        Cancels a scheduled Jericho send from being sent.

        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.cancel_jericho_send(jericho_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str jericho_id: ID of the Jericho Job to cancel (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.cancel_jericho_send_with_http_info(jericho_id, **kwargs)
        else:
            (data) = self.cancel_jericho_send_with_http_info(jericho_id, **kwargs)
            return data

    def cancel_jericho_send_with_http_info(self, jericho_id, **kwargs):
        """
        Cancel a Jericho Send
        Cancels a scheduled Jericho send from being sent.

        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.cancel_jericho_send_with_http_info(jericho_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str jericho_id: ID of the Jericho Job to cancel (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['jericho_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        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 cancel_jericho_send" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'jericho_id' is set
        if ('jericho_id' not in params) or (params['jericho_id'] is None):
            raise ValueError("Missing the required parameter `jericho_id` when calling `cancel_jericho_send`")

        resource_path = '/team/{teamId}/jericho/{jerichoId}'.replace('{format}', 'json')
        path_params = {}
        if 'jericho_id' in params:
            path_params['jerichoId'] = params['jericho_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

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

        # Authentication setting
        auth_settings = ['BBOAuth2']

        return self.api_client.call_api(resource_path, 'DELETE',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type=None,
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def get_client_group_assets(self, asset_type, **kwargs):
        """
        Lists team assets
        Returns a collection of assets

        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.get_client_group_assets(asset_type, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str asset_type: The type of assets. (required)
        :param str team_id: The team containing the assets.
        :param str auto_tag_name: The auto tag name containing the assets.
        :param str page_size: The number of items to retrieve in a single db query.
        :param str page: Zero-based index of the page of data to retrieve from the db.
        :param str search: Search words.
        :return: InlineResponse200
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.get_client_group_assets_with_http_info(asset_type, **kwargs)
        else:
            (data) = self.get_client_group_assets_with_http_info(asset_type, **kwargs)
            return data

    def get_client_group_assets_with_http_info(self, asset_type, **kwargs):
        """
        Lists team assets
        Returns a collection of assets

        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.get_client_group_assets_with_http_info(asset_type, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str asset_type: The type of assets. (required)
        :param str team_id: The team containing the assets.
        :param str auto_tag_name: The auto tag name containing the assets.
        :param str page_size: The number of items to retrieve in a single db query.
        :param str page: Zero-based index of the page of data to retrieve from the db.
        :param str search: Search words.
        :return: InlineResponse200
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['asset_type', 'team_id', 'auto_tag_name', 'page_size', 'page', 'search']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        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 get_client_group_assets" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'asset_type' is set
        if ('asset_type' not in params) or (params['asset_type'] is None):
            raise ValueError("Missing the required parameter `asset_type` when calling `get_client_group_assets`")

        resource_path = '/team/assets/'.replace('{format}', 'json')
        path_params = {}

        query_params = {}
        if 'asset_type' in params:
            query_params['assetType'] = params['asset_type']
        if 'team_id' in params:
            query_params['teamId'] = params['team_id']
        if 'auto_tag_name' in params:
            query_params['autoTagName'] = params['auto_tag_name']
        if 'page_size' in params:
            query_params['pageSize'] = params['page_size']
        if 'page' in params:
            query_params['page'] = params['page']
        if 'search' in params:
            query_params['search'] = params['search']

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

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

        # Authentication setting
        auth_settings = ['BBOAuth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='InlineResponse200',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def get_jericho_sends(self, team_id, **kwargs):
        """
        List Jericho Sends
        Lists Jericho sends, both pending and sent.

        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.get_jericho_sends(team_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str team_id: The team whose Jericho sends you wish to see. (required)
        :return: list[JerichoConfiguration]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.get_jericho_sends_with_http_info(team_id, **kwargs)
        else:
            (data) = self.get_jericho_sends_with_http_info(team_id, **kwargs)
            return data

    def get_jericho_sends_with_http_info(self, team_id, **kwargs):
        """
        List Jericho Sends
        Lists Jericho sends, both pending and sent.

        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.get_jericho_sends_with_http_info(team_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str team_id: The team whose Jericho sends you wish to see. (required)
        :return: list[JerichoConfiguration]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['team_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        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 get_jericho_sends" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'team_id' is set
        if ('team_id' not in params) or (params['team_id'] is None):
            raise ValueError("Missing the required parameter `team_id` when calling `get_jericho_sends`")

        resource_path = '/team/{teamId}/jericho'.replace('{format}', 'json')
        path_params = {}
        if 'team_id' in params:
            path_params['teamId'] = params['team_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

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

        # Authentication setting
        auth_settings = ['BBOAuth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='list[JerichoConfiguration]',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def get_jericho_stats(self, jericho_id, team_id, **kwargs):
        """
        Gets Jericho performance statistics
        Returns an aggregate view of the performance of a Jericho send

        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.get_jericho_stats(jericho_id, team_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str jericho_id: ID of the Jericho job (required)
        :param str team_id: ID of team through which Jericho was sent (required)
        :return: JerichoPerformance
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.get_jericho_stats_with_http_info(jericho_id, team_id, **kwargs)
        else:
            (data) = self.get_jericho_stats_with_http_info(jericho_id, team_id, **kwargs)
            return data

    def get_jericho_stats_with_http_info(self, jericho_id, team_id, **kwargs):
        """
        Gets Jericho performance statistics
        Returns an aggregate view of the performance of a Jericho send

        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.get_jericho_stats_with_http_info(jericho_id, team_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str jericho_id: ID of the Jericho job (required)
        :param str team_id: ID of team through which Jericho was sent (required)
        :return: JerichoPerformance
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['jericho_id', 'team_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        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 get_jericho_stats" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'jericho_id' is set
        if ('jericho_id' not in params) or (params['jericho_id'] is None):
            raise ValueError("Missing the required parameter `jericho_id` when calling `get_jericho_stats`")
        # verify the required parameter 'team_id' is set
        if ('team_id' not in params) or (params['team_id'] is None):
            raise ValueError("Missing the required parameter `team_id` when calling `get_jericho_stats`")

        resource_path = '/team/{teamId}/jericho/{jerichoId}/performance'.replace('{format}', 'json')
        path_params = {}
        if 'jericho_id' in params:
            path_params['jerichoId'] = params['jericho_id']
        if 'team_id' in params:
            path_params['teamId'] = params['team_id']

        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'])
        if not header_params['Accept']:
            del header_params['Accept']

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

        # Authentication setting
        auth_settings = ['BBOAuth2']

        return self.api_client.call_api(resource_path, 'GET',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='JerichoPerformance',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))

    def queue_jericho_send(self, config, team_id, **kwargs):
        """
        Creates a Jericho send.
        Sends email content on behalf of members of a client group. There are two forms this send can take:         Static Email, and Video Prompt. Static emails require only an emailId.         Video Prompts build emails dynamically and require most of the other fields.         You must be an administrator of a Team Account to use this method.

        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.queue_jericho_send(config, team_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param JerichoConfiguration config: JSON representing a Jericho configuration (required)
        :param str team_id: The ID of the team. (required)
        :return: JerichoConfiguration
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.queue_jericho_send_with_http_info(config, team_id, **kwargs)
        else:
            (data) = self.queue_jericho_send_with_http_info(config, team_id, **kwargs)
            return data

    def queue_jericho_send_with_http_info(self, config, team_id, **kwargs):
        """
        Creates a Jericho send.
        Sends email content on behalf of members of a client group. There are two forms this send can take:         Static Email, and Video Prompt. Static emails require only an emailId.         Video Prompts build emails dynamically and require most of the other fields.         You must be an administrator of a Team Account to use this method.

        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.queue_jericho_send_with_http_info(config, team_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param JerichoConfiguration config: JSON representing a Jericho configuration (required)
        :param str team_id: The ID of the team. (required)
        :return: JerichoConfiguration
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['config', 'team_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')

        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 queue_jericho_send" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'config' is set
        if ('config' not in params) or (params['config'] is None):
            raise ValueError("Missing the required parameter `config` when calling `queue_jericho_send`")
        # verify the required parameter 'team_id' is set
        if ('team_id' not in params) or (params['team_id'] is None):
            raise ValueError("Missing the required parameter `team_id` when calling `queue_jericho_send`")

        resource_path = '/team/{teamId}/jericho'.replace('{format}', 'json')
        path_params = {}
        if 'team_id' in params:
            path_params['teamId'] = params['team_id']

        query_params = {}

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'config' in params:
            body_params = params['config']

        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])
        if not header_params['Accept']:
            del header_params['Accept']

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

        # Authentication setting
        auth_settings = ['BBOAuth2']

        return self.api_client.call_api(resource_path, 'POST',
                                            path_params,
                                            query_params,
                                            header_params,
                                            body=body_params,
                                            post_params=form_params,
                                            files=local_var_files,
                                            response_type='JerichoConfiguration',
                                            auth_settings=auth_settings,
                                            callback=params.get('callback'),
                                            _return_http_data_only=params.get('_return_http_data_only'))
