fruit-company
Version:
Apple services library
65 lines • 3.19 kB
JavaScript
;
/*
* MIT No Attribution
*
* Copyright 2024 Peter "Kevin" Contreras
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
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.SearchMusicCatalog = void 0;
const serene_front_1 = require("serene-front");
const models_1 = require("./models");
class SearchMusicCatalog {
constructor(options) {
this.options = options;
}
prepare({}) {
const url = new URL(`${models_1.appleMusicBaseUrl}/catalog/${this.options.storefront}/search`);
url.searchParams.append("types", this.options.types.join(","));
url.searchParams.append("term", this.options.term);
if (this.options.language !== undefined) {
url.searchParams.append("l", this.options.language);
}
if (this.options.limit !== undefined) {
url.searchParams.append("limit", String(this.options.limit));
}
if (this.options.offset !== undefined) {
url.searchParams.append("offset", String(this.options.offset));
}
if (this.options.with !== undefined) {
url.searchParams.append("with", this.options.with.join(","));
}
return new Request(url);
}
parse(_a) {
return __awaiter(this, arguments, void 0, function* ({ fetchResponse }) {
if (!fetchResponse.ok) {
throw new serene_front_1.RESTError(fetchResponse.status, fetchResponse.statusText, `<${fetchResponse.url}>`);
}
return yield fetchResponse.json();
});
}
}
exports.SearchMusicCatalog = SearchMusicCatalog;
//# sourceMappingURL=requests.js.map