UNPKG

yandex-music

Version:

Creative and progressive Node.js framework for applications that interact with yandex music

63 lines (62 loc) 2.93 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Likes = void 0; const log_decorator_1 = require("../../decorators/log.decorator"); const albums_1 = require("./albums"); const artists_1 = require("./artists"); const playlists_1 = require("./playlists"); const tracks_1 = require("./tracks"); class Likes { constructor(client) { this.client = client; this.albums = new albums_1.Albums(this); this.artists = new artists_1.Artists(this); this.playlists = new playlists_1.Playlists(this); this.tracks = new tracks_1.Tracks(this); } /** * Actions marked "I like". * @param {action} type The type of the object. * @param {List} ids * @param {boolean} remove If True, then removes the mark, otherwise puts. * @param {number} user_id Unique user ID. * @returns OK if the request is successful. */ async action(type, ids, remove = false, user_id = this.client.uid) { const action = remove ? "remove" : "add-multiple"; const params = { [`${type}-ids`]: ids }; return await this.client.request.post(`/users/${user_id}/likes/${type}s/${action}`, null, params); } /** * Getting objects marked "I like". * @param {action} type The type of the object. * @param {number} user_id Unique user ID. * @param {Record<string, any>} params Parameters to be passed to the request. * @returns Obj type. */ async get(type, user_id = this.client.uid, params = {}) { return await this.client.request.get(`/users/${user_id}/likes/${type}s`, params); } } __decorate([ (0, log_decorator_1.log)(), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Array, Boolean, Number]), __metadata("design:returntype", Promise) ], Likes.prototype, "action", null); __decorate([ (0, log_decorator_1.log)(), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Number, Object]), __metadata("design:returntype", Promise) ], Likes.prototype, "get", null); exports.Likes = Likes;