2024-05-03 14:51:45 +02:00

27 lines
719 B
TypeScript

import { Api as GramJs } from '../../../lib/gramjs';
import { buildApiCollectibleInfo } from '../apiBuilders/misc';
import { invokeRequest } from './client';
type InputCollectible = {
phone: string;
} | {
username: string;
};
export async function fetchCollectionInfo(collectible: InputCollectible) {
const inputCollectible = 'username' in collectible
? new GramJs.InputCollectibleUsername({ username: collectible.username })
: new GramJs.InputCollectiblePhone({ phone: collectible.phone });
const result = await invokeRequest(new GramJs.fragment.GetCollectibleInfo({
collectible: inputCollectible,
}));
if (!result) {
return undefined;
}
return buildApiCollectibleInfo(result);
}