Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HGI-6871 / Use where=Date param instead of If-Modified-Since header #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion tap_xero/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,16 @@ def filter(self, tap_stream_id, since=None, **params):
if self.user_agent:
headers["User-Agent"] = self.user_agent
if since:
headers["If-Modified-Since"] = since
if xero_resource_name == "Invoices":
# Parse the since datetime and format it for Xero's DateTime filter
dt = datetime.strptime(since, "%Y-%m-%dT%H:%M:%SZ")
# Format as DateTime(YYYY, MM, DD, HH, mm, ss) for Xero's query syntax
formatted_date = f"DateTime({dt.year}, {dt.month:02}, {dt.day:02}, {dt.hour:02}, {dt.minute:02}, {dt.second:02})"
# Add where clause to filter by Date field
params["where"] = f"Date >= {formatted_date}"
else:
# For all other endpoints, use If-Modified-Since header
headers["If-Modified-Since"] = since
if tap_stream_id == "journals_payments_only":
params.update({"paymentsOnly":'true'})
request = requests.Request("GET", url, headers=headers, params=params)
Expand Down