fp/packages/utils/src/patron.ts
CJ_Clippy 140883a69c
Some checks failed
ci / build (push) Failing after 1s
dec 2024 progress
2024-12-11 23:23:46 -08:00

181 lines
3.7 KiB
TypeScript

export function formatPatronUsername (first_name: string, last_name: string) {
return `${first_name || ''} ${last_name || ''}`.trim()
}
export interface Reward {
id: string;
type: "reward";
attributes: {
amount_cents: number;
created_at: string;
description: string;
discord_role_ids: any | null;
edited_at: string;
image_url: string | null;
patron_count: number;
post_count: number | null;
published: boolean;
published_at: string;
remaining: number | null;
requires_shipping: boolean;
title: string;
unpublished_at: string | null;
url: string;
user_limit: number | null;
};
}
export interface Patron {
id: string;
full_name: string;
}
export type PublicPatron = {
id: string; // User ID of the patron
full_name: string; // Full name of the patron, pulled from included data
link?: string;
};
namespace Patreon {
export interface APIResponse {
data: {
id: string;
relationships: {
currently_entitled_tiers: {
data: { id: string; type: string }[];
};
user: {
data: { id: string; type: string };
};
};
type: string;
}[];
included: {
id: string;
type: string;
attributes: {
full_name?: string;
};
}[];
meta: {
count: number;
pagination: {
cursors: {
next?: string;
}
}
};
}
export interface Pledge {
id: string;
type: "pledge";
attributes: {
amount_cents: number;
created_at: string;
declined_since: string | null;
patron_pays_fees: boolean;
pledge_cap_cents: number | null;
};
relationships: {
patron: {
data: {
id: string;
type: "user";
};
links: {
related: string;
};
};
reward: {
data: {
id: string;
type: "reward";
};
links: {
related: string;
};
};
};
}
export interface User {
id: string;
type: "user";
attributes: {
about: string;
created: string;
email: string;
facebook: string | null;
first_name: string;
full_name: string;
gender: number;
image_url: string;
is_email_verified: boolean;
last_name: string;
social_connections: SocialConnections;
thumb_url: string;
twitch: string | null;
twitter: string | null;
url: string;
vanity: string;
youtube: string | null;
};
}
export interface SocialConnections {
deviantart: string | null;
discord: string | null;
facebook: string | null;
reddit: string | null;
spotify: string | null;
twitch: string | null;
twitter: string | null;
youtube: string | null;
}
export interface Reward {
id: string;
type: "reward";
attributes: {
amount_cents: number;
created_at: string;
description: string;
discord_role_ids: any | null;
edited_at: string;
image_url: string | null;
patron_count: number;
post_count: number | null;
published: boolean;
published_at: string;
remaining: number | null;
requires_shipping: boolean;
title: string;
unpublished_at: string | null;
url: string;
user_limit: number | null;
};
}
}
export const cjClippyPatreonCampaignId = '8012692'
export const tiers = {
everyone: '-1',
free: '10620388',
archiveSupporter: '8154170',
stealthSupporter: '9561793',
tuneItUp: '9184994',
maxQ: '22529959',
archiveCollector: '8154171',
advancedArchiveSupporter: '8686045',
quantumSupporter: '8694826',
sneakyQuantumSupporter: '9560538',
luberPlusPlus: '8686022'
}