Skip to content

Commit 9d929d9

Browse files
committed
Some cleanup and add organization invitations
1 parent f0a92ff commit 9d929d9

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

tap_clerk/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ClerkStream(RESTStream):
2424
"""Clerk stream class."""
2525

2626
# Update this value if necessary or override `parse_response`.
27-
records_jsonpath = "$[*]"
27+
records_jsonpath = "$.data[*]"
2828

2929
# Update this value if necessary or override `get_new_paginator`.
3030
next_page_token_jsonpath = "$.next_page" # noqa: S105

tap_clerk/streams.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ class OrganizationsStream(ClerkStream):
3636
th.Property("updated_at", th.IntegerType),
3737
).to_dict()
3838

39-
def parse_response(self, response: requests.Response) -> t.Iterable[dict]:
40-
yield from extract_jsonpath("$.data[*]", input=response.json())
41-
4239
def get_child_context(self, record: dict, context: t.Optional[dict]) -> dict:
4340
return { "organization_id": record["id"] }
4441

@@ -84,8 +81,25 @@ class OrganizationMembershipStream(ClerkStream):
8481
th.Property("updated_at", th.IntegerType, description="Timestamp of when the membership was last updated")
8582
).to_dict()
8683

87-
def parse_response(self, response: requests.Response) -> t.Iterable[dict]:
88-
yield from extract_jsonpath("$.data[*]", input=response.json())
84+
class OrganizationInvitationsStream(ClerkStream):
85+
"""Organization invitations stream class."""
86+
name = "organization_invitations"
87+
path = "/organization_invitations"
88+
primary_keys = ["id"]
89+
replication_key = None
90+
schema = th.PropertiesList(
91+
th.Property("id", th.StringType, description="The unique identifier for the invitation"),
92+
th.Property("object", th.StringType, description="Type of the object, should be 'organization_invitation'"),
93+
th.Property("email_address", th.StringType, description="Email address of the invited user"),
94+
th.Property("role", th.StringType, description="Role assigned to the invited user"),
95+
th.Property("role_name", th.StringType, description="Name of the role assigned"),
96+
th.Property("organization_id", th.StringType, description="ID of the organization"),
97+
th.Property("status", th.StringType, description="Status of the invitation (pending, accepted, revoked)"),
98+
th.Property("public_metadata", th.ObjectType(additional_properties=True), description="Public metadata"),
99+
th.Property("private_metadata", th.ObjectType(additional_properties=True), description="Private metadata"),
100+
th.Property("created_at", th.IntegerType, description="Timestamp of when the invitation was created"),
101+
th.Property("updated_at", th.IntegerType, description="Timestamp of when the invitation was last updated")
102+
).to_dict()
89103

90104
class UsersStream(ClerkStream):
91105
"""Users stream class."""
@@ -251,15 +265,4 @@ class WaitlistEntriesStream(ClerkStream):
251265
th.Property("created_at", th.IntegerType),
252266
th.Property("updated_at", th.IntegerType)
253267
))
254-
).to_dict()
255-
256-
def get_url_params(self, context: dict | None, next_page_token: t.Any | None) -> dict[str, t.Any]:
257-
params: dict = {"limit": self.API_LIMIT_PAGE_SIZE}
258-
if next_page_token:
259-
params["offset"] = next_page_token
260-
if self.replication_key:
261-
params["order_by"] = f'+{self.replication_key}'
262-
return params
263-
264-
def parse_response(self, response: requests.Response) -> t.Iterable[dict]:
265-
yield from extract_jsonpath("$.data[*]", input=response.json())
268+
).to_dict()

tap_clerk/tap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def discover_streams(self) -> list[streams.ClerkStream]:
2424
streams.OrganizationMembershipStream(self),
2525
streams.UsersStream(self),
2626
streams.WaitlistEntriesStream(self),
27+
streams.OrganizationInvitationsStream(self),
2728
]
2829

2930
if __name__ == "__main__":
30-
TapClerk.cli()
31+
TapClerk.cli()

0 commit comments

Comments
 (0)