Skip to content

Commit 04a28b5

Browse files
authored
Feat: add CGW Accounts API specification (#190)
Feat: add CGW Accounts API specification
1 parent 4f908a3 commit 04a28b5

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed

src/index.ts

+43
Original file line numberDiff line numberDiff line change
@@ -652,4 +652,47 @@ export function verifyAuth(body: operations['verify_auth']['parameters']['body']
652652
})
653653
}
654654

655+
export function createAccount(body: operations['create_account']['parameters']['body']) {
656+
return postEndpoint(baseUrl, '/v1/accounts', {
657+
body,
658+
credentials: 'include',
659+
})
660+
}
661+
662+
export function getAccount(address: string) {
663+
return getEndpoint(baseUrl, '/v1/accounts/{address}', {
664+
path: { address },
665+
credentials: 'include',
666+
})
667+
}
668+
669+
export function deleteAccount(address: string) {
670+
return deleteEndpoint(baseUrl, '/v1/accounts/{address}', {
671+
path: { address },
672+
credentials: 'include',
673+
})
674+
}
675+
676+
export function getAccountDataTypes() {
677+
return getEndpoint(baseUrl, '/v1/accounts/data-types')
678+
}
679+
680+
export function getAccountDataSettings(address: string) {
681+
return getEndpoint(baseUrl, '/v1/accounts/{address}/data-settings', {
682+
path: { address },
683+
credentials: 'include',
684+
})
685+
}
686+
687+
export function putAccountDataSettings(
688+
address: string,
689+
body: operations['put_account_data_settings']['parameters']['body'],
690+
) {
691+
return putEndpoint(baseUrl, '/v1/accounts/{address}/data-settings', {
692+
path: { address },
693+
body,
694+
credentials: 'include',
695+
})
696+
}
697+
655698
/* eslint-enable @typescript-eslint/explicit-module-boundary-types */

src/types/accounts.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export type Account = {
2+
id: string
3+
groupId: string | null
4+
address: `0x${string}`
5+
}
6+
7+
export type AccountDataType = {
8+
id: string
9+
name: string
10+
description: string | null
11+
isActive: boolean
12+
}
13+
14+
export type AccountDataSetting = {
15+
dataTypeId: string
16+
enabled: boolean
17+
}
18+
19+
export type CreateAccountRequest = {
20+
address: `0x${string}`
21+
}
22+
23+
export type UpsertAccountDataSettingsRequest = {
24+
accountDataSettings: AccountDataSetting[]
25+
}

src/types/api.ts

+121
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ import type { RelayCountResponse, RelayTransactionRequest, RelayTransactionRespo
4646
import type { RegisterRecoveryModuleRequestBody } from './recovery'
4747
import type { Contract } from './contracts'
4848
import type { AuthNonce } from './auth'
49+
import type {
50+
Account,
51+
AccountDataSetting,
52+
AccountDataType,
53+
CreateAccountRequest,
54+
UpsertAccountDataSettingsRequest,
55+
} from './accounts'
4956

5057
export type Primitive = string | number | boolean | null
5158

@@ -472,6 +479,39 @@ export interface paths extends PathRegistry {
472479
}
473480
}
474481
}
482+
'/v1/accounts': {
483+
post: operations['create_account']
484+
parameters: {
485+
path: null
486+
credentials: 'include'
487+
}
488+
}
489+
'/v1/accounts/{address}': {
490+
get: operations['get_account']
491+
delete: operations['delete_account']
492+
parameters: {
493+
path: {
494+
address: string
495+
}
496+
credentials: 'include'
497+
}
498+
}
499+
'/v1/accounts/data-types': {
500+
get: operations['get_account_data_types']
501+
parameters: {
502+
path: null
503+
}
504+
}
505+
'/v1/accounts/{address}/data-settings': {
506+
get: operations['get_account_data_settings']
507+
put: operations['put_account_data_settings']
508+
parameters: {
509+
path: {
510+
address: string
511+
}
512+
credentials: 'include'
513+
}
514+
}
475515
}
476516

477517
export interface operations {
@@ -1225,4 +1265,85 @@ export interface operations {
12251265
}
12261266
}
12271267
}
1268+
create_account: {
1269+
parameters: {
1270+
body: CreateAccountRequest
1271+
credentials: 'include'
1272+
}
1273+
responses: {
1274+
200: {
1275+
schema: Account
1276+
}
1277+
403: unknown
1278+
422: unknown
1279+
}
1280+
}
1281+
get_account_data_types: {
1282+
parameters: null
1283+
responses: {
1284+
200: {
1285+
schema: AccountDataType[]
1286+
}
1287+
}
1288+
}
1289+
get_account_data_settings: {
1290+
parameters: {
1291+
path: {
1292+
address: string
1293+
}
1294+
credentials: 'include'
1295+
}
1296+
responses: {
1297+
200: {
1298+
schema: AccountDataSetting[]
1299+
}
1300+
403: unknown
1301+
}
1302+
}
1303+
put_account_data_settings: {
1304+
parameters: {
1305+
path: {
1306+
address: string
1307+
}
1308+
credentials: 'include'
1309+
body: UpsertAccountDataSettingsRequest
1310+
}
1311+
responses: {
1312+
200: {
1313+
schema: AccountDataSetting[]
1314+
}
1315+
403: unknown
1316+
}
1317+
}
1318+
get_account: {
1319+
parameters: {
1320+
path: {
1321+
address: string
1322+
}
1323+
credentials: 'include'
1324+
}
1325+
responses: {
1326+
200: {
1327+
schema: Account
1328+
}
1329+
403: unknown
1330+
}
1331+
}
1332+
delete_account: {
1333+
parameters: {
1334+
path: {
1335+
address: string
1336+
}
1337+
credentials: 'include'
1338+
}
1339+
responses: {
1340+
204: {
1341+
schema: void
1342+
}
1343+
200: {
1344+
schema: void
1345+
}
1346+
403: unknown
1347+
}
1348+
}
12281349
}

0 commit comments

Comments
 (0)