Skip to content

Commit

Permalink
feat(Flows): add an endpoint for all flows
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Delisle committed Feb 20, 2024
1 parent 420bf14 commit 08ef477
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/universe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,7 @@ export class Universe extends APICarrier {
}
}
const res = await this.http.getClient()(opts)

const resources = res.data.data as FlowRawPayload[]

return resources
Expand All @@ -2188,6 +2189,30 @@ export class Universe extends APICarrier {
}
}

public get flows (): {fetch: (options?: UniverseFetchOptions) => Promise<FlowRawPayload[] | undefined>} {
return {
fetch: async (options?: UniverseFetchOptions): Promise<FlowRawPayload[] | undefined> => {
try {
const opts = {
method: 'GET',
url: `${this.universeBase}/api/v0/analytics/reports/flows`,
params: {
...(options?.query ?? {})
}
}

const res = await this.http.getClient()(opts)

const resources = res.data.data as FlowRawPayload[]

return resources
} catch (err) {
throw new BaseError('Failed to fetch top flows', { error: err })
}
}
}
}

public async favorites (options?: EntityFetchOptions): Promise<favorite.Favorite[] | favorite.FavoriteRawPayload[] | undefined> {
return await this.makeBaseResourceListRequest<favorite.Favorite, favorite.Favorites, favorite.FavoriteRawPayload, EntityFetchOptions, favorite.FavoritesFetchRemoteError>(favorite.Favorite, favorite.Favorites, favorite.FavoritesFetchRemoteError, options)
}
Expand Down

0 comments on commit 08ef477

Please sign in to comment.