MCPcopy Create free account
hub / github.com/MALSync/MALSync / _sync

Method _sync

src/_provider/Kitsu/single.ts:287–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

285 }
286
287 async _sync() {
288 const variables: any = {
289 data: {
290 attributes: {
291 notes: this.listI().attributes.notes,
292 progress: this.listI().attributes.progress,
293 volumesOwned: this.listI().attributes.volumesOwned,
294 reconsuming: this.listI().attributes.reconsuming,
295 reconsumeCount: this.listI().attributes.reconsumeCount,
296 ratingTwenty: this._getTwentyScore(),
297 status: this.listI().attributes.status,
298 startedAt: this.listI().attributes.startedAt,
299 finishedAt: this.listI().attributes.finishedAt,
300 },
301 type: 'library-entries',
302 },
303 };
304 const tType = this.getType();
305 if (!tType) return Promise.resolve();
306 let updateUrl;
307 let post;
308 if (this.isOnList()) {
309 updateUrl = `https://kitsu.app/api/edge/library-entries/${this.listI().id}`;
310 variables.data.id = this.listI().id;
311 post = 'PATCH';
312 } else {
313 updateUrl = 'https://kitsu.app/api/edge/library-entries/';
314 variables.data.relationships = {
315 [tType]: {
316 data: {
317 type: tType,
318 id: this.ids.kitsu.id,
319 },
320 },
321 user: {
322 data: {
323 type: 'users',
324 id: await this.userId(),
325 },
326 },
327 };
328 post = 'POST';
329 }
330
331 this.logger.log(post, variables);
332
333 return this.apiCall(post, updateUrl, variables).then(res => {
334 if (res && res.data && res.data.id) {
335 this.listI().id = res.data.id;
336 }
337 return res;
338 });
339 }
340
341 protected apiCall(
342 mode: 'GET' | 'POST' | 'DELETE' | 'PUT',

Callers

nothing calls this directly

Calls 4

listIMethod · 0.95
_getTwentyScoreMethod · 0.95
userIdMethod · 0.95
apiCallMethod · 0.95

Tested by

no test coverage detected