diff --git a/setup.py b/setup.py index fd0353f..bd02dba 100755 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/tap_xero/client.py b/tap_xero/client.py index 5c0af58..7e8ead3 100644 --- a/tap_xero/client.py +++ b/tap_xero/client.py @@ -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: diff --git a/tap_xero/streams.py b/tap_xero/streams.py index ffd16fd..7c3662b 100644 --- a/tap_xero/streams.py +++ b/tap_xero/streams.py @@ -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