186 lines
3.8 KiB
TypeScript
186 lines
3.8 KiB
TypeScript
/**
|
|
* API of the server (auto-generated code)
|
|
*/
|
|
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray } from "./rest-tools"
|
|
import {Response, isResponse, InputStream, isAlbum, Long, RestErrorResponse, Album, FormDataContentDisposition, } from "./model"
|
|
export namespace AlbumResource {
|
|
|
|
/**
|
|
* Remove a specific album
|
|
*/
|
|
export function remove({ restConfig, params, }: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<Response> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album/{id}",
|
|
requestType: HTTPRequestModel.DELETE,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isResponse);
|
|
};
|
|
/**
|
|
* Get a specific Album with his ID
|
|
*/
|
|
export function get({ restConfig, params, }: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<Album> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album/{id}",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isAlbum);
|
|
};
|
|
/**
|
|
* Update a specific album
|
|
*/
|
|
export function patch({ restConfig, params, data, }: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: Album,
|
|
}): Promise<Album> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album/{id}",
|
|
requestType: HTTPRequestModel.PATCH,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}, isAlbum);
|
|
};
|
|
/**
|
|
* Add an album (when all the data already exist)
|
|
*/
|
|
export function post({ restConfig, data, }: {
|
|
restConfig: RESTConfig,
|
|
data: Album,
|
|
}): Promise<Album> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
}, isAlbum);
|
|
};
|
|
/**
|
|
* Remove a Track on a specific album
|
|
*/
|
|
export function removeTrack({ restConfig, params, }: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
trackId: Long,
|
|
id: Long,
|
|
},
|
|
}): Promise<Album> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album/{id}/track/{trackId}",
|
|
requestType: HTTPRequestModel.DELETE,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isAlbum);
|
|
};
|
|
/**
|
|
* Add a cover on a specific album
|
|
*/
|
|
export function addCover({ restConfig, params, data, }: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: {
|
|
fileName: string,
|
|
file: FormDataContentDisposition,
|
|
},
|
|
}): Promise<Response> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album/{id}/cover",
|
|
requestType: HTTPRequestModel.POST,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}, isResponse);
|
|
};
|
|
/**
|
|
* Remove a cover on a specific album
|
|
*/
|
|
export function removeCover({ restConfig, params, }: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
coverId: Long,
|
|
id: Long,
|
|
},
|
|
}): Promise<Response> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album/{id}/cover/{coverId}",
|
|
requestType: HTTPRequestModel.DELETE,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isResponse);
|
|
};
|
|
/**
|
|
* Get all the available Albums
|
|
*/
|
|
export function gets({ restConfig, }: {
|
|
restConfig: RESTConfig,
|
|
}): Promise<Album[]> {
|
|
return RESTRequestJsonArray({
|
|
restModel: {
|
|
endPoint: "/album",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
}, isAlbum);
|
|
};
|
|
/**
|
|
* Add a Track on a specific album
|
|
*/
|
|
export function addTrack({ restConfig, params, }: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
trackId: Long,
|
|
id: Long,
|
|
},
|
|
}): Promise<Album> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/album/{id}/track/{trackId}",
|
|
requestType: HTTPRequestModel.POST,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isAlbum);
|
|
};
|
|
}
|