cryptascreen 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. cryptascreen/__init__.py +61 -0
  2. cryptascreen/_util.py +111 -0
  3. cryptascreen/_version.py +3 -0
  4. cryptascreen/client.py +231 -0
  5. cryptascreen/config.py +48 -0
  6. cryptascreen/errors.py +217 -0
  7. cryptascreen/helpers.py +47 -0
  8. cryptascreen/operations.py +131 -0
  9. cryptascreen/resources/__init__.py +1 -0
  10. cryptascreen/resources/alerts.py +51 -0
  11. cryptascreen/resources/auth.py +36 -0
  12. cryptascreen/resources/capabilities.py +36 -0
  13. cryptascreen/resources/cases.py +198 -0
  14. cryptascreen/resources/compliance.py +116 -0
  15. cryptascreen/resources/graph.py +70 -0
  16. cryptascreen/resources/intelligence.py +69 -0
  17. cryptascreen/resources/monitoring.py +142 -0
  18. cryptascreen/resources/names.py +97 -0
  19. cryptascreen/resources/sanctions.py +50 -0
  20. cryptascreen/resources/screening.py +379 -0
  21. cryptascreen/resources/settings.py +115 -0
  22. cryptascreen/resources/webhooks.py +55 -0
  23. cryptascreen/retry.py +176 -0
  24. cryptascreen/signature.py +118 -0
  25. cryptascreen/types/__init__.py +313 -0
  26. cryptascreen/types/_account.py +199 -0
  27. cryptascreen/types/_models.py +1620 -0
  28. cryptascreen/types/cases.py +31 -0
  29. cryptascreen/types/common.py +17 -0
  30. cryptascreen/types/compliance.py +27 -0
  31. cryptascreen/types/graph.py +25 -0
  32. cryptascreen/types/intelligence.py +11 -0
  33. cryptascreen/types/names.py +39 -0
  34. cryptascreen/types/sanctions.py +13 -0
  35. cryptascreen/types/screening.py +73 -0
  36. cryptascreen/types/wallet.py +85 -0
  37. cryptascreen/types/webhooks.py +13 -0
  38. cryptascreen-0.2.0.dist-info/METADATA +305 -0
  39. cryptascreen-0.2.0.dist-info/RECORD +41 -0
  40. cryptascreen-0.2.0.dist-info/WHEEL +4 -0
  41. cryptascreen-0.2.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,47 @@
1
+ """Narrowing and display helpers (ports of the helpers exported by @cryptascreen/sdk types)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from cryptascreen._util import is_terminal_job_status # noqa: F401 (re-exported)
8
+ from cryptascreen.types._models import (
9
+ GraphResponse,
10
+ NameScreenResponse,
11
+ ScreeningResponse,
12
+ WalletCategoryPart,
13
+ )
14
+
15
+
16
+ def is_assessed(r: ScreeningResponse) -> bool:
17
+ """True when the address was assessed (risk level is not UNKNOWN and a score exists)."""
18
+ return r.risk_level != "UNKNOWN" and r.risk_score is not None
19
+
20
+
21
+ def sanctions_layer_complete(r: ScreeningResponse) -> bool:
22
+ """True only when the mandatory sanctions layer was COMPLETE; anything else is not an all-clear."""
23
+ layers: Any = r.layers
24
+ return bool(layers and layers.sanctions and layers.sanctions.state == "COMPLETE")
25
+
26
+
27
+ def is_name_clear(r: NameScreenResponse) -> bool:
28
+ """True only for a completed screening whose outcome is CLEAR. Anything else needs a person to look."""
29
+ return r.outcome == "CLEAR"
30
+
31
+
32
+ def is_graph_complete(r: GraphResponse) -> bool:
33
+ """True only when the API states the graph read was COMPLETE (null status: legacy ``truncated`` flag)."""
34
+ s = r.stats
35
+ if s is None:
36
+ return False
37
+ if s.status is not None:
38
+ return bool(s.status == "COMPLETE")
39
+ return s.truncated is False
40
+
41
+
42
+ def category_share_label(part: WalletCategoryPart, digits: int = 1) -> str:
43
+ """``n/a`` for a part without numbers, ``>= x%`` (as ``≥ x%``) for a lower bound, else ``x%``. Never renders null as 0%."""
44
+ if part.state == "NOT_ANALYZED" or part.usd_share is None:
45
+ return "n/a"
46
+ pct = f"{float(part.usd_share) * 100:.{digits}f}%"
47
+ return pct if part.state == "COMPLETE" else "≥ " + pct
@@ -0,0 +1,131 @@
1
+ """Operation table: SDK method -> HTTP method + path (generated). Checked against the customer API operations by the test-suite."""
2
+
3
+ from __future__ import annotations
4
+
5
+ # (resource, python method, TS method, HTTP method, path relative to /api/v1)
6
+ OPERATIONS: list[tuple[str, str, str, str | None, str | None]] = [
7
+ ("screening", "screen_address", "screenAddress", "POST", "/screen/address"),
8
+ ("screening", "screen_bulk", "screenBulk", "POST", "/screen/bulk"),
9
+ ("screening", "screen_bulk_async", "screenBulkAsync", "POST", "/screen/bulk"),
10
+ ("screening", "poll_job", "pollJob", "GET", "/screen/jobs/{jobId}"),
11
+ ("screening", "list_jobs", "listJobs", "GET", "/screen/jobs"),
12
+ ("screening", "get_job_results", "getJobResults", "GET", "/screen/jobs/{jobId}/results"),
13
+ ("screening", "cancel_job", "cancelJob", "POST", "/screen/jobs/{jobId}/cancel"),
14
+ ("screening", "get_history", "getHistory", "GET", "/screen/address/{chain}/{address}/history"),
15
+ (
16
+ "screening",
17
+ "list_evaluations",
18
+ "listEvaluations",
19
+ "GET",
20
+ "/screen/address/{chain}/{address}/evaluations",
21
+ ),
22
+ (
23
+ "screening",
24
+ "get_counterparties",
25
+ "getCounterparties",
26
+ "GET",
27
+ "/screen/address/{chain}/{address}/counterparties",
28
+ ),
29
+ (
30
+ "screening",
31
+ "get_transactions",
32
+ "getTransactions",
33
+ "GET",
34
+ "/screen/address/{chain}/{address}/transactions",
35
+ ),
36
+ (
37
+ "screening",
38
+ "get_exposure_paths",
39
+ "getExposurePaths",
40
+ "GET",
41
+ "/screen/address/{chain}/{address}/exposure-paths",
42
+ ),
43
+ ("screening", "get_evaluation", "getEvaluation", "GET", "/screen/evaluations/{evaluationId}"),
44
+ ("screening", "screen_bulk_and_wait", "screenBulkAndWait", None, None),
45
+ ("sanctions", "check", "check", "GET", "/sanctions/check/{chain}/{address}"),
46
+ ("sanctions", "get_status", "getStatus", "GET", "/sanctions/status"),
47
+ ("names", "screen", "screen", "POST", "/screen/name"),
48
+ ("names", "get", "get", "GET", "/screen/name/{screeningId}"),
49
+ ("names", "history", "history", "GET", "/screen/name/history"),
50
+ ("names", "decide", "decide", "POST", "/screen/name/decisions"),
51
+ ("names", "decision_audit", "decisionAudit", "GET", "/screen/name/decisions/audit"),
52
+ ("graph", "build_graph", "buildGraph", "POST", "/investigate/graph"),
53
+ ("graph", "export_graph", "exportGraph", "POST", "/investigate/graph/export"),
54
+ ("graph", "trace", "trace", "POST", "/investigate/trace"),
55
+ ("cases", "create", "create", "POST", "/cases"),
56
+ ("cases", "list", "list", "GET", "/cases"),
57
+ ("cases", "get", "get", "GET", "/cases/{caseId}"),
58
+ ("cases", "update_status", "updateStatus", "PUT", "/cases/{caseId}/status"),
59
+ ("cases", "add_note", "addNote", "POST", "/cases/{caseId}/notes"),
60
+ ("cases", "add_evidence", "addEvidence", "POST", "/cases/{caseId}/evidence"),
61
+ ("cases", "escalate", "escalate", "POST", "/cases/{caseId}/escalate"),
62
+ ("cases", "get_assignment", "getAssignment", "GET", "/cases/{caseId}/assignment"),
63
+ ("cases", "set_assignee", "setAssignee", "PUT", "/cases/{caseId}/assignee"),
64
+ ("cases", "link_evaluation", "linkEvaluation", "POST", "/cases/{caseId}/evaluations"),
65
+ ("alerts", "get", "get", "GET", "/alerts/{id}"),
66
+ ("alerts", "acknowledge", "acknowledge", "POST", "/alerts/{id}/acknowledge"),
67
+ ("compliance", "check_travel_rule", "checkTravelRule", "POST", "/compliance/travel-rule/check"),
68
+ (
69
+ "compliance",
70
+ "build_travel_rule_payload",
71
+ "buildTravelRulePayload",
72
+ "POST",
73
+ "/compliance/travel-rule/payload",
74
+ ),
75
+ (
76
+ "compliance",
77
+ "identify_vasp",
78
+ "identifyVasp",
79
+ "GET",
80
+ "/compliance/travel-rule/vasp/identify/{chain}/{address}",
81
+ ),
82
+ ("compliance", "generate_dac8_report", "generateDac8Report", "POST", "/compliance/dac8/report"),
83
+ (
84
+ "intelligence",
85
+ "get_entity_labels",
86
+ "getEntityLabels",
87
+ "GET",
88
+ "/intelligence/entity/{chain}/{address}",
89
+ ),
90
+ ("intelligence", "get_entity_label", "getEntityLabel", None, None),
91
+ ("intelligence", "get_vasp_info", "getVaspInfo", None, None),
92
+ ("webhooks", "list", "list", "GET", "/webhooks"),
93
+ ("webhooks", "get_deliveries", "getDeliveries", "GET", "/webhooks/{webhookId}/deliveries"),
94
+ ("auth", "me", "me", "GET", "/auth/me"),
95
+ ("capabilities", "get", "get", "GET", "/capabilities"),
96
+ ("settings", "get_score_thresholds", "getScoreThresholds", "GET", "/settings/score-thresholds"),
97
+ (
98
+ "settings",
99
+ "get_score_threshold_audit",
100
+ "getScoreThresholdAudit",
101
+ "GET",
102
+ "/settings/score-thresholds/audit",
103
+ ),
104
+ ("settings", "get_name_matching", "getNameMatching", "GET", "/settings/name-matching"),
105
+ (
106
+ "settings",
107
+ "get_name_matching_audit",
108
+ "getNameMatchingAudit",
109
+ "GET",
110
+ "/settings/name-matching/audit",
111
+ ),
112
+ ("settings", "get_name_lists", "getNameLists", "GET", "/settings/name-lists"),
113
+ ("settings", "get_name_list_audit", "getNameListAudit", "GET", "/settings/name-lists/audit"),
114
+ ("settings", "list_vendor_keys", "listVendorKeys", "GET", "/settings/vendor-keys"),
115
+ ("monitoring", "list_wallets", "listWallets", "GET", "/monitoring/wallets"),
116
+ ("monitoring", "add_wallet", "addWallet", "POST", "/monitoring/wallets"),
117
+ ("monitoring", "remove_wallet", "removeWallet", "DELETE", "/monitoring/wallets/{id}"),
118
+ ("monitoring", "list_names", "listNames", "GET", "/monitoring/names"),
119
+ ("monitoring", "add_name", "addName", "POST", "/monitoring/names"),
120
+ ("monitoring", "remove_name", "removeName", "DELETE", "/monitoring/names/{id}"),
121
+ ("monitoring", "get_overview", "getOverview", "GET", "/monitoring/overview"),
122
+ ("monitoring", "list_breaches", "listBreaches", "GET", "/monitoring/breaches"),
123
+ ("monitoring", "get_breach_summary", "getBreachSummary", "GET", "/monitoring/breaches/summary"),
124
+ (
125
+ "monitoring",
126
+ "acknowledge_breach",
127
+ "acknowledgeBreach",
128
+ "POST",
129
+ "/monitoring/breaches/{id}/acknowledge",
130
+ ),
131
+ ]
@@ -0,0 +1 @@
1
+ """API resources."""
@@ -0,0 +1,51 @@
1
+ """Alerts resource (mirrors @cryptascreen/sdk alerts endpoints)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from cryptascreen._util import _enc
8
+ from cryptascreen.types._models import (
9
+ AlertDetail,
10
+ )
11
+
12
+ if TYPE_CHECKING:
13
+ from cryptascreen.client import AsyncHttpClient, HttpClient
14
+
15
+
16
+ class AlertsResource:
17
+ """Synchronous alerts operations. Access via ``client.alerts``."""
18
+
19
+ def __init__(self, http: HttpClient) -> None:
20
+ self._http = http
21
+
22
+ def get(self, id: str) -> AlertDetail:
23
+ """GET /alerts/{id}"""
24
+ data = self._http.request("GET", f"/api/v1/alerts/{_enc(id)}")
25
+ return AlertDetail.model_validate(data)
26
+
27
+ def acknowledge(self, id: int | str, note: str | None = None) -> AlertDetail:
28
+ """Acknowledge an alert. Idempotent: a repeat returns the stored acknowledgement with alreadyAcknowledged true."""
29
+ body = {"note": note.strip()} if note and note.strip() else {}
30
+ data = self._http.request("POST", f"/api/v1/alerts/{_enc(str(id))}/acknowledge", json=body)
31
+ return AlertDetail.model_validate(data)
32
+
33
+
34
+ class AsyncAlertsResource:
35
+ """Asynchronous alerts operations. Access via ``client.alerts``."""
36
+
37
+ def __init__(self, http: AsyncHttpClient) -> None:
38
+ self._http = http
39
+
40
+ async def get(self, id: str) -> AlertDetail:
41
+ """GET /alerts/{id}"""
42
+ data = await self._http.request("GET", f"/api/v1/alerts/{_enc(id)}")
43
+ return AlertDetail.model_validate(data)
44
+
45
+ async def acknowledge(self, id: int | str, note: str | None = None) -> AlertDetail:
46
+ """Acknowledge an alert. Idempotent: a repeat returns the stored acknowledgement with alreadyAcknowledged true."""
47
+ body = {"note": note.strip()} if note and note.strip() else {}
48
+ data = await self._http.request(
49
+ "POST", f"/api/v1/alerts/{_enc(str(id))}/acknowledge", json=body
50
+ )
51
+ return AlertDetail.model_validate(data)
@@ -0,0 +1,36 @@
1
+ """Caller identity (resource ``client.auth``)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from cryptascreen.types._account import (
8
+ AuthMe,
9
+ )
10
+
11
+ if TYPE_CHECKING:
12
+ from cryptascreen.client import AsyncHttpClient, HttpClient
13
+
14
+
15
+ class AuthResource:
16
+ """Synchronous caller identity. Access via ``client.auth``."""
17
+
18
+ def __init__(self, http: HttpClient) -> None:
19
+ self._http = http
20
+
21
+ def me(self) -> AuthMe:
22
+ """The calling identity. With an API key this is the key's tenant owner (authMethod API_KEY)."""
23
+ data = self._http.request("GET", "/api/v1/auth/me")
24
+ return AuthMe.model_validate(data)
25
+
26
+
27
+ class AsyncAuthResource:
28
+ """Asynchronous caller identity. Access via ``client.auth``."""
29
+
30
+ def __init__(self, http: AsyncHttpClient) -> None:
31
+ self._http = http
32
+
33
+ async def me(self) -> AuthMe:
34
+ """The calling identity. With an API key this is the key's tenant owner (authMethod API_KEY)."""
35
+ data = await self._http.request("GET", "/api/v1/auth/me")
36
+ return AuthMe.model_validate(data)
@@ -0,0 +1,36 @@
1
+ """Chains and layers (resource ``client.capabilities``)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from cryptascreen.types._account import (
8
+ Capabilities,
9
+ )
10
+
11
+ if TYPE_CHECKING:
12
+ from cryptascreen.client import AsyncHttpClient, HttpClient
13
+
14
+
15
+ class CapabilitiesResource:
16
+ """Synchronous chains and layers. Access via ``client.capabilities``."""
17
+
18
+ def __init__(self, http: HttpClient) -> None:
19
+ self._http = http
20
+
21
+ def get(self) -> Capabilities:
22
+ """Chains the screening API accepts (on-chain COVERED / UNAVAILABLE) and the live layer state (ON / OFF)."""
23
+ data = self._http.request("GET", "/api/v1/capabilities")
24
+ return Capabilities.model_validate(data)
25
+
26
+
27
+ class AsyncCapabilitiesResource:
28
+ """Asynchronous chains and layers. Access via ``client.capabilities``."""
29
+
30
+ def __init__(self, http: AsyncHttpClient) -> None:
31
+ self._http = http
32
+
33
+ async def get(self) -> Capabilities:
34
+ """Chains the screening API accepts (on-chain COVERED / UNAVAILABLE) and the live layer state (ON / OFF)."""
35
+ data = await self._http.request("GET", "/api/v1/capabilities")
36
+ return Capabilities.model_validate(data)
@@ -0,0 +1,198 @@
1
+ """Cases resource (mirrors @cryptascreen/sdk cases endpoints)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from cryptascreen._util import _body, _enc, _query
8
+ from cryptascreen.types._models import (
9
+ AddEvidenceRequest,
10
+ AddNoteRequest,
11
+ CaseAssignment,
12
+ CaseEvidence,
13
+ CaseNote,
14
+ CreateCaseRequest,
15
+ EscalateCaseRequest,
16
+ InvestigationCase,
17
+ PaginatedResponse,
18
+ UpdateCaseStatusRequest,
19
+ )
20
+
21
+ if TYPE_CHECKING:
22
+ from cryptascreen.client import AsyncHttpClient, HttpClient
23
+
24
+
25
+ class CasesResource:
26
+ """Synchronous cases operations. Access via ``client.cases``."""
27
+
28
+ def __init__(self, http: HttpClient) -> None:
29
+ self._http = http
30
+
31
+ def create(self, request: CreateCaseRequest | dict[str, Any]) -> InvestigationCase:
32
+ """POST /cases"""
33
+ data = self._http.request("POST", "/api/v1/cases", json=_body(request))
34
+ return InvestigationCase.model_validate(data)
35
+
36
+ def list(
37
+ self,
38
+ *,
39
+ status: str | None = None,
40
+ priority: str | None = None,
41
+ page: int | None = None,
42
+ page_size: int | None = None,
43
+ ) -> PaginatedResponse[InvestigationCase]:
44
+ """GET /cases"""
45
+ data = self._http.request(
46
+ "GET",
47
+ "/api/v1/cases",
48
+ params=_query(status=status, priority=priority, page=page, pageSize=page_size),
49
+ )
50
+ return PaginatedResponse[InvestigationCase].model_validate(data)
51
+
52
+ def get(self, case_id: str) -> InvestigationCase:
53
+ """GET /cases/{caseId}"""
54
+ data = self._http.request("GET", f"/api/v1/cases/{_enc(case_id)}")
55
+ return InvestigationCase.model_validate(data)
56
+
57
+ def update_status(
58
+ self, case_id: str, request: UpdateCaseStatusRequest | dict[str, Any]
59
+ ) -> InvestigationCase:
60
+ """PUT /cases/{caseId}/status"""
61
+ data = self._http.request(
62
+ "PUT", f"/api/v1/cases/{_enc(case_id)}/status", json=_body(request)
63
+ )
64
+ return InvestigationCase.model_validate(data)
65
+
66
+ def add_note(self, case_id: str, request: AddNoteRequest | dict[str, Any]) -> CaseNote:
67
+ """POST /cases/{caseId}/notes"""
68
+ data = self._http.request(
69
+ "POST", f"/api/v1/cases/{_enc(case_id)}/notes", json=_body(request)
70
+ )
71
+ return CaseNote.model_validate(data)
72
+
73
+ def add_evidence(
74
+ self, case_id: str, request: AddEvidenceRequest | dict[str, Any]
75
+ ) -> CaseEvidence:
76
+ """POST /cases/{caseId}/evidence"""
77
+ data = self._http.request(
78
+ "POST", f"/api/v1/cases/{_enc(case_id)}/evidence", json=_body(request)
79
+ )
80
+ return CaseEvidence.model_validate(data)
81
+
82
+ def escalate(
83
+ self, case_id: str, request: EscalateCaseRequest | dict[str, Any]
84
+ ) -> InvestigationCase:
85
+ """POST /cases/{caseId}/escalate"""
86
+ data = self._http.request(
87
+ "POST", f"/api/v1/cases/{_enc(case_id)}/escalate", json=_body(request)
88
+ )
89
+ return InvestigationCase.model_validate(data)
90
+
91
+ def get_assignment(self, case_id: str) -> CaseAssignment:
92
+ """GET /cases/{caseId}/assignment"""
93
+ data = self._http.request("GET", f"/api/v1/cases/{_enc(case_id)}/assignment")
94
+ return CaseAssignment.model_validate(data)
95
+
96
+ def set_assignee(self, case_id: str, user_id: int | None) -> CaseAssignment:
97
+ """Assign the case to a user of your organization, or unassign with ``None``."""
98
+ data = self._http.request(
99
+ "PUT", f"/api/v1/cases/{_enc(case_id)}/assignee", json={"userId": user_id}
100
+ )
101
+ return CaseAssignment.model_validate(data)
102
+
103
+ def link_evaluation(self, case_id: str, evaluation_id: str) -> CaseAssignment:
104
+ """Link a screening evaluation of your organization to the case (idempotent)."""
105
+ data = self._http.request(
106
+ "POST",
107
+ f"/api/v1/cases/{_enc(case_id)}/evaluations",
108
+ json={"evaluationId": evaluation_id},
109
+ )
110
+ return CaseAssignment.model_validate(data)
111
+
112
+
113
+ class AsyncCasesResource:
114
+ """Asynchronous cases operations. Access via ``client.cases``."""
115
+
116
+ def __init__(self, http: AsyncHttpClient) -> None:
117
+ self._http = http
118
+
119
+ async def create(self, request: CreateCaseRequest | dict[str, Any]) -> InvestigationCase:
120
+ """POST /cases"""
121
+ data = await self._http.request("POST", "/api/v1/cases", json=_body(request))
122
+ return InvestigationCase.model_validate(data)
123
+
124
+ async def list(
125
+ self,
126
+ *,
127
+ status: str | None = None,
128
+ priority: str | None = None,
129
+ page: int | None = None,
130
+ page_size: int | None = None,
131
+ ) -> PaginatedResponse[InvestigationCase]:
132
+ """GET /cases"""
133
+ data = await self._http.request(
134
+ "GET",
135
+ "/api/v1/cases",
136
+ params=_query(status=status, priority=priority, page=page, pageSize=page_size),
137
+ )
138
+ return PaginatedResponse[InvestigationCase].model_validate(data)
139
+
140
+ async def get(self, case_id: str) -> InvestigationCase:
141
+ """GET /cases/{caseId}"""
142
+ data = await self._http.request("GET", f"/api/v1/cases/{_enc(case_id)}")
143
+ return InvestigationCase.model_validate(data)
144
+
145
+ async def update_status(
146
+ self, case_id: str, request: UpdateCaseStatusRequest | dict[str, Any]
147
+ ) -> InvestigationCase:
148
+ """PUT /cases/{caseId}/status"""
149
+ data = await self._http.request(
150
+ "PUT", f"/api/v1/cases/{_enc(case_id)}/status", json=_body(request)
151
+ )
152
+ return InvestigationCase.model_validate(data)
153
+
154
+ async def add_note(self, case_id: str, request: AddNoteRequest | dict[str, Any]) -> CaseNote:
155
+ """POST /cases/{caseId}/notes"""
156
+ data = await self._http.request(
157
+ "POST", f"/api/v1/cases/{_enc(case_id)}/notes", json=_body(request)
158
+ )
159
+ return CaseNote.model_validate(data)
160
+
161
+ async def add_evidence(
162
+ self, case_id: str, request: AddEvidenceRequest | dict[str, Any]
163
+ ) -> CaseEvidence:
164
+ """POST /cases/{caseId}/evidence"""
165
+ data = await self._http.request(
166
+ "POST", f"/api/v1/cases/{_enc(case_id)}/evidence", json=_body(request)
167
+ )
168
+ return CaseEvidence.model_validate(data)
169
+
170
+ async def escalate(
171
+ self, case_id: str, request: EscalateCaseRequest | dict[str, Any]
172
+ ) -> InvestigationCase:
173
+ """POST /cases/{caseId}/escalate"""
174
+ data = await self._http.request(
175
+ "POST", f"/api/v1/cases/{_enc(case_id)}/escalate", json=_body(request)
176
+ )
177
+ return InvestigationCase.model_validate(data)
178
+
179
+ async def get_assignment(self, case_id: str) -> CaseAssignment:
180
+ """GET /cases/{caseId}/assignment"""
181
+ data = await self._http.request("GET", f"/api/v1/cases/{_enc(case_id)}/assignment")
182
+ return CaseAssignment.model_validate(data)
183
+
184
+ async def set_assignee(self, case_id: str, user_id: int | None) -> CaseAssignment:
185
+ """Assign the case to a user of your organization, or unassign with ``None``."""
186
+ data = await self._http.request(
187
+ "PUT", f"/api/v1/cases/{_enc(case_id)}/assignee", json={"userId": user_id}
188
+ )
189
+ return CaseAssignment.model_validate(data)
190
+
191
+ async def link_evaluation(self, case_id: str, evaluation_id: str) -> CaseAssignment:
192
+ """Link a screening evaluation of your organization to the case (idempotent)."""
193
+ data = await self._http.request(
194
+ "POST",
195
+ f"/api/v1/cases/{_enc(case_id)}/evaluations",
196
+ json={"evaluationId": evaluation_id},
197
+ )
198
+ return CaseAssignment.model_validate(data)
@@ -0,0 +1,116 @@
1
+ """Compliance resource (mirrors @cryptascreen/sdk compliance endpoints)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from cryptascreen._util import _body, _enc
8
+ from cryptascreen.errors import ValidationError
9
+ from cryptascreen.types._models import (
10
+ Dac8ReportRequest,
11
+ Dac8ReportResult,
12
+ TravelRuleCheckRequest,
13
+ TravelRuleCheckResult,
14
+ TravelRulePayload,
15
+ TravelRulePayloadRequest,
16
+ VaspIdentification,
17
+ )
18
+
19
+ if TYPE_CHECKING:
20
+ from cryptascreen.client import AsyncHttpClient, HttpClient
21
+
22
+
23
+ class ComplianceResource:
24
+ """Synchronous compliance operations. Access via ``client.compliance``."""
25
+
26
+ def __init__(self, http: HttpClient) -> None:
27
+ self._http = http
28
+
29
+ def check_travel_rule(
30
+ self, request: TravelRuleCheckRequest | dict[str, Any]
31
+ ) -> TravelRuleCheckResult:
32
+ """POST /compliance/travel-rule/check"""
33
+ data = self._http.request(
34
+ "POST", "/api/v1/compliance/travel-rule/check", json=_body(request)
35
+ )
36
+ return TravelRuleCheckResult.model_validate(data)
37
+
38
+ def build_travel_rule_payload(
39
+ self, request: TravelRulePayloadRequest | dict[str, Any]
40
+ ) -> TravelRulePayload:
41
+ """POST /compliance/travel-rule/payload"""
42
+ data = self._http.request(
43
+ "POST", "/api/v1/compliance/travel-rule/payload", json=_body(request)
44
+ )
45
+ return TravelRulePayload.model_validate(data)
46
+
47
+ def identify_vasp(self, chain: str, address: str) -> VaspIdentification:
48
+ """GET /compliance/travel-rule/vasp/identify/{chain}/{address}"""
49
+ data = self._http.request(
50
+ "GET", f"/api/v1/compliance/travel-rule/vasp/identify/{_enc(chain)}/{_enc(address)}"
51
+ )
52
+ return VaspIdentification.model_validate(data)
53
+
54
+ def generate_dac8_report(self, request: Dac8ReportRequest | dict[str, Any]) -> Dac8ReportResult:
55
+ """Deprecated: DAC8 reporting is deferred (unvalidated draft, not a filing). A request of the 0.1.x shape raises ValidationError client-side."""
56
+ body = _body(request)
57
+ missing = [
58
+ k for k in ("taxYear", "jurisdiction", "operator", "users") if body.get(k) is None
59
+ ]
60
+ if missing:
61
+ raise ValidationError(
62
+ f"DAC8 report request requires {', '.join(missing)} (DAC8 is deferred; see CHANGELOG)",
63
+ {k: ["required"] for k in missing},
64
+ validation_code="DAC8_REQUEST_SHAPE",
65
+ )
66
+ data = self._http.request("POST", "/api/v1/compliance/dac8/report", json=body)
67
+ return Dac8ReportResult.model_validate(data)
68
+
69
+
70
+ class AsyncComplianceResource:
71
+ """Asynchronous compliance operations. Access via ``client.compliance``."""
72
+
73
+ def __init__(self, http: AsyncHttpClient) -> None:
74
+ self._http = http
75
+
76
+ async def check_travel_rule(
77
+ self, request: TravelRuleCheckRequest | dict[str, Any]
78
+ ) -> TravelRuleCheckResult:
79
+ """POST /compliance/travel-rule/check"""
80
+ data = await self._http.request(
81
+ "POST", "/api/v1/compliance/travel-rule/check", json=_body(request)
82
+ )
83
+ return TravelRuleCheckResult.model_validate(data)
84
+
85
+ async def build_travel_rule_payload(
86
+ self, request: TravelRulePayloadRequest | dict[str, Any]
87
+ ) -> TravelRulePayload:
88
+ """POST /compliance/travel-rule/payload"""
89
+ data = await self._http.request(
90
+ "POST", "/api/v1/compliance/travel-rule/payload", json=_body(request)
91
+ )
92
+ return TravelRulePayload.model_validate(data)
93
+
94
+ async def identify_vasp(self, chain: str, address: str) -> VaspIdentification:
95
+ """GET /compliance/travel-rule/vasp/identify/{chain}/{address}"""
96
+ data = await self._http.request(
97
+ "GET", f"/api/v1/compliance/travel-rule/vasp/identify/{_enc(chain)}/{_enc(address)}"
98
+ )
99
+ return VaspIdentification.model_validate(data)
100
+
101
+ async def generate_dac8_report(
102
+ self, request: Dac8ReportRequest | dict[str, Any]
103
+ ) -> Dac8ReportResult:
104
+ """Deprecated: DAC8 reporting is deferred (unvalidated draft, not a filing). A request of the 0.1.x shape raises ValidationError client-side."""
105
+ body = _body(request)
106
+ missing = [
107
+ k for k in ("taxYear", "jurisdiction", "operator", "users") if body.get(k) is None
108
+ ]
109
+ if missing:
110
+ raise ValidationError(
111
+ f"DAC8 report request requires {', '.join(missing)} (DAC8 is deferred; see CHANGELOG)",
112
+ {k: ["required"] for k in missing},
113
+ validation_code="DAC8_REQUEST_SHAPE",
114
+ )
115
+ data = await self._http.request("POST", "/api/v1/compliance/dac8/report", json=body)
116
+ return Dac8ReportResult.model_validate(data)