|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | from typing_extensions import ( |
2 | 4 | Iterable, |
3 | | - List, |
4 | | - Literal, |
5 | 5 | Protocol, |
6 | | - overload, |
7 | 6 | ) |
8 | 7 |
|
9 | | -from ..context import requires |
10 | | -from ..resources import Resource, ResourceSequence |
| 8 | +from ..resources import Resource, ResourceSequence, _ResourceSequence |
| 9 | +from .rename_params import rename_params |
11 | 10 |
|
12 | 11 |
|
13 | 12 | class Hit(Resource, Protocol): |
14 | 13 | pass |
15 | 14 |
|
16 | 15 |
|
17 | 16 | class Hits(ResourceSequence[Hit], Protocol): |
18 | | - pass |
| 17 | + def fetch( |
| 18 | + self, |
| 19 | + *, |
| 20 | + start: str = ..., |
| 21 | + end: str = ..., |
| 22 | + ) -> Iterable[Hit]: |
| 23 | + """ |
| 24 | + Fetch all content hit records matching the specified conditions. |
| 25 | +
|
| 26 | + Parameters |
| 27 | + ---------- |
| 28 | + start : str, not required |
| 29 | + The timestamp that starts the time window of interest in RFC 3339 format. |
| 30 | + Any hit information that happened prior to this timestamp will not be returned. |
| 31 | + Example: "2025-05-01T00:00:00Z" |
| 32 | + end : str, not required |
| 33 | + The timestamp that ends the time window of interest in RFC 3339 format. |
| 34 | + Any hit information that happened after this timestamp will not be returned. |
| 35 | + Example: "2025-05-02T00:00:00Z" |
| 36 | +
|
| 37 | + Returns |
| 38 | + ------- |
| 39 | + Iterable[Hit] |
| 40 | + All content hit records matching the specified conditions. |
| 41 | + """ |
| 42 | + ... |
| 43 | + |
| 44 | + def find_by( |
| 45 | + self, |
| 46 | + *, |
| 47 | + id: str = ..., # noqa: A002 |
| 48 | + content_guid: str = ..., |
| 49 | + user_guid: str = ..., |
| 50 | + timestamp: str = ..., |
| 51 | + ) -> Hit | None: |
| 52 | + """ |
| 53 | + Find the first hit record matching the specified conditions. |
| 54 | +
|
| 55 | + There is no implied ordering, so if order matters, you should specify it yourself. |
| 56 | +
|
| 57 | + Parameters |
| 58 | + ---------- |
| 59 | + id : str, not required |
| 60 | + The ID of the activity record. |
| 61 | + content_guid : str, not required |
| 62 | + The GUID, in RFC4122 format, of the content this information pertains to. |
| 63 | + user_guid : str, not required |
| 64 | + The GUID, in RFC4122 format, of the user that visited the content. |
| 65 | + May be null when the target content does not require a user session. |
| 66 | + timestamp : str, not required |
| 67 | + The timestamp, in RFC 3339 format, when the user visited the content. |
| 68 | +
|
| 69 | + Returns |
| 70 | + ------- |
| 71 | + Hit | None |
| 72 | + The first hit record matching the specified conditions, or `None` if no such record exists. |
| 73 | + """ |
| 74 | + ... |
| 75 | + |
| 76 | + |
| 77 | +class _Hits(_ResourceSequence, Hits): |
| 78 | + def fetch( |
| 79 | + self, |
| 80 | + **kwargs, |
| 81 | + ) -> Iterable[Hit]: |
| 82 | + """ |
| 83 | + Fetch all content hit records matching the specified conditions. |
| 84 | +
|
| 85 | + Parameters |
| 86 | + ---------- |
| 87 | + start : str, not required |
| 88 | + The timestamp that starts the time window of interest in RFC 3339 format. |
| 89 | + Any hit information that happened prior to this timestamp will not be returned. |
| 90 | + Example: "2025-05-01T00:00:00Z" |
| 91 | + end : str, not required |
| 92 | + The timestamp that ends the time window of interest in RFC 3339 format. |
| 93 | + Any hit information that happened after this timestamp will not be returned. |
| 94 | + Example: "2025-05-02T00:00:00Z" |
| 95 | +
|
| 96 | + Returns |
| 97 | + ------- |
| 98 | + Iterable[Hit] |
| 99 | + All content hit records matching the specified conditions. |
| 100 | + """ |
| 101 | + params = rename_params(kwargs) |
19 | 102 |
|
| 103 | + result = super().fetch(**params) |
20 | 104 |
|
21 | | -# TODO: |
22 | | -# fetch, find_by documentation |
23 | | -# - fetch function args are gonna be the query params |
24 | | -# - find_by is the object props |
25 | | -# if the server fails with extra query params that'd be bad. |
26 | | -# tests |
27 | | -# - reference packages_test file |
| 105 | + return result |
0 commit comments