UNPKG

splitwise

Version:

A TypeScript SDK for the Splitwise API.

45 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Friends = void 0; const base_js_1 = require("./base.js"); class Friends extends base_js_1.BaseResource { async list(overrides) { return this.http.get('/get_friends', { unwrapKey: 'friends', ...overrides, }); } async get(params, overrides) { return this.http.get(`/get_friend/${params.id}`, { unwrapKey: 'friend', ...overrides, }); } async create(params, overrides) { // Verified empirically: the API returns { friend: {...} } (singular), // matching the OpenAPI spec. v1 incorrectly assumed `friends: [...]`. return this.http.post('/create_friend', { body: { ...params }, unwrapKey: 'friend', ...overrides, }); } async createMultiple(params, overrides) { // Per OpenAPI the wire format is `users[]` (not `friends[]`) and the // response is wrapped in `users`. return this.http.post('/create_friends', { body: { users: params.friends }, unwrapKey: 'users', ...overrides, }); } /** * Deletes a friendship. Throws SplitwiseConstraintError if the API refuses * (most commonly because the friendship has unsettled debts). */ async delete(params, overrides) { await this.http.post(`/delete_friend/${params.id}`, overrides); } } exports.Friends = Friends; //# sourceMappingURL=friends.js.map