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

water connections stream #106

Merged
merged 1 commit into from
Sep 13, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"data": {
"type": "object"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,35 @@ def read_records(
yield from paymentstream.read_records(sync_mode, cursor_field, stream_slice, stream_state)


class MgramsevaWaterConnections(MgramsevaStream):
"""object for water connections"""

def __init__(
self, headers: dict, request_info: dict, user_request: dict, tenantid_list: list, **kwargs
): # pylint: disable=super-init-not-called
"""specify endpoint for water connections and call super"""
self.headers = headers
self.request_info = request_info
self.user_request = user_request
self.tenantid_list = tenantid_list

def read_records(
self,
sync_mode: SyncMode,
cursor_field: Optional[List[str]] = None,
stream_slice: Optional[Mapping[str, Any]] = None,
stream_state: Optional[Mapping[str, Any]] = None,
) -> Iterable[StreamData]:
"""override"""

for tenantid in self.tenantid_list:
params = {"tenantId": tenantid, "businessService": "WS"}
wcstream = MgramsevaStream(
"ws-services/wc/_search", self.headers, self.request_info, self.user_request, params, "WaterConnection"
)
yield from wcstream.read_records(sync_mode, cursor_field, stream_slice, stream_state)


# Source
class SourceMgramseva(AbstractSource):
"""Source for mGramSeva"""
Expand Down Expand Up @@ -393,6 +422,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
# Generate streams for each object type
streams = [
MgramsevaPayments(self.headers, self.request_info, self.user_request, self.config["tenantids"]),
MgramsevaWaterConnections(self.headers, self.request_info, self.user_request, self.config["tenantids"]),
MgramsevaTenantExpenses(self.headers, self.request_info, self.user_request, self.config["tenantids"], start_date, end_date),
MgramsevaDemands(self.headers, self.request_info, self.user_request, self.config["tenantids"]),
]
Expand Down
Loading