Skip to content

Commit

Permalink
Journals stream with payments only param (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
xacadil authored Mar 8, 2024
1 parent bf8e2c7 commit dcfe262
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tap_xero/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ def check_platform_access(self, config, config_path):
@backoff.on_exception(retry_after_wait_gen, XeroTooManyInMinuteError, giveup=is_not_status_code_fn([429]), jitter=None, max_tries=3)
def filter(self, tap_stream_id, since=None, **params):
xero_resource_name = tap_stream_id.title().replace("_", "")
#override resource name for Journals with payments only stream.
if xero_resource_name == "JournalsPaymentsOnly":
xero_resource_name = "Journals"
is_report = False
if xero_resource_name.startswith("Reports"):
is_report = True
Expand All @@ -255,7 +258,8 @@ def filter(self, tap_stream_id, since=None, **params):
headers["User-Agent"] = self.user_agent
if since:
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)
response = self.session.send(request.prepare())

Expand Down
150 changes: 150 additions & 0 deletions tap_xero/schemas/journals_payments_only.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"type": [
"null",
"object"
],
"properties": {
"JournalID": {
"type": [
"string"
]
},
"JournalDate": {
"format": "date-time",
"type": [
"null",
"string"
]
},
"JournalNumber": {
"type": [
"null",
"integer"
]
},
"CreatedDateUTC": {
"format": "date-time",
"type": [
"null",
"string"
]
},
"Reference": {
"type": [
"null",
"string"
]
},
"SourceID": {
"type": [
"null",
"string"
]
},
"SourceType": {
"type": [
"null",
"string"
]
},
"JournalLines": {
"items": {
"properties": {
"JournalID": {
"type": [
"string"
]
},
"JournalLineID": {
"type": [
"null",
"string"
]
},
"AccountType": {
"type": [
"null",
"string"
]
},
"AccountID": {
"type": [
"null",
"string"
]
},
"AccountCode": {
"type": [
"null",
"string"
]
},
"TaxName": {
"type": [
"null",
"string"
]
},
"TaxType": {
"type": [
"null",
"string"
]
},
"Description": {
"type": [
"null",
"string"
]
},
"GrossAmount": {
"type": [
"null",
"number"
]
},
"NetAmount": {
"type": [
"null",
"number"
]
},
"AccountName": {
"type": [
"null",
"string"
]
},
"TaxAmount": {
"type": [
"null",
"number"
]
},
"TrackingCategories": {
"items": {
"$ref": "tracking_categories"
},
"type": [
"null",
"array"
]
}
},
"type": [
"null",
"object"
],
"additionalProperties": false
},
"type": [
"null",
"array"
]
}
},
"tap_schema_dependencies": [
"tracking_categories"
],
"additionalProperties": false
}
1 change: 1 addition & 0 deletions tap_xero/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def sync(self, ctx):
# JOURNALS STREAM
# This endpoint is paginated, but in its own special snowflake way.
Journals("journals", ["JournalID"], bookmark_key="JournalNumber", format_fn=transform.format_journals),
Journals("journals_payments_only", ["JournalID"], bookmark_key="JournalNumber", format_fn=transform.format_journals),

# NON-PAGINATED STREAMS
# These endpoints do not support pagination, but do support the Modified At
Expand Down

0 comments on commit dcfe262

Please sign in to comment.