Skip to content

Commit bdfeef4

Browse files
committed
Updates for API Keys list shape
Instead of returning the key `api_keys`, we will return `data`, which is more consistent with other API endpoints.
1 parent 84af458 commit bdfeef4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

apikey.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ type APIKeyWithSecret struct {
3434
// APIKeyList represents a list of API keys without secrets.
3535
type APIKeyList struct {
3636
APIResource
37-
APIKeys []*APIKey `json:"api_keys"`
37+
APIKeys []*APIKey `json:"data"`
38+
TotalCount int64 `json:"total_count"`
3839
}

apikey/api_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestPackageList(t *testing.T) {
7272
t.Parallel()
7373

7474
response := map[string]interface{}{
75-
"api_keys": []map[string]interface{}{
75+
"data": []map[string]interface{}{
7676
{
7777
"object": "api_key",
7878
"id": "ak_test123",
@@ -92,6 +92,7 @@ func TestPackageList(t *testing.T) {
9292
"updated_at": 1640995200,
9393
},
9494
},
95+
"total_count": int64(1),
9596
}
9697

9798
responseJSON, _ := json.Marshal(response)
@@ -120,6 +121,7 @@ func TestPackageList(t *testing.T) {
120121

121122
apiKeys, err := List(context.Background(), params)
122123
require.NoError(t, err)
124+
assert.Equal(t, int64(1), apiKeys.TotalCount)
123125
assert.Len(t, apiKeys.APIKeys, 1)
124126
assert.Equal(t, "ak_test123", apiKeys.APIKeys[0].ID)
125127
}

apikey/client_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestList(t *testing.T) {
6868
t.Parallel()
6969

7070
response := map[string]interface{}{
71-
"api_keys": []map[string]interface{}{
71+
"data": []map[string]interface{}{
7272
{
7373
"object": "api_key",
7474
"id": "ak_test123",
@@ -88,6 +88,7 @@ func TestList(t *testing.T) {
8888
"updated_at": 1640995200,
8989
},
9090
},
91+
"total_count": int64(1),
9192
}
9293

9394
responseJSON, _ := json.Marshal(response)
@@ -114,6 +115,7 @@ func TestList(t *testing.T) {
114115

115116
apiKeys, err := client.List(context.Background(), params)
116117
require.NoError(t, err)
118+
assert.Equal(t, int64(1), apiKeys.TotalCount)
117119
assert.Len(t, apiKeys.APIKeys, 1)
118120
assert.Equal(t, "ak_test123", apiKeys.APIKeys[0].ID)
119121
}

0 commit comments

Comments
 (0)