Skip to content

Commit

Permalink
8906 Fix full refresh read for SurveyResponses stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Zirochkaa committed Jan 18, 2022
1 parent e854da1 commit 4ca1447
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ def next_page_token(self, response: requests.Response) -> Optional[Mapping[str,
def request_params(
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None
) -> MutableMapping[str, Any]:
params = {"per_page": self.limit, "since": self.since}
if next_page_token:
params = {"per_page": self.limit, **next_page_token}
else:
params = {"per_page": self.limit, "since": self.since}
params.update(**next_page_token)
return params

def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
Expand Down Expand Up @@ -79,6 +78,10 @@ def parse_response(self, response: requests.Response, stream_state: Mapping[str,


class People(IncrementalDelightedStream):
"""
API docs: https://app.delighted.com/docs/api/listing-people
"""

def path(self, **kwargs) -> str:
return "people.json"

Expand All @@ -90,6 +93,10 @@ def next_page_token(self, response: requests.Response) -> Optional[Mapping[str,


class Unsubscribes(IncrementalDelightedStream):
"""
API docs: https://app.delighted.com/docs/api/listing-unsubscribed-people
"""

cursor_field = "unsubscribed_at"
primary_key = "person_id"

Expand All @@ -98,6 +105,10 @@ def path(self, **kwargs) -> str:


class Bounces(IncrementalDelightedStream):
"""
API docs: https://app.delighted.com/docs/api/listing-bounced-people
"""

cursor_field = "bounced_at"
primary_key = "person_id"

Expand All @@ -106,6 +117,10 @@ def path(self, **kwargs) -> str:


class SurveyResponses(IncrementalDelightedStream):
"""
API docs: https://app.delighted.com/docs/api/listing-survey-responses
"""

cursor_field = "updated_at"

def path(self, **kwargs) -> str:
Expand All @@ -114,8 +129,13 @@ def path(self, **kwargs) -> str:
def request_params(self, stream_state=None, **kwargs):
stream_state = stream_state or {}
params = super().request_params(stream_state=stream_state, **kwargs)

if "since" in params:
params["updated_since"] = params.pop("since")

if stream_state:
params["updated_since"] = stream_state.get(self.cursor_field)

return params


Expand Down

0 comments on commit 4ca1447

Please sign in to comment.