@@ -30,6 +30,14 @@ import {
3030 getAssetsV2ROI ,
3131 getAssetTimeseries ,
3232 getAssetTimeseriesWithGranularity ,
33+ modifyWatchlistAssets ,
34+ deleteWatchlist ,
35+ listWatchlists ,
36+ getPermissions ,
37+ createWatchlist ,
38+ getTeamAllowance ,
39+ getWatchlist ,
40+ updateWatchlist ,
3341} from "../types" ;
3442import type {
3543 createChatCompletionParameters ,
@@ -92,6 +100,19 @@ import type {
92100 getAssetTimeseriesWithGranularityParameters ,
93101 getAssetTimeseriesWithGranularityResponse ,
94102 TimeseriesMetadata ,
103+ modifyWatchlistAssetsResponse ,
104+ modifyWatchlistAssetsParameters ,
105+ deleteWatchlistResponse ,
106+ deleteWatchlistParameters ,
107+ listWatchlistsResponse ,
108+ createWatchlistParameters ,
109+ createWatchlistResponse ,
110+ getPermissionsResponse ,
111+ getWatchlistParameters ,
112+ getTeamAllowanceResponse ,
113+ getWatchlistResponse ,
114+ updateWatchlistParameters ,
115+ updateWatchlistResponse ,
95116} from "../types" ;
96117import type { Agent } from "node:http" ;
97118import { pick } from "../utils" ;
@@ -118,6 +139,7 @@ import type {
118139 RecapsAPIInterface ,
119140 ResearchInterface ,
120141 TokenUnlocksInterface ,
142+ UserManagementInterface ,
121143} from "./base" ;
122144import { MessariClientBase } from "./base" ;
123145
@@ -264,7 +286,16 @@ export class MessariClient extends MessariClientBase {
264286 throw error ;
265287 }
266288
267- const responseData = await response . json ( ) ;
289+ // Check if the response is JSON or text based on Content-Type header
290+ const contentType = response . headers . get ( "Content-Type" ) ;
291+ let responseData : { data : T } ;
292+
293+ if ( contentType ?. toLowerCase ( ) . includes ( "application/json" ) ) {
294+ responseData = await response . json ( ) ;
295+ } else {
296+ responseData = { data : await response . text ( ) } as { data : T } ;
297+ }
298+
268299 this . logger ( LogLevel . DEBUG , "request success" , { responseData } ) ;
269300
270301 // Emit response event
@@ -913,6 +944,71 @@ export class MessariClient extends MessariClientBase {
913944 } ,
914945 } ;
915946
947+ /**
948+ * User Management API service
949+ * Provides methods for managing user-specific data like watchlists, credits, and permissions
950+ */
951+ public readonly userManagement : UserManagementInterface = {
952+ getTeamAllowance : ( options ?: RequestOptions ) =>
953+ this . request < getTeamAllowanceResponse > ( {
954+ method : getTeamAllowance . method ,
955+ path : getTeamAllowance . path ( ) ,
956+ options,
957+ } ) ,
958+
959+ getPermissions : ( options ?: RequestOptions ) =>
960+ this . request < getPermissionsResponse > ( {
961+ method : getPermissions . method ,
962+ path : getPermissions . path ( ) ,
963+ options,
964+ } ) ,
965+
966+ listWatchlists : ( options ?: RequestOptions ) =>
967+ this . request < listWatchlistsResponse > ( {
968+ method : listWatchlists . method ,
969+ path : listWatchlists . path ( ) ,
970+ options,
971+ } ) ,
972+
973+ createWatchlist : ( params : createWatchlistParameters , options ?: RequestOptions ) =>
974+ this . request < createWatchlistResponse > ( {
975+ method : createWatchlist . method ,
976+ path : createWatchlist . path ( ) ,
977+ body : pick ( params , createWatchlist . bodyParams ) ,
978+ options,
979+ } ) ,
980+
981+ getWatchlist : ( params : getWatchlistParameters , options ?: RequestOptions ) =>
982+ this . request < getWatchlistResponse > ( {
983+ method : getWatchlist . method ,
984+ path : getWatchlist . path ( params ) ,
985+ options,
986+ } ) ,
987+
988+ updateWatchlist : ( params : updateWatchlistParameters , options ?: RequestOptions ) =>
989+ this . request < updateWatchlistResponse > ( {
990+ method : updateWatchlist . method ,
991+ path : updateWatchlist . path ( { id : params . id } ) ,
992+ body : pick ( params , updateWatchlist . bodyParams ) ,
993+ options,
994+ } ) ,
995+
996+ deleteWatchlist : ( params : deleteWatchlistParameters , options ?: RequestOptions ) =>
997+ this . request < deleteWatchlistResponse > ( {
998+ method : deleteWatchlist . method ,
999+ path : deleteWatchlist . path ( params ) ,
1000+ options,
1001+ } ) ,
1002+
1003+ modifyWatchlistAssets : ( params : modifyWatchlistAssetsParameters , options ?: RequestOptions ) =>
1004+ this . request < modifyWatchlistAssetsResponse > ( {
1005+ method : modifyWatchlistAssets . method ,
1006+ path : modifyWatchlistAssets . path ( { id : params . id } ) ,
1007+ body : pick ( params , modifyWatchlistAssets . bodyParams ) ,
1008+ options,
1009+ } ) ,
1010+ } ;
1011+
9161012 // Recaps is commented out as we don't want to expose it yet
9171013 // public readonly recaps: RecapsAPIInterface = {
9181014 // getProjectRecap: async (params: getProjectRecapParameters) => {
0 commit comments