Skip to content

Commit

Permalink
Changed loan_accounts stream implementation to MultithreadedBookmarkG…
Browse files Browse the repository at this point in the history
…enerator stream.
  • Loading branch information
shantanu73 committed Mar 26, 2024
1 parent fac0fa0 commit 33bfbd1
Showing 1 changed file with 10 additions and 31 deletions.
41 changes: 10 additions & 31 deletions tap_mambu/tap_generators/loan_accounts_generator.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
import abc
from .multithreaded_bookmark_generator import MultithreadedBookmarkGenerator
from ..helpers.datetime_utils import datetime_to_utc_str

from .generator import TapGenerator
from ..helpers import get_bookmark
from ..helpers.datetime_utils import str_to_localized_datetime, datetime_to_local_str


class LoanAccountsGenerator(TapGenerator):
@abc.abstractmethod
class LoanAccountsLMGenerator(MultithreadedBookmarkGenerator):
def _init_endpoint_config(self):
super(LoanAccountsGenerator, self)._init_endpoint_config()
super(LoanAccountsLMGenerator, self)._init_endpoint_config()
self.endpoint_path = "loans:search"
self.endpoint_bookmark_field = "lastModifiedDate"
self.endpoint_sorting_criteria = {
"field": "id",
"order": "ASC"
}


class LoanAccountsLMGenerator(LoanAccountsGenerator):
def _init_endpoint_config(self):
super()._init_endpoint_config()
self.endpoint_bookmark_field = "lastModifiedDate"
self.endpoint_filter_criteria = [
{
"field": "lastModifiedDate",
"operator": "AFTER",
"value": datetime_to_local_str(str_to_localized_datetime(
get_bookmark(self.state, self.stream_name, self.sub_type, self.start_date)))
}
]
def prepare_batch_params(self):
super(LoanAccountsLMGenerator, self).prepare_batch_params()
self.endpoint_filter_criteria[0]["value"] = datetime_to_utc_str(self.endpoint_intermediary_bookmark_value)


class LoanAccountsADGenerator(LoanAccountsGenerator):
class LoanAccountsADGenerator(LoanAccountsLMGenerator):
def _init_endpoint_config(self):
super()._init_endpoint_config()
super(LoanAccountsADGenerator, self)._init_endpoint_config()
self.endpoint_bookmark_field = "lastAccountAppraisalDate"
self.endpoint_filter_criteria = [
{
"field": "lastAccountAppraisalDate",
"operator": "AFTER",
"value": datetime_to_local_str(str_to_localized_datetime(
get_bookmark(self.state, self.stream_name, self.sub_type, self.start_date)))
}
]

0 comments on commit 33bfbd1

Please sign in to comment.