tim_manger
02/08/2024, 10:11 PMReuben (Matatika)
02/08/2024, 10:38 PMparent_stream_type
of LeaveBalances
stream LeaveTypes
only, and modify LeaveTypes.get_child_context
to be
def get_child_context(self, record: dict, context: dict) -> dict:
"""Return a context dictionary for child streams."""
return {
**context, # or `"Company_Id": context["Company_Id"]` if you want to be more specific
"LeaveType_Id": record["Id"],
}
?tim_manger
02/08/2024, 11:52 PMReuben (Matatika)
02/09/2024, 12:13 AMCompany_id
for the LeaveTypes
stream?tim_manger
02/09/2024, 12:18 AMLeaveTypes
stream would still use the Company_id
.
However LeaveBalances
would use LeaveType_Id
from LeaveTypes
stream and PayRun_Id
from PayRun
stream.
can that be done?Reuben (Matatika)
02/09/2024, 12:48 AMclass Companies(EasiPayLiveStream):
primary_keys = ["id"]
rest_method = "Get"
path = '/1/companies'
name = "Companies"
schema_filepath = SCHEMAS_DIR / "Companies_Schema.json"
def get_child_context(self, record: dict, context: dict) -> dict:
"""Return a context dictionary for child streams."""
return {
"Company_Id": record["Id"],
}
class LeaveTypes(EasiPayLiveStream):
primary_keys = ["id"]
rest_method = "Get"
path = '/1/leavetypes?companyid={Company_Id}'
name = "LeaveTypes"
parent_stream_type = Companies
schema_filepath = SCHEMAS_DIR / "LeaveTypes_Schema.json"
def get_child_context(self, record: dict, context: dict) -> dict:
"""Return a context dictionary for child streams."""
return {
**context,
"LeaveType_Id": record["Id"],
}
class PayRuns(EasiPayLiveStream):
primary_keys = ["id"]
rest_method = "Get"
path = '/1/PayRuns'
name = "PayRuns"
parent_stream_type = LeaveTypes
schema_filepath = SCHEMAS_DIR / "PayRuns_Schema.json"
def get_child_context(self, record: dict, context: dict) -> dict:
"""Return a context dictionary for child streams."""
return {
**context,
"PayRun_Id": record["Id"],
}
class LeaveBalances(EasiPayLiveStream):
primary_keys = ["id"]
rest_method = "Get"
path = '/1/leavebalances?payrun_id={PayRun_Id}&&leave_type_ids={LeaveType_Id}'
name = "EasiPayLive_LeaveBalances"
parent_stream_type = PayRuns
schema_filepath = SCHEMAS_DIR / "LeaveBalances_Schema.json"
I saw what you were trying to do with a composite parent_stream_type
which is a nice idea but not supported (I'm not sure of the implications of that design). You can get pretty custom with streams though, so there might be a more efficient way that doesn't use parent-child streams. This might be related: https://github.com/meltano/sdk/issues/93tim_manger
02/09/2024, 12:53 AM