splitwise
Version:
A TypeScript SDK for the Splitwise API.
417 lines • 11 kB
TypeScript
export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
export interface Logger {
debug(msg: string): void;
info(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
}
export interface UserShare {
userId: number;
paidShare?: string;
owedShare?: string;
firstName?: string;
lastName?: string;
email?: string;
}
export interface Picture {
small?: string;
medium?: string;
large?: string;
}
export interface Balance {
currencyCode: string;
amount: string;
}
export interface Repayment {
from: number;
to: number;
amount: string;
}
export interface Debt {
from: number;
to: number;
amount: string;
currencyCode: string;
}
export interface ExpenseListParams {
groupId?: number;
friendId?: number;
datedAfter?: string;
datedBefore?: string;
updatedAfter?: string;
updatedBefore?: string;
limit?: number;
offset?: number;
visible?: boolean;
}
export interface ExpenseGetParams {
id: number;
}
export interface ExpenseCreateParams {
cost: string;
description: string;
groupId?: number;
/** Not documented in OpenAPI for create_expense; v1 supported it for
* non-group debts. Smoke-test before relying on it. */
friendId?: number;
details?: string;
date?: string;
repeatInterval?: string;
currencyCode?: string;
categoryId?: number;
users?: UserShare[];
splitEqually?: boolean;
payment?: boolean;
/** Tag for how the expense was created (e.g. "equal"). Undocumented. */
creationMethod?: string;
/**
* Optional receipt image. When provided, the request is sent as
* multipart/form-data instead of form-urlencoded. Pass a `Blob` (works in
* Node 18+, browsers, and other modern runtimes); in browsers a `File`
* (which extends Blob) also works.
*/
receipt?: Blob;
}
export interface ExpenseUpdateParams {
id: number;
cost?: string;
description?: string;
groupId?: number;
friendId?: number;
details?: string;
date?: string;
repeatInterval?: string;
currencyCode?: string;
categoryId?: number;
users?: UserShare[];
payment?: boolean;
expenseBundleId?: number;
}
export interface ExpenseDeleteParams {
id: number;
}
export interface ExpenseRestoreParams {
id: number;
}
export interface CreateDebtParams {
/** User id of the person who paid (i.e. is owed money). */
paidBy: number;
/** User id of the person who owes money. */
owedBy: number;
amount: string | number;
description?: string;
groupId?: number;
date?: string;
}
export type GroupListParams = Record<string, never>;
export interface GroupGetParams {
id: number;
}
export type GroupType = 'home' | 'trip' | 'couple' | 'other' | 'apartment' | 'house';
export interface GroupCreateParams {
name: string;
groupType?: GroupType | string;
/** Whether the group should simplify debts. */
simplifyByDefault?: boolean;
/** Undocumented in OpenAPI but supported by v1. */
countryCode?: string;
users?: Array<{
userId?: number;
firstName?: string;
lastName?: string;
email?: string;
}>;
}
export interface GroupDeleteParams {
id: number;
}
export interface GroupRestoreParams {
id: number;
}
export interface AddUserToGroupParams {
groupId: number;
userId?: number;
email?: string;
firstName?: string;
lastName?: string;
}
export interface RemoveUserFromGroupParams {
groupId: number;
userId: number;
}
export interface UserGetParams {
id: number;
}
export interface UserUpdateParams {
id: number;
firstName?: string;
lastName?: string;
email?: string;
password?: string;
locale?: string;
dateFormat?: string;
defaultCurrency?: string;
defaultGroupId?: number;
notificationSettings?: Record<string, boolean>;
}
export interface FriendGetParams {
id: number;
}
export interface FriendCreateParams {
userEmail: string;
userFirstName?: string;
userLastName?: string;
}
export interface FriendCreateMultipleParams {
friends: Array<{
email: string;
firstName?: string;
lastName?: string;
}>;
}
export interface FriendDeleteParams {
id: number;
}
export interface CommentListParams {
expenseId: number;
}
export interface CommentCreateParams {
expenseId: number;
content: string;
}
export interface CommentDeleteParams {
id: number;
}
export interface NotificationListParams {
updatedAfter?: string;
limit?: number;
}
export interface ParseSentenceParams {
input: string;
groupId?: number;
friendId?: number;
/** If true, the parsed expense is auto-saved by Splitwise. */
autosave?: boolean;
}
/** Response from /parse_sentence (undocumented endpoint; shape confirmed
* empirically by other-language SDKs). */
export interface ParseSentenceResponse {
expense?: Expense;
valid?: boolean;
confidence?: number;
error?: string;
}
export interface GetMainDataParams {
noExpenses?: boolean;
limit?: number;
cachebust?: boolean;
}
export interface User {
id: number;
firstName: string;
/** May be null on the API; some accounts have first name only. */
lastName: string | null;
email?: string;
registrationStatus?: string;
picture?: Picture;
customPicture?: boolean;
defaultCurrency?: string;
locale?: string;
}
export interface CurrentUser extends User {
email: string;
defaultCurrency: string;
locale: string;
dateFormat?: string;
defaultGroupId?: number;
notificationsRead?: string;
notificationsCount?: number;
/** Per OpenAPI this is an open-ended bag of boolean flags; new keys may
* appear without notice. */
notifications?: Record<string, boolean>;
/** Undocumented but present on /get_current_user. */
countryCode?: string;
forceRefreshAt?: string | null;
addFriendUrl?: string;
}
export interface GroupMember {
id: number;
firstName: string;
/** May be null on the API; some accounts only set a first name. */
lastName: string | null;
email?: string;
registrationStatus?: string;
picture?: Picture;
customPicture?: boolean;
balance: Balance[];
}
export interface GroupAvatar {
original?: string | null;
xxlarge?: string | null;
xlarge?: string | null;
large?: string | null;
medium?: string | null;
small?: string | null;
}
export interface GroupCoverPhoto {
xxlarge?: string | null;
xlarge?: string | null;
}
export interface Group {
id: number;
name: string;
groupType?: string;
createdAt?: string;
updatedAt?: string;
simplifyByDefault?: boolean;
members?: GroupMember[];
originalDebts?: Debt[];
simplifiedDebts?: Debt[];
/** Undocumented in OpenAPI but present on responses. */
whiteboard?: string | null;
/** Undocumented; tracks optimistic-concurrency for whiteboard updates. */
whiteboardLockVersion?: number;
whiteboardUpdatedAt?: string | null;
whiteboardUpdatedBy?: number | null;
/** Undocumented; null when no group reminders are configured. */
groupReminders?: unknown | null;
inviteLink?: string;
avatar?: GroupAvatar;
/** Undocumented variant returned alongside `avatar`. */
tallAvatar?: {
xlarge?: string;
large?: string;
};
customAvatar?: boolean;
coverPhoto?: GroupCoverPhoto;
}
export interface ExpenseCategory {
id: number;
name: string;
}
export interface Receipt {
large?: string | null;
original?: string | null;
}
export interface ExpenseShare {
user: User;
userId: number;
paidShare: string;
owedShare: string;
netBalance: string;
}
export interface Expense {
id: number;
groupId: number | null;
/** Spec field name is `friendship_id` (singular friendship, not `friend_id`). */
friendshipId?: number | null;
expenseBundleId?: number | null;
description: string;
repeats: boolean;
repeatInterval?: string | null;
emailReminder?: boolean;
emailReminderInAdvance?: number | null;
nextRepeat?: string | null;
details?: string | null;
commentsCount?: number;
payment: boolean;
/** Undocumented in OpenAPI but present in responses. */
creationMethod?: string | null;
/** Undocumented in OpenAPI but present in responses (e.g. for payments). */
transactionMethod?: string | null;
transactionConfirmed?: boolean;
transactionId?: string | null;
transactionStatus?: string | null;
cost: string;
currencyCode: string;
repayments?: Repayment[];
date: string;
createdAt: string;
createdBy?: User | null;
updatedAt?: string;
updatedBy?: User | null;
deletedAt?: string | null;
deletedBy?: User | null;
category?: ExpenseCategory;
receipt?: Receipt;
users?: ExpenseShare[];
comments?: Comment[];
}
export interface CategoryIconTypes {
/** Per OpenAPI the API returns `large` and `xlarge` here, not the standard
* small/medium/large picture sizes. */
square?: {
large?: string;
xlarge?: string;
};
slim?: {
small?: string;
large?: string;
};
/** Undocumented but present in real responses. */
transparent?: {
large?: string;
xlarge?: string;
};
}
export interface Category {
id: number;
name: string;
icon?: string;
iconTypes?: CategoryIconTypes;
subcategories?: Category[];
}
export interface Currency {
currencyCode: string;
unit: string;
}
export interface Comment {
id: number;
content: string;
commentType: string;
relationType: string;
relationId: number;
createdAt: string;
deletedAt?: string | null;
user?: User;
}
export interface NotificationSource {
/** e.g. "Expense", "Group", "Friendship". */
type: string;
id: number;
url?: string | null;
}
export interface Notification {
id: number;
/**
* Notification kind, returned as a small integer. See `NotificationType`
* for the known values, and `notificationTypeName()` for a human-readable
* name. Splitwise may add new values without warning, so handle unknown
* numbers gracefully.
*/
type?: number;
createdAt: string;
createdBy?: number;
source?: NotificationSource | null;
imageUrl?: string;
imageShape?: 'square' | 'circle' | string;
content?: string;
}
export interface FriendGroup {
groupId: number;
balance: Balance[];
}
export interface Friend {
id: number;
firstName: string;
/** May be null on the API; some accounts only set a first name. */
lastName: string | null;
email?: string;
registrationStatus?: string;
picture?: Picture;
customPicture?: boolean;
balance: Balance[];
groups: FriendGroup[];
updatedAt?: string;
}
//# sourceMappingURL=types.d.ts.map