Skip to content

Commit 11b1c3d

Browse files
feat: Add the users history stream' (#60)
1 parent 74fcd7b commit 11b1c3d

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# tap-jotform
44

5-
<div
5+
<div>
66
<a href="https://results.pre-commit.ci/latest/github/edgarrmondragon/tap-jotform/main">
77
<img alt="pre-commit.ci status" src="https://results.pre-commit.ci/badge/github/edgarrmondragon/tap-jotform/main.svg"/>
88
</a>

tap_jotform/streams.py

+49-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from __future__ import annotations
44

55
import json
6-
from typing import Generator
6+
from datetime import date
7+
from typing import Any, Generator
78

89
import requests
910
from singer_sdk import typing as th # JSON Schema typing helpers
@@ -231,3 +232,50 @@ def post_process(self, row: dict, context: dict | None = None) -> dict:
231232
fields = row.get("fields") or ""
232233
row["fields"] = fields.split(",")
233234
return row
235+
236+
237+
class UserHistory(JotformStream):
238+
"""User History stream."""
239+
240+
name = "user_history"
241+
path = "/user/history"
242+
243+
schema = th.PropertiesList(
244+
th.Property(
245+
"type",
246+
th.StringType,
247+
allowed_values=[
248+
"userCreation",
249+
"userLogin",
250+
"formCreation",
251+
"formUpdate",
252+
"formDelete",
253+
"formPurge",
254+
],
255+
),
256+
th.Property("username", th.StringType),
257+
th.Property("ip", th.StringType),
258+
th.Property("server", th.StringType),
259+
th.Property("timestamp", th.IntegerType),
260+
th.Property("email", th.EmailType),
261+
th.Property("parent", th.StringType),
262+
th.Property("subuser", th.StringType),
263+
).to_dict()
264+
265+
def get_url_params(
266+
self, context: dict | None, next_page_token: tuple[date, date] | None
267+
) -> dict[str, Any]:
268+
"""Get the URL parameters.
269+
270+
Args:
271+
context: The context object.
272+
next_page_token: The next page token.
273+
274+
Returns:
275+
The URL parameters.
276+
"""
277+
params = super().get_url_params(context, next_page_token)
278+
params["action"] = "all"
279+
params["date"] = "all"
280+
params["sortBy"] = "ASC"
281+
return params

tap_jotform/tap.py

+1
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ def discover_streams(self) -> list[Stream]:
9595
streams.QuestionsStream(self),
9696
streams.SubmissionsStream(self),
9797
streams.ReportsStream(self),
98+
streams.UserHistory(self),
9899
]

0 commit comments

Comments
 (0)