Skip to content

Klient autoryzowany

import { createTipplyClient } from "tipply-sdk-ts";
const client = createTipplyClient({
authCookie: process.env.TIPPLY_AUTH_COOKIE!,
});
const me = await client.me.get();
const profile = await client.profile.get();
const hasPendingProfileChanges = await client.profile.pendingChanges.check();
const [announcements, extraAnnouncements, incomeStats, tipStats, points] = await Promise.all([
client.dashboard.announcements.list(),
client.dashboard.announcements.listExtra(),
client.dashboard.stats.income.get(),
client.dashboard.stats.tips.get(),
client.dashboard.points.get(),
]);
const recentTips = await client.dashboard.tips.recent.list();
const filteredTips = await client.tips
.list()
.filter("amount")
.search("mikrofon")
.limit(10)
.offset(0)
.get();
const configuration = await client.paymentMethods.configuration.get();
const methods = await client.paymentMethods.list();
const updatedPaypal = await client.paymentMethods.method("paypal").update({
minimalAmount: 1500,
});
await client.settings.alerts.toggle(false);
await client.settings.alertSound.toggle(false);
await client.profile.page.updateSettings({
description: "Streamer variety, speedrunning i live coding.",
});
const goals = await client.goals.list();
const createdGoal = await client.goals.create({
title: "Nowy mikrofon",
amount: 50000,
});
await client.goals.id(createdGoal.id).update({
title: "Nowy mikrofon XLR",
amount: 70000,
});
await client.goals.id(createdGoal.id).reset();
const voting = await client.goals.voting.get();
const moderators = await client.moderators.list();
const media = await client.media.list();
const usage = await client.media.usage.get();
const latestWithdrawals = await client.withdrawals.latest.list();
import { asWithdrawalId } from "tipply-sdk-ts";
const pdf = await client.withdrawals
.id(asWithdrawalId("withdrawal-123"))
.confirmationPdf
.get();

Auth client pozwala łatwo stworzyć drugi klient z inną sesją:

const baseClient = createTipplyClient({
authCookie: process.env.TIPPLY_AUTH_COOKIE!,
});
const anotherClient = baseClient.withAuthCookie(process.env.OTHER_TIPPLY_AUTH_COOKIE!);

Możesz też przekazać pełny obiekt sesji:

const impersonatedClient = baseClient.withSession({
getAuthCookie: async () => process.env.OTHER_TIPPLY_AUTH_COOKIE,
});
  • me
  • dashboard
  • profile
  • paymentMethods
  • settings
  • goals
  • templates
  • tips
  • moderators
  • media
  • withdrawals
  • reports
  • tipAlerts
  • public

Szczegółowa lista wszystkich metod jest w SDK Reference.