Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions tap_exact/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,26 @@ def post_process(
def select(self) -> str:
"""Return the select query parameter."""
return ",".join(self.schema["properties"].keys())


class ExactBulkStream(ExactStream):
"""Exact bulk stream class."""

def get_new_paginator(self) -> BaseOffsetPaginator:
"""Create a new pagination helper instance."""
return ExactPaginator(self, start_value=None, page_size=1000)


class ExactSyncStream(ExactBulkStream):
"""Exact stream class for sync endpoints."""

def get_url_params(self, context: dict | None, next_page_token: str) -> dict[str, Any]:
"""Return a dictionary of parameters to use in the API request."""
params: dict = {}
if self.select:
params["$select"] = self.select
starting_timestamp = self.get_starting_replication_key_value(context)
params["$filter"] = f"Timestamp gt {starting_timestamp if type(starting_timestamp) is int else 1}"
if next_page_token:
params["$skiptoken"] = next_page_token
return params
10 changes: 10 additions & 0 deletions tap_exact/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,13 @@
Property("TransactionEntryNo", IntegerType), # Entry number of transaction
Property("Type", StringType), # Asset type (0=Other Assets, 1=Commercial Building)
).to_dict()

deleted_schema = PropertiesList(
Property("ID", StringType), # Primary key
Property("Timestamp", IntegerType), # Deletion timestamp
Property("Division", IntegerType), # Division code
Property("DeletedBy", StringType), # User ID of the person who deleted the record
Property("DeletedDate", DateTimeType), # Date when the record was deleted
Property("EntityKey", StringType), # The primary key of the deleted record
Property("EntityType", IntegerType), # The type of the deleted record
).to_dict()
38 changes: 21 additions & 17 deletions tap_exact/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,37 @@

import typing as t

from tap_exact.client import ExactStream
from tap_exact.schemas import (
assets_schema,
gl_account_classification_mappings_schema,
gl_accounts_schema,
gl_classifications_schema,
transaction_lines_schema,
)
from tap_exact import schemas
from tap_exact.client import ExactBulkStream, ExactStream, ExactSyncStream


class TransactionLinesStream(ExactStream):
class TransactionLinesStream(ExactBulkStream):
"""Define TransactionLines stream."""

name = "transaction_lines"
path = "/bulk/Financial/TransactionLines"
primary_keys: t.ClassVar[list[str]] = ["ID", "Division"]
replication_key: t.ClassVar[str] = "Modified"
schema = transaction_lines_schema # pyright: ignore[reportAssignmentType]
schema = schemas.transaction_lines_schema # pyright: ignore[reportAssignmentType]


class GLAccountsStream(ExactStream):
class GLAccountsStream(ExactBulkStream):
"""Define GLAccounts stream."""

name = "gl_accounts"
path = "/bulk/Financial/GLAccounts"
primary_keys: t.ClassVar[list[str]] = ["ID", "Division"]
replication_key: t.ClassVar[str] = "Modified"
schema = gl_accounts_schema # pyright: ignore[reportAssignmentType]
schema = schemas.gl_accounts_schema # pyright: ignore[reportAssignmentType]


class GLClassificationsStream(ExactStream):
class GLClassificationsStream(ExactBulkStream):
"""Define GLClassifications stream."""

name = "gl_classifications"
path = "/sync/Financial/GLClassifications"
path = "/bulk/Financial/GLClassifications"
primary_keys: t.ClassVar[list[str]] = ["ID", "Division"]
schema = gl_classifications_schema # pyright: ignore[reportAssignmentType]
schema = schemas.gl_classifications_schema # pyright: ignore[reportAssignmentType]


class GLAccountClassificationMappingsStream(ExactStream):
Expand All @@ -49,7 +43,7 @@ class GLAccountClassificationMappingsStream(ExactStream):
name = "gl_account_classification_mappings"
path = "/Financial/GLAccountClassificationMappings"
primary_keys: t.ClassVar[list[str]] = ["ID", "Division"]
schema = gl_account_classification_mappings_schema # pyright: ignore[reportAssignmentType]
schema = schemas.gl_account_classification_mappings_schema # pyright: ignore[reportAssignmentType]


class AssetsStream(ExactStream):
Expand All @@ -58,4 +52,14 @@ class AssetsStream(ExactStream):
name = "assets"
path = "/assets/Assets"
primary_keys: t.ClassVar[list[str]] = ["ID", "Division"]
schema = assets_schema # pyright: ignore[reportAssignmentType]
schema = schemas.assets_schema # pyright: ignore[reportAssignmentType]


class DeletedStream(ExactSyncStream):
"""Define Deleted stream."""

name = "deleted"
path = "/sync/Deleted"
primary_keys: t.ClassVar[list[str]] = ["ID", "Division"]
replication_key: t.ClassVar[str] = "Timestamp"
schema = schemas.deleted_schema # pyright: ignore[reportAssignmentType]
1 change: 1 addition & 0 deletions tap_exact/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def discover_streams(self) -> list[streams.ExactStream]:
streams.GLAccountClassificationMappingsStream(self),
streams.TransactionLinesStream(self),
streams.AssetsStream(self),
streams.DeletedStream(self),
]


Expand Down