Skip to content

Commit 5007b6f

Browse files
committed
Type integration_events() as the list the endpoint returns
GET .../integrations/{integration_id}/events answers with a bare JSON array of events. The method was annotated -> dict and fell back to {}, and its test mocked a {"results": [...]} wrapper the API never sends. The annotation and fallback are now a list, and the fixture has the shape of a real event.
1 parent 94df69d commit 5007b6f

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
`GET orgs/{org_slug}/settings/integrations/{integration_id}/events`. It
99
previously requested the integration's own path, which has no `GET` route,
1010
so the method always failed. It needs the `integration:list` scope.
11+
- Its return annotation is now `list`, matching the JSON array the endpoint
12+
returns.
1113

1214
## 3.6.2
1315

‎socketdev/settings/__init__.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,15 @@ def get(
108108
)
109109
return {}
110110

111-
def integration_events(self, org_slug: str, integration_id: str) -> dict:
111+
def integration_events(self, org_slug: str, integration_id: str) -> list:
112112
"""Get integration events for a specific integration.
113113
114114
Args:
115115
org_slug: Organization slug
116116
integration_id: Integration ID
117+
118+
Returns:
119+
The integration's events, as the list the API returns.
117120
"""
118121
path = f"orgs/{org_slug}/settings/integrations/{integration_id}/events"
119122
response = self.api.do_request(path=path)
@@ -123,7 +126,7 @@ def integration_events(self, org_slug: str, integration_id: str) -> dict:
123126

124127
error_message = response.json().get("error", {}).get("message", "Unknown error")
125128
log.error(f"Error getting integration events: {response.status_code}, message: {error_message}")
126-
return {}
129+
return []
127130

128131
def get_license_policy(self, org_slug: str) -> dict:
129132
"""Get license policy settings for an organization.

‎tests/unit/test_all_endpoints_unit.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,20 @@ def test_settings_get_unit(self):
738738

739739
def test_settings_integration_events_unit(self):
740740
"""Test integration events retrieval."""
741-
expected_data = {"results": [{"id": "event-1"}]}
741+
expected_data = [
742+
{
743+
"id": "event-1",
744+
"integration_id": "integration-1",
745+
"type": "alert",
746+
"payload": {},
747+
"status_code": 200,
748+
"error": "",
749+
"sent_at": "2026-01-01T00:00:00.000Z",
750+
"retry_info": [],
751+
"created_at": "2026-01-01T00:00:00.000Z",
752+
"updated_at": "2026-01-01T00:00:00.000Z",
753+
}
754+
]
742755
self._mock_response(expected_data)
743756

744757
result = self.sdk.settings.integration_events("test-org", "integration-1")

0 commit comments

Comments
 (0)