Skip to content

Commit 0c7b051

Browse files
committed
IDEV-2020: Create FeedsResults class for results generator for feeds endponints.
1 parent 3c2d37b commit 0c7b051

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

domaintools/results.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from ordereddict import OrderedDict
1212

1313
from itertools import zip_longest
14+
from types import GeneratorType
15+
1416
from domaintools_async import AsyncResults as Results
1517

1618

@@ -141,3 +143,21 @@ def flattened(self):
141143
flat[f"contact_{contact_key}_{i}"] = " | ".join(contact_value) if type(contact_value) in (list, tuple) else contact_value
142144

143145
return flat
146+
147+
148+
class FeedsResults(Results):
149+
"""Returns the generator for feeds results"""
150+
151+
def response(self) -> GeneratorType:
152+
status_code = None
153+
while status_code != 200:
154+
resp_data = super().response()
155+
status_code = self.status
156+
yield resp_data
157+
158+
self._data = None
159+
self._response = None
160+
if not self.kwargs.get("sessionID"):
161+
# we'll only do iterative request for queries that has sessionID.
162+
# Otherwise, we will have an infinite request if sessionID was not provided but the required data asked is more than the maximum (1 hour of data)
163+
break

0 commit comments

Comments
 (0)