UNPKG

friend-connect

Version:

**BEFORE YOU USE THIS TOOL, PLEASE READ THE FOLLOWING: WE _AS CONTRIBUTORS_ ARE NOT RESPONSIBLE FOR ANY DAMAGE OR LOSS CAUSED BY THIS APP. USE AN ALT ACCOUNT, JUST IN CASE THERE IS AN ISSUE WITH THIS METHOD.**

52 lines (51 loc) 1.7 kB
import { parseIdentifier } from "../utils/index"; export default class Social { constructor(xboxLiveClient) { this.xbox = xboxLiveClient; } async getFriends() { const res = await fetch(`${Social.uri}/users/me/people`, { method: "GET", headers: { Authorization: this.xbox.authorizationHeader, }, }); return await res.json(); } addFriend(identifier) { return fetch(`${Social.uri}/users/me/people/${parseIdentifier(identifier)}`, { method: "PUT", headers: { Authorization: this.xbox.authorizationHeader, }, }); } removeFriend(identifier) { return fetch(`${Social.uri}/users/me/people/${parseIdentifier(identifier)}`, { method: "DELETE", headers: { Authorization: this.xbox.authorizationHeader, }, }); } async getProfile(identifier) { const res = await fetch(`${Social.uri}/users/me/people/${parseIdentifier(identifier)}`, { method: "GET", headers: { Authorization: this.xbox.authorizationHeader, }, }); return await res.json(); } async getProfileSummary(identifier) { const res = await fetch(`${Social.uri}/users/${parseIdentifier(identifier)}/summary`, { method: "GET", headers: { Authorization: this.xbox.authorizationHeader, }, }); let data = await res.json(); return data; } } Social.uri = "https://social.xboxlive.com";