Beispiel #1
0
        public static async Task <FriendRequestCancel> Unfriend(this VRCSharpSession session, APIUser User)
        {
            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);

            var response = await client.DeleteAsync($"https://vrchat.com/api/1/user/{User.id}/friendRequest?apiKey={GlobalVars.ApiKey}");

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(JsonConvert.DeserializeObject <FriendRequestCancel>(await response.Content.ReadAsStringAsync()));
            }
            else
            {
                return(null);
            }
        }