|
3 | 3 | from __future__ import annotations
|
4 | 4 |
|
5 | 5 | import json
|
6 |
| -from typing import Generator |
| 6 | +from datetime import date |
| 7 | +from typing import Any, Generator |
7 | 8 |
|
8 | 9 | import requests
|
9 | 10 | 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:
|
231 | 232 | fields = row.get("fields") or ""
|
232 | 233 | row["fields"] = fields.split(",")
|
233 | 234 | 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 |
0 commit comments