Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions flinks/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand All @@ -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 <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 #
##################################
Expand Down
41 changes: 41 additions & 0 deletions flinks/entities/attributes.py
Original file line number Diff line number Diff line change
@@ -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)