UNPKG

@4lch4/toggl-aid

Version:

A wrapper library for interacting with the Toggl API.

85 lines 3.22 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeEntries = void 0; const BaseEndpoint_1 = require("../BaseEndpoint"); class TimeEntries extends BaseEndpoint_1.BaseEndpoint { createTimeEntry(timeEntry) { return __awaiter(this, void 0, void 0, function* () { try { const res = yield this.axios.performRequest('POST', '/time_entries', { data: { time_entry: timeEntry } }); return this.respond(res); } catch (err) { return err; } }); } startTimeEntry(timeEntry) { return __awaiter(this, void 0, void 0, function* () { try { const res = yield this.axios.performRequest('POST', '/time_entries/start', { data: timeEntry }); return this.respond(res); } catch (err) { return err; } }); } stopTimeEntry(timeEntryId) { return __awaiter(this, void 0, void 0, function* () { try { const res = yield this.axios.performRequest('PUT', `/time_entries/${timeEntryId}/stop`); return this.respond(res); } catch (err) { return err; } }); } getRunningTimeEntry() { return __awaiter(this, void 0, void 0, function* () { try { const res = yield this.axios.performRequest('GET', '/time_entries/current'); return this.respond(res); } catch (err) { return err; } }); } updateTimeEntry(timeEntryId, timeEntry) { return __awaiter(this, void 0, void 0, function* () { try { const res = yield this.axios.performRequest('PUT', `/time_entries/${timeEntryId}`, { data: { time_entry: timeEntry } }); return this.respond(res); } catch (err) { return err; } }); } deleteTimeEntry(timeEntryId) { return __awaiter(this, void 0, void 0, function* () { try { const res = yield this.axios.performRequest('DELETE', `/time_entries/${timeEntryId}`); return this.respond(res); } catch (err) { return err; } }); } } exports.TimeEntries = TimeEntries; //# sourceMappingURL=TimeEntries.js.map