Skip to content

Commit

Permalink
add ability to filter by start_date
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyyid committed Feb 27, 2024
1 parent 3d2abc4 commit e416489
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages

setup(name="tap-xero",
version="2.2.11",
version="2.2.12",
description="Singer.io tap for extracting data from the Xero API",
author="Stitch",
url="http://singer.io",
Expand Down
2 changes: 2 additions & 0 deletions tap_xero/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ def filter(self, tap_stream_id, since=None, **params):
headers = {"Accept": "application/json",
"Authorization": "Bearer " + self.access_token,
"Xero-tenant-id": self.tenant_id}
if params.get("headers"):
headers.update(params.pop("headers"))
if self.user_agent:
headers["User-Agent"] = self.user_agent
if since:
Expand Down
4 changes: 4 additions & 0 deletions tap_xero/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ def sync(self, ctx):
journal_number = ctx.get_bookmark(bookmark) or 0
while True:
filter_options = {"offset": journal_number}
if ctx.config.get("start_date"):
start_date = parse(ctx.config.get("start_date"))
filter_options['headers'] = {"If-Modified-Since": start_date.strftime("%Y-%m-%dT%H:%M:%SZ")}

records = _make_request(ctx, self.tap_stream_id, filter_options)
logging.info("Got {} records: {}".format(
len(records), records
Expand Down

0 comments on commit e416489

Please sign in to comment.