from trimble.id._constants import PACKAGE_NAME
from .AnalyticsHttpClient import AnalyticsHttpClient
import pkg_resources  

class FixedKeySetProvider:
    """
    A keyset provider that returns a fixed keyset
    """
    def __init__(self, keyset, productName = None):      
        """
        Initialize FixedKeySetProvider class

        :param keyset: A dictionary of named keys
        :param productName: Product name of consuming application
        """  
        self._keyset = keyset

        self._version = pkg_resources.require(PACKAGE_NAME)[0].version

        AnalyticsHttpClient.SendInitEvent(
            name=self.__class__.__name__, 
            client_name=PACKAGE_NAME, 
            client_version=self._version)

    async def retrieve_keyset(self):
        """
        Retrieves a dictionary of named keys

        :return: Fixed Keyset
        """
        AnalyticsHttpClient.SendMethodEvent(
            name=f"{self.__class__.__name__}_retrieve_keyset", 
            client_name=PACKAGE_NAME, 
            client_version=self._version)
        return self._keyset