# coding: utf-8

"""
    Mentortools Marketplace Server

    Mentortools service for ingesting payment-provider webhooks into normalized order events

    The version of the OpenAPI document: 0.1.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


import re  # noqa: F401
import io
import warnings

from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable

from pydantic import StrictBool, StrictInt, conint

from typing import Any, Dict, Optional

from marketplace_server_connector.models.account_in import AccountIn
from marketplace_server_connector.models.account_patch_in import AccountPatchIn
from marketplace_server_connector.models.product_in import ProductIn
from marketplace_server_connector.models.wrapped_response_account_out import WrappedResponseAccountOut
from marketplace_server_connector.models.wrapped_response_account_sync_out import WrappedResponseAccountSyncOut
from marketplace_server_connector.models.wrapped_response_id_out import WrappedResponseIdOut
from marketplace_server_connector.models.wrapped_response_int import WrappedResponseInt
from marketplace_server_connector.models.wrapped_response_list_account_out import WrappedResponseListAccountOut
from marketplace_server_connector.models.wrapped_response_list_account_sync_out import WrappedResponseListAccountSyncOut
from marketplace_server_connector.models.wrapped_response_list_product_out import WrappedResponseListProductOut

from marketplace_server_connector.api_client import ApiClient
from marketplace_server_connector.api_response import ApiResponse
from marketplace_server_connector.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class CatalogApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client

    @validate_arguments
    async def count_products_v1_catalog_products_count_get(self, provider : Optional[Any] = None, include_archived : Optional[StrictBool] = None, **kwargs) -> WrappedResponseInt:  # noqa: E501
        """Count the portal's marketplace products  # noqa: E501


        :param provider:
        :type provider: Provider
        :param include_archived:
        :type include_archived: bool
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseInt
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the count_products_v1_catalog_products_count_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.count_products_v1_catalog_products_count_get_with_http_info(provider, include_archived, **kwargs)  # noqa: E501

    @validate_arguments
    async def count_products_v1_catalog_products_count_get_with_http_info(self, provider : Optional[Any] = None, include_archived : Optional[StrictBool] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Count the portal's marketplace products  # noqa: E501


        :param provider:
        :type provider: Provider
        :param include_archived:
        :type include_archived: bool
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseInt, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'provider',
            'include_archived'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method count_products_v1_catalog_products_count_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('provider') is not None:  # noqa: E501
            _query_params.append(('provider', _params['provider'].value))

        if _params.get('include_archived') is not None:  # noqa: E501
            _query_params.append(('include_archived', _params['include_archived']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseInt",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/products/count', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def create_account_v1_catalog_accounts_post(self, account_in : AccountIn, **kwargs) -> WrappedResponseIdOut:  # noqa: E501
        """Connect a provider account  # noqa: E501


        :param account_in: (required)
        :type account_in: AccountIn
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseIdOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the create_account_v1_catalog_accounts_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.create_account_v1_catalog_accounts_post_with_http_info(account_in, **kwargs)  # noqa: E501

    @validate_arguments
    async def create_account_v1_catalog_accounts_post_with_http_info(self, account_in : AccountIn, **kwargs) -> ApiResponse:  # noqa: E501
        """Connect a provider account  # noqa: E501


        :param account_in: (required)
        :type account_in: AccountIn
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseIdOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'account_in'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_account_v1_catalog_accounts_post" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['account_in'] is not None:
            _body_params = _params['account_in']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseIdOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/accounts', 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def create_product_v1_catalog_products_post(self, product_in : ProductIn, **kwargs) -> WrappedResponseIdOut:  # noqa: E501
        """Register a marketplace product  # noqa: E501


        :param product_in: (required)
        :type product_in: ProductIn
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseIdOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the create_product_v1_catalog_products_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.create_product_v1_catalog_products_post_with_http_info(product_in, **kwargs)  # noqa: E501

    @validate_arguments
    async def create_product_v1_catalog_products_post_with_http_info(self, product_in : ProductIn, **kwargs) -> ApiResponse:  # noqa: E501
        """Register a marketplace product  # noqa: E501


        :param product_in: (required)
        :type product_in: ProductIn
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseIdOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'product_in'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_product_v1_catalog_products_post" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['product_in'] is not None:
            _body_params = _params['product_in']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseIdOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/products', 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def delete_account_v1_catalog_accounts_account_id_delete(self, account_id : StrictInt, **kwargs) -> WrappedResponseIdOut:  # noqa: E501
        """Disconnect (delete) an account  # noqa: E501

        409 if the account still has products (they back access-package links) — disable it (is_active=false) or remove its products first.  # noqa: E501

        :param account_id: (required)
        :type account_id: int
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseIdOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the delete_account_v1_catalog_accounts_account_id_delete_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.delete_account_v1_catalog_accounts_account_id_delete_with_http_info(account_id, **kwargs)  # noqa: E501

    @validate_arguments
    async def delete_account_v1_catalog_accounts_account_id_delete_with_http_info(self, account_id : StrictInt, **kwargs) -> ApiResponse:  # noqa: E501
        """Disconnect (delete) an account  # noqa: E501

        409 if the account still has products (they back access-package links) — disable it (is_active=false) or remove its products first.  # noqa: E501

        :param account_id: (required)
        :type account_id: int
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseIdOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'account_id'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method delete_account_v1_catalog_accounts_account_id_delete" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['account_id'] is not None:
            _path_params['account_id'] = _params['account_id']


        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseIdOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/accounts/{account_id}', 'DELETE',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def get_account_v1_catalog_accounts_account_id_get(self, account_id : StrictInt, **kwargs) -> WrappedResponseAccountOut:  # noqa: E501
        """Get one connected account  # noqa: E501


        :param account_id: (required)
        :type account_id: int
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseAccountOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the get_account_v1_catalog_accounts_account_id_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.get_account_v1_catalog_accounts_account_id_get_with_http_info(account_id, **kwargs)  # noqa: E501

    @validate_arguments
    async def get_account_v1_catalog_accounts_account_id_get_with_http_info(self, account_id : StrictInt, **kwargs) -> ApiResponse:  # noqa: E501
        """Get one connected account  # noqa: E501


        :param account_id: (required)
        :type account_id: int
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseAccountOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'account_id'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_account_v1_catalog_accounts_account_id_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['account_id'] is not None:
            _path_params['account_id'] = _params['account_id']


        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseAccountOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/accounts/{account_id}', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def list_accounts_v1_catalog_accounts_get(self, active_only : Optional[StrictBool] = None, **kwargs) -> WrappedResponseListAccountOut:  # noqa: E501
        """List the portal's connected provider accounts  # noqa: E501

        Query: active_only? (default false — includes disabled). Credentials are never returned; only the credential key names that are set.  # noqa: E501

        :param active_only:
        :type active_only: bool
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseListAccountOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the list_accounts_v1_catalog_accounts_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.list_accounts_v1_catalog_accounts_get_with_http_info(active_only, **kwargs)  # noqa: E501

    @validate_arguments
    async def list_accounts_v1_catalog_accounts_get_with_http_info(self, active_only : Optional[StrictBool] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """List the portal's connected provider accounts  # noqa: E501

        Query: active_only? (default false — includes disabled). Credentials are never returned; only the credential key names that are set.  # noqa: E501

        :param active_only:
        :type active_only: bool
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseListAccountOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'active_only'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_accounts_v1_catalog_accounts_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('active_only') is not None:  # noqa: E501
            _query_params.append(('active_only', _params['active_only']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListAccountOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/accounts', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def list_products_v1_catalog_products_get(self, provider : Optional[Any] = None, include_archived : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> WrappedResponseListProductOut:  # noqa: E501
        """List the portal's marketplace products (paginated)  # noqa: E501

        Query: portal_id (servers only — user tokens are portal-scoped), provider?, limit, offset. Use /products/count for the total. Products appear here when registered via POST or auto-registered by the first IPN.  # noqa: E501

        :param provider:
        :type provider: Provider
        :param include_archived:
        :type include_archived: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseListProductOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the list_products_v1_catalog_products_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.list_products_v1_catalog_products_get_with_http_info(provider, include_archived, limit, offset, **kwargs)  # noqa: E501

    @validate_arguments
    async def list_products_v1_catalog_products_get_with_http_info(self, provider : Optional[Any] = None, include_archived : Optional[StrictBool] = None, limit : Optional[conint(strict=True, le=200, ge=1)] = None, offset : Optional[conint(strict=True, ge=0)] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """List the portal's marketplace products (paginated)  # noqa: E501

        Query: portal_id (servers only — user tokens are portal-scoped), provider?, limit, offset. Use /products/count for the total. Products appear here when registered via POST or auto-registered by the first IPN.  # noqa: E501

        :param provider:
        :type provider: Provider
        :param include_archived:
        :type include_archived: bool
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseListProductOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'provider',
            'include_archived',
            'limit',
            'offset'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method list_products_v1_catalog_products_get" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('provider') is not None:  # noqa: E501
            _query_params.append(('provider', _params['provider'].value))

        if _params.get('include_archived') is not None:  # noqa: E501
            _query_params.append(('include_archived', _params['include_archived']))

        if _params.get('limit') is not None:  # noqa: E501
            _query_params.append(('limit', _params['limit']))

        if _params.get('offset') is not None:  # noqa: E501
            _query_params.append(('offset', _params['offset']))

        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListProductOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/products', 'GET',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def sync_account_products_v1_catalog_accounts_account_id_products_sync_post(self, account_id : StrictInt, body : Optional[Dict[str, Any]] = None, **kwargs) -> WrappedResponseAccountSyncOut:  # noqa: E501
        """Sync products from one provider account  # noqa: E501


        :param account_id: (required)
        :type account_id: int
        :param body:
        :type body: object
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseAccountSyncOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the sync_account_products_v1_catalog_accounts_account_id_products_sync_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.sync_account_products_v1_catalog_accounts_account_id_products_sync_post_with_http_info(account_id, body, **kwargs)  # noqa: E501

    @validate_arguments
    async def sync_account_products_v1_catalog_accounts_account_id_products_sync_post_with_http_info(self, account_id : StrictInt, body : Optional[Dict[str, Any]] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Sync products from one provider account  # noqa: E501


        :param account_id: (required)
        :type account_id: int
        :param body:
        :type body: object
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseAccountSyncOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'account_id',
            'body'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method sync_account_products_v1_catalog_accounts_account_id_products_sync_post" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['account_id'] is not None:
            _path_params['account_id'] = _params['account_id']


        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['body'] is not None:
            _body_params = _params['body']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseAccountSyncOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/accounts/{account_id}/products/sync', 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def sync_all_products_v1_catalog_products_sync_post(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> WrappedResponseListAccountSyncOut:  # noqa: E501
        """Sync products from ALL of the portal's provider accounts  # noqa: E501

        Pulls each active account's product list from its provider API and reconciles the catalog (upsert by external id; vanished products are soft-archived). Providers without a product-list API report supported=false. Body: {portal_id?} (servers only).  # noqa: E501

        :param body:
        :type body: object
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseListAccountSyncOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the sync_all_products_v1_catalog_products_sync_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.sync_all_products_v1_catalog_products_sync_post_with_http_info(body, **kwargs)  # noqa: E501

    @validate_arguments
    async def sync_all_products_v1_catalog_products_sync_post_with_http_info(self, body : Optional[Dict[str, Any]] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Sync products from ALL of the portal's provider accounts  # noqa: E501

        Pulls each active account's product list from its provider API and reconciles the catalog (upsert by external id; vanished products are soft-archived). Providers without a product-list API report supported=false. Body: {portal_id?} (servers only).  # noqa: E501

        :param body:
        :type body: object
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseListAccountSyncOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'body'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method sync_all_products_v1_catalog_products_sync_post" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['body'] is not None:
            _body_params = _params['body']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListAccountSyncOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/products/sync', 'POST',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @validate_arguments
    async def update_account_v1_catalog_accounts_account_id_patch(self, account_id : StrictInt, account_patch_in : AccountPatchIn, **kwargs) -> WrappedResponseIdOut:  # noqa: E501
        """Update an account (rotate credentials / enable-disable)  # noqa: E501

        Body: {credentials?, is_active?}. credentials replaces the whole set; is_active=false is the safe 'disconnect' (stops webhooks + sync, keeps products).  # noqa: E501

        :param account_id: (required)
        :type account_id: int
        :param account_patch_in: (required)
        :type account_patch_in: AccountPatchIn
        :param _request_timeout: timeout setting for this request.
               If one number provided, it will be total request
               timeout. It can also be a pair (tuple) of
               (connection, read) timeouts.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseIdOut
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the update_account_v1_catalog_accounts_account_id_patch_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.update_account_v1_catalog_accounts_account_id_patch_with_http_info(account_id, account_patch_in, **kwargs)  # noqa: E501

    @validate_arguments
    async def update_account_v1_catalog_accounts_account_id_patch_with_http_info(self, account_id : StrictInt, account_patch_in : AccountPatchIn, **kwargs) -> ApiResponse:  # noqa: E501
        """Update an account (rotate credentials / enable-disable)  # noqa: E501

        Body: {credentials?, is_active?}. credentials replaces the whole set; is_active=false is the safe 'disconnect' (stops webhooks + sync, keeps products).  # noqa: E501

        :param account_id: (required)
        :type account_id: int
        :param account_patch_in: (required)
        :type account_patch_in: AccountPatchIn
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, optional
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the authentication
                              in the spec for a single request.
        :type _request_auth: dict, optional
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseIdOut, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'account_id',
            'account_patch_in'
        ]
        _all_params.extend(
            [
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers'
            ]
        )

        # validate the arguments
        for _key, _val in _params['kwargs'].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method update_account_v1_catalog_accounts_account_id_patch" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['account_id'] is not None:
            _path_params['account_id'] = _params['account_id']


        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get('_headers', {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params['account_patch_in'] is not None:
            _body_params = _params['account_patch_in']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get('_content_type',
            self.api_client.select_header_content_type(
                ['application/json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

        # authentication setting
        _auth_settings = ['Bearer Authorization', 'ServerName Authorization']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseIdOut",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/catalog/accounts/{account_id}', 'PATCH',
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))
