# coding: utf-8

"""
    Airtable API

    OpenAPI spec for Airtable's REST API  # noqa: E501

    OpenAPI spec version: 2024-12-27
    
    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 ..api_client import ApiClient


class CommentsApi(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 airtable_comments_create(self, body, base_id, table_id_or_name, record_id, **kwargs):  # noqa: E501
        """Create comment  # noqa: E501

        Creates a comment on a record. User mentioned is supported.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_create(body, base_id, table_id_or_name, record_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param RecordIdCommentsBody body: (required)
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :return: InlineResponse2009
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.airtable_comments_create_with_http_info(body, base_id, table_id_or_name, record_id, **kwargs)  # noqa: E501
        else:
            (data) = self.airtable_comments_create_with_http_info(body, base_id, table_id_or_name, record_id, **kwargs)  # noqa: E501
            return data

    def airtable_comments_create_with_http_info(self, body, base_id, table_id_or_name, record_id, **kwargs):  # noqa: E501
        """Create comment  # noqa: E501

        Creates a comment on a record. User mentioned is supported.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_create_with_http_info(body, base_id, table_id_or_name, record_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param RecordIdCommentsBody body: (required)
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :return: InlineResponse2009
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body', 'base_id', 'table_id_or_name', 'record_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 airtable_comments_create" % 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 `airtable_comments_create`")  # noqa: E501
        # verify the required parameter 'base_id' is set
        if ('base_id' not in params or
                params['base_id'] is None):
            raise ValueError("Missing the required parameter `base_id` when calling `airtable_comments_create`")  # noqa: E501
        # verify the required parameter 'table_id_or_name' is set
        if ('table_id_or_name' not in params or
                params['table_id_or_name'] is None):
            raise ValueError("Missing the required parameter `table_id_or_name` when calling `airtable_comments_create`")  # noqa: E501
        # verify the required parameter 'record_id' is set
        if ('record_id' not in params or
                params['record_id'] is None):
            raise ValueError("Missing the required parameter `record_id` when calling `airtable_comments_create`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'base_id' in params:
            path_params['baseId'] = params['base_id']  # noqa: E501
        if 'table_id_or_name' in params:
            path_params['tableIdOrName'] = params['table_id_or_name']  # noqa: E501
        if 'record_id' in params:
            path_params['recordId'] = params['record_id']  # noqa: E501

        query_params = []

        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'])  # 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 = ['ApiKeyAuth', 'Oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/{baseId}/{tableIdOrName}/{recordId}/comments', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InlineResponse2009',  # 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 airtable_comments_delete(self, base_id, table_id_or_name, record_id, row_comment_id, **kwargs):  # noqa: E501
        """Delete comment  # noqa: E501

        Deletes a comment from a record. Non-admin API users can only delete comments they have created. Enterprise Admins can delete any comment from a record.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_delete(base_id, table_id_or_name, record_id, row_comment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :param str row_comment_id: (required)
        :return: InlineResponse20010
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.airtable_comments_delete_with_http_info(base_id, table_id_or_name, record_id, row_comment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.airtable_comments_delete_with_http_info(base_id, table_id_or_name, record_id, row_comment_id, **kwargs)  # noqa: E501
            return data

    def airtable_comments_delete_with_http_info(self, base_id, table_id_or_name, record_id, row_comment_id, **kwargs):  # noqa: E501
        """Delete comment  # noqa: E501

        Deletes a comment from a record. Non-admin API users can only delete comments they have created. Enterprise Admins can delete any comment from a record.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_delete_with_http_info(base_id, table_id_or_name, record_id, row_comment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :param str row_comment_id: (required)
        :return: InlineResponse20010
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['base_id', 'table_id_or_name', 'record_id', 'row_comment_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 airtable_comments_delete" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'base_id' is set
        if ('base_id' not in params or
                params['base_id'] is None):
            raise ValueError("Missing the required parameter `base_id` when calling `airtable_comments_delete`")  # noqa: E501
        # verify the required parameter 'table_id_or_name' is set
        if ('table_id_or_name' not in params or
                params['table_id_or_name'] is None):
            raise ValueError("Missing the required parameter `table_id_or_name` when calling `airtable_comments_delete`")  # noqa: E501
        # verify the required parameter 'record_id' is set
        if ('record_id' not in params or
                params['record_id'] is None):
            raise ValueError("Missing the required parameter `record_id` when calling `airtable_comments_delete`")  # noqa: E501
        # verify the required parameter 'row_comment_id' is set
        if ('row_comment_id' not in params or
                params['row_comment_id'] is None):
            raise ValueError("Missing the required parameter `row_comment_id` when calling `airtable_comments_delete`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'base_id' in params:
            path_params['baseId'] = params['base_id']  # noqa: E501
        if 'table_id_or_name' in params:
            path_params['tableIdOrName'] = params['table_id_or_name']  # noqa: E501
        if 'record_id' in params:
            path_params['recordId'] = params['record_id']  # noqa: E501
        if 'row_comment_id' in params:
            path_params['rowCommentId'] = params['row_comment_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 = ['ApiKeyAuth', 'Oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/{baseId}/{tableIdOrName}/{recordId}/comments/{rowCommentId}', 'DELETE',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InlineResponse20010',  # 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 airtable_comments_list(self, base_id, table_id_or_name, record_id, **kwargs):  # noqa: E501
        """List comments  # noqa: E501

        Returns a list of comments for the record from newest to oldest.  Note: Comments in reply to another comment (where parentCommentId is set) may not have  their parent comment in the same page of results and vice versa.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_list(base_id, table_id_or_name, record_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :param int page_size: If specified, this will determine the number of comments to return
        :param str offset: A pointer to a specific comment for pagination
        :return: InlineResponse2008
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.airtable_comments_list_with_http_info(base_id, table_id_or_name, record_id, **kwargs)  # noqa: E501
        else:
            (data) = self.airtable_comments_list_with_http_info(base_id, table_id_or_name, record_id, **kwargs)  # noqa: E501
            return data

    def airtable_comments_list_with_http_info(self, base_id, table_id_or_name, record_id, **kwargs):  # noqa: E501
        """List comments  # noqa: E501

        Returns a list of comments for the record from newest to oldest.  Note: Comments in reply to another comment (where parentCommentId is set) may not have  their parent comment in the same page of results and vice versa.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_list_with_http_info(base_id, table_id_or_name, record_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :param int page_size: If specified, this will determine the number of comments to return
        :param str offset: A pointer to a specific comment for pagination
        :return: InlineResponse2008
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['base_id', 'table_id_or_name', 'record_id', 'page_size', '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 airtable_comments_list" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'base_id' is set
        if ('base_id' not in params or
                params['base_id'] is None):
            raise ValueError("Missing the required parameter `base_id` when calling `airtable_comments_list`")  # noqa: E501
        # verify the required parameter 'table_id_or_name' is set
        if ('table_id_or_name' not in params or
                params['table_id_or_name'] is None):
            raise ValueError("Missing the required parameter `table_id_or_name` when calling `airtable_comments_list`")  # noqa: E501
        # verify the required parameter 'record_id' is set
        if ('record_id' not in params or
                params['record_id'] is None):
            raise ValueError("Missing the required parameter `record_id` when calling `airtable_comments_list`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'base_id' in params:
            path_params['baseId'] = params['base_id']  # noqa: E501
        if 'table_id_or_name' in params:
            path_params['tableIdOrName'] = params['table_id_or_name']  # noqa: E501
        if 'record_id' in params:
            path_params['recordId'] = params['record_id']  # noqa: E501

        query_params = []
        if 'page_size' in params:
            query_params.append(('pageSize', params['page_size']))  # 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 = ['ApiKeyAuth', 'Oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/{baseId}/{tableIdOrName}/{recordId}/comments', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InlineResponse2008',  # 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 airtable_comments_update(self, body, base_id, table_id_or_name, record_id, row_comment_id, **kwargs):  # noqa: E501
        """Update comment  # noqa: E501

        Updates a comment on a record. API users can only update comments they have created.  User mentioned is supported.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_update(body, base_id, table_id_or_name, record_id, row_comment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param CommentsRowCommentIdBody body: (required)
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :param str row_comment_id: (required)
        :return: InlineResponse20011
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.airtable_comments_update_with_http_info(body, base_id, table_id_or_name, record_id, row_comment_id, **kwargs)  # noqa: E501
        else:
            (data) = self.airtable_comments_update_with_http_info(body, base_id, table_id_or_name, record_id, row_comment_id, **kwargs)  # noqa: E501
            return data

    def airtable_comments_update_with_http_info(self, body, base_id, table_id_or_name, record_id, row_comment_id, **kwargs):  # noqa: E501
        """Update comment  # noqa: E501

        Updates a comment on a record. API users can only update comments they have created.  User mentioned is supported.   # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.airtable_comments_update_with_http_info(body, base_id, table_id_or_name, record_id, row_comment_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool:
        :param CommentsRowCommentIdBody body: (required)
        :param str base_id: (required)
        :param str table_id_or_name: (required)
        :param str record_id: (required)
        :param str row_comment_id: (required)
        :return: InlineResponse20011
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body', 'base_id', 'table_id_or_name', 'record_id', 'row_comment_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 airtable_comments_update" % 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 `airtable_comments_update`")  # noqa: E501
        # verify the required parameter 'base_id' is set
        if ('base_id' not in params or
                params['base_id'] is None):
            raise ValueError("Missing the required parameter `base_id` when calling `airtable_comments_update`")  # noqa: E501
        # verify the required parameter 'table_id_or_name' is set
        if ('table_id_or_name' not in params or
                params['table_id_or_name'] is None):
            raise ValueError("Missing the required parameter `table_id_or_name` when calling `airtable_comments_update`")  # noqa: E501
        # verify the required parameter 'record_id' is set
        if ('record_id' not in params or
                params['record_id'] is None):
            raise ValueError("Missing the required parameter `record_id` when calling `airtable_comments_update`")  # noqa: E501
        # verify the required parameter 'row_comment_id' is set
        if ('row_comment_id' not in params or
                params['row_comment_id'] is None):
            raise ValueError("Missing the required parameter `row_comment_id` when calling `airtable_comments_update`")  # noqa: E501

        collection_formats = {}

        path_params = {}
        if 'base_id' in params:
            path_params['baseId'] = params['base_id']  # noqa: E501
        if 'table_id_or_name' in params:
            path_params['tableIdOrName'] = params['table_id_or_name']  # noqa: E501
        if 'record_id' in params:
            path_params['recordId'] = params['record_id']  # noqa: E501
        if 'row_comment_id' in params:
            path_params['rowCommentId'] = params['row_comment_id']  # noqa: E501

        query_params = []

        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'])  # 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 = ['ApiKeyAuth', 'Oauth2']  # noqa: E501

        return self.api_client.call_api(
            '/{baseId}/{tableIdOrName}/{recordId}/comments/{rowCommentId}', 'PATCH',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='InlineResponse20011',  # 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)
