ringfinger/js/api/UserSharingsGetApiRequest.ts

27 lines
709 B
TypeScript
Raw Normal View History

import ApiRequest from "./ApiRequest.js";
import RequestMethod from "./RequestMethod.js";
import Sharing from "../types/Sharing.js";
import UserSharingsGetEvent from "../event/UserSharingsGetEvent.js";
export default class UserSharingsGetApiRequest extends ApiRequest
{
public constructor(userId: number)
{
super('user/' + userId + '/sharings', RequestMethod.GET);
this.onSuccess = (response: string) => {
let json = JSON.parse(response);
let sharings: Array<Sharing> = [];
json.sharings.forEach(
(result: any) => {
sharings.push(new Sharing(result.sharingId, result.userId, result.userSharedId));
}
);
window.dispatchEvent(new UserSharingsGetEvent(sharings));
}
}
}