diff --git a/flinks/client.py b/flinks/client.py index f6f5b61..cc5b0c1 100644 --- a/flinks/client.py +++ b/flinks/client.py @@ -40,6 +40,7 @@ def __init__(self, customer_id, base_url=None, http_max_retries=None): # Set up entities attributes. self._banking_services = None + self._attributes = None ################### # FLINKS ENTITIES # @@ -58,6 +59,18 @@ def banking_services(self): self._banking_services = BankingServices(self) return self._banking_services + @property + def attributes(self): + """ Allows to access the attributes entity. + + :return: :class:`Attribute ` object + :rtype: flinks.entities.attributes.Attribute + + """ + if self._attributes is None: + from .entities.attributes import Attribute + self._attributes = Attribute(self) + return self._attributes ################################## # PRIVATE METHODS AND PROPERTIES # ################################## diff --git a/flinks/entities/attributes.py b/flinks/entities/attributes.py new file mode 100644 index 0000000..531de87 --- /dev/null +++ b/flinks/entities/attributes.py @@ -0,0 +1,41 @@ +""" + Flinks attributes entity + ============================== + + This module defines the ``Attribute`` entity allowing to get values of special parameters. + Documentation: https://docs.flinks.io/docs/enrich-your-data + +""" + +from ..baseapi import BaseApi + + +class Attribute(BaseApi): + """ Wraps attributes parameters for calling into Flinks API """ + + def __init__(self, client): + super().__init__(client) + self.endpoint = 'insight/login' + + def get_attributes(self, login_id, request_id, attributes, filters=None): + """ Retrieves dict with values of attributes + + :param login_id: valid login ID + :param request_id: valid request ID, which you can get after success authorization + :param attributes: dict of attributes broken-down by Attribute level + :param filters: dict of filters broken-down by categories + :type login_id: str + :type request_id:: str + :type attributes:: dict + :type filters:: dict + :return: dictionary containing the values of attributes + :rtype: dictionary + + """ + data = {"Attributes": attributes} + + if filters is not None: + data.update({"Filters": filters}) + + return self._client._call('POST', self._build_path( + login_id + '/attributes/' + request_id), data=data)