import { storage } from "../storage"; import type { Compatibility } from "../types/compatibility"; import type { Neighbour } from "../types/neighbour"; import type { Profile } from "../types/profile"; import type { Scrobble } from "../types/scrobble"; import { client } from "."; export const getProfileByDid = async (did: string) => { const response = await client.get( "/xrpc/app.rocksky.actor.getProfile", { params: { did }, }, ); return response.data; }; export const getProfileStatsByDid = async (did: string) => { const response = await client.get("/xrpc/app.rocksky.stats.getStats", { params: { did }, }); return response.data; }; export const getRecentTracksByDid = async ( did: string, offset = 0, size = 10, ): Promise => { const response = await client.get<{ scrobbles: Scrobble[] }>( "/xrpc/app.rocksky.actor.getActorScrobbles", { params: { did, offset, limit: size }, headers: { Authorization: storage.getToken() ? `Bearer ${storage.getToken()}` : undefined, }, }, ); return response.data.scrobbles || []; }; export const getActorNeighbours = async (did: string) => { const response = await client.get<{ neighbours: Neighbour[] }>( "/xrpc/app.rocksky.actor.getActorNeighbours", { params: { did }, }, ); return response.data; }; export const getActorCompatibility = async (did: string) => { const response = await client.get<{ compatibility: Compatibility | null }>( "/xrpc/app.rocksky.actor.getActorCompatibility", { params: { did }, headers: { Authorization: `Bearer ${storage.getToken()}`, }, }, ); return response.data; };