@@ -4,15 +4,36 @@ import {
44 getAccountPath ,
55 getAccountTokensPath ,
66 getPaymentTokenPath ,
7+ getPortfolioHistoryPath ,
8+ getPortfolioStatsPath ,
9+ getProfileCollectionsPath ,
10+ getProfileFavoritesPath ,
11+ getProfileListingsPath ,
12+ getProfileOffersPath ,
13+ getProfileOffersReceivedPath ,
714 getResolveAccountPath ,
815} from "./apiPaths"
916import type { Fetcher } from "./fetcher"
1017import type {
1118 GetAccountTokensArgs ,
1219 GetAccountTokensResponse ,
20+ PortfolioArgs ,
21+ PortfolioHistoryResponse ,
22+ PortfolioStatsResponse ,
23+ ProfileCollectionsArgs ,
24+ ProfileCollectionsResponse ,
25+ ProfileFavoritesArgs ,
26+ ProfileFavoritesResponse ,
27+ ProfileListingsResponse ,
28+ ProfileOffersResponse ,
29+ ProfileOrdersArgs ,
1330 ResolveAccountResponse ,
1431} from "./types"
1532
33+ function joinArray ( value : string [ ] | undefined ) : string | undefined {
34+ return value && value . length > 0 ? value . join ( "," ) : undefined
35+ }
36+
1637/**
1738 * Account and payment token related API operations
1839 */
@@ -66,4 +87,113 @@ export class AccountsAPI {
6687 )
6788 return response
6889 }
90+
91+ /**
92+ * Get portfolio stats (net worth, P&L) for an account.
93+ */
94+ async getPortfolioStats (
95+ address : string ,
96+ args ?: PortfolioArgs ,
97+ ) : Promise < PortfolioStatsResponse > {
98+ return this . fetcher . get < PortfolioStatsResponse > (
99+ getPortfolioStatsPath ( address ) ,
100+ args ,
101+ )
102+ }
103+
104+ /**
105+ * Get portfolio net-worth history for an account.
106+ */
107+ async getPortfolioHistory (
108+ address : string ,
109+ args ?: PortfolioArgs ,
110+ ) : Promise < PortfolioHistoryResponse > {
111+ return this . fetcher . get < PortfolioHistoryResponse > (
112+ getPortfolioHistoryPath ( address ) ,
113+ args ,
114+ )
115+ }
116+
117+ /**
118+ * Get offers received by an account, scoped by collection/chain.
119+ */
120+ async getProfileOffersReceived (
121+ address : string ,
122+ args ?: ProfileOrdersArgs ,
123+ ) : Promise < ProfileOffersResponse > {
124+ return this . fetcher . get < ProfileOffersResponse > (
125+ getProfileOffersReceivedPath ( address ) ,
126+ {
127+ ...args ,
128+ collection_slugs : joinArray ( args ?. collection_slugs ) ,
129+ chains : joinArray ( args ?. chains ) ,
130+ } ,
131+ )
132+ }
133+
134+ /**
135+ * Get active offers made by an account.
136+ */
137+ async getProfileOffers (
138+ address : string ,
139+ args ?: ProfileOrdersArgs ,
140+ ) : Promise < ProfileOffersResponse > {
141+ return this . fetcher . get < ProfileOffersResponse > (
142+ getProfileOffersPath ( address ) ,
143+ {
144+ ...args ,
145+ collection_slugs : joinArray ( args ?. collection_slugs ) ,
146+ chains : joinArray ( args ?. chains ) ,
147+ } ,
148+ )
149+ }
150+
151+ /**
152+ * Get active listings for an account.
153+ */
154+ async getProfileListings (
155+ address : string ,
156+ args ?: ProfileOrdersArgs ,
157+ ) : Promise < ProfileListingsResponse > {
158+ return this . fetcher . get < ProfileListingsResponse > (
159+ getProfileListingsPath ( address ) ,
160+ {
161+ ...args ,
162+ collection_slugs : joinArray ( args ?. collection_slugs ) ,
163+ chains : joinArray ( args ?. chains ) ,
164+ } ,
165+ )
166+ }
167+
168+ /**
169+ * Get items favorited by an account.
170+ */
171+ async getProfileFavorites (
172+ address : string ,
173+ args ?: ProfileFavoritesArgs ,
174+ ) : Promise < ProfileFavoritesResponse > {
175+ return this . fetcher . get < ProfileFavoritesResponse > (
176+ getProfileFavoritesPath ( address ) ,
177+ {
178+ ...args ,
179+ chains : joinArray ( args ?. chains ) ,
180+ } ,
181+ )
182+ }
183+
184+ /**
185+ * Get collections owned by an account.
186+ */
187+ async getProfileCollections (
188+ address : string ,
189+ args ?: ProfileCollectionsArgs ,
190+ ) : Promise < ProfileCollectionsResponse > {
191+ return this . fetcher . get < ProfileCollectionsResponse > (
192+ getProfileCollectionsPath ( address ) ,
193+ {
194+ ...args ,
195+ chains : joinArray ( args ?. chains ) ,
196+ } ,
197+ )
198+ }
69199}
0 commit comments