コード例 #1
0
ファイル: FriendsApiTests.cs プロジェクト: dotted/VRChat.Net
        public void CanHandleValidFriendsOfCurrentUserResponse()
        {
            MockHttpMessageHandler.SetResponse(new JArray(
                                                   new JObject(
                                                       new JProperty("id", "some id"),
                                                       new JProperty("username", "some username"),
                                                       new JProperty("displayName", "some display name"),
                                                       new JProperty("currentAvatarImageUrl", "https://some.url/currentAvatarImageUrl.jpg"),
                                                       new JProperty("currentAvatarThumbnailImageUrl", "https://some.url/currentAvatarThumbnailImageUrl.jpg"),
                                                       new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                       new JProperty("developerType", "some developer type"),
                                                       new JProperty("location", "some location"))));

            var api    = new FriendsApi();
            var result = api.Get(0, 20, false).Result;

            result.Should().HaveCount(1);
            result[0].id.Should().Be("some id");
            result[0].username.Should().Be("some username");
            result[0].displayName.Should().Be("some display name");
            result[0].currentAvatarImageUrl.Should().Be("https://some.url/currentAvatarImageUrl.jpg");
            result[0].currentAvatarThumbnailImageUrl.Should().Be("https://some.url/currentAvatarThumbnailImageUrl.jpg");
            result[0].tags.Should().HaveCount(2).And.ContainInOrder("tag 1", "tag 2");
            result[0].developerType.Should().Be("some developer type");
            result[0].location.Should().Be("some location");
        }
コード例 #2
0
ファイル: VRChatApi.cs プロジェクト: NeuroWhAI/VRChat.Net
        public VRChatApi(string username, string password)
        {
            // initialize endpoint classes
            RemoteConfig = new RemoteConfig();
            UserApi      = new UserApi(username, password);
            FriendsApi   = new FriendsApi();
            WorldApi     = new WorldApi();

            // initialize http client
            // TODO: use the auth cookie
            if (Global.HttpClient == null)
            {
                Global.HttpClient             = new HttpClient();
                Global.HttpClient.BaseAddress = new Uri("https://api.vrchat.cloud/api/1/");
            }

            string authEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{UserApi.Username}:{UserApi.Password}"));

            var header = Global.HttpClient.DefaultRequestHeaders;

            if (header.Contains("Authorization"))
            {
                header.Remove("Authorization");
            }
            header.Add("Authorization", $"Basic {authEncoded}");
        }
コード例 #3
0
        public VRChatApi(string username, string password)
        {
            Logger.Trace(() => $"Entering {nameof(VRChatApi)} constructor");
            Logger.Debug(() => $"Using username {username}");

            // initialize endpoint classes
            RemoteConfig   = new RemoteConfig();
            UserApi        = new UserApi(username, password);
            FriendsApi     = new FriendsApi();
            WorldApi       = new WorldApi();
            ModerationsApi = new ModerationsApi();
            AvatarApi      = new AvatarApi();

            // initialize http client
            // TODO: use the auth cookie
            if (Global.HttpClient == null)
            {
                Logger.Trace(() => $"Instantiating {nameof(HttpClient)}");
                Global.HttpClient             = new HttpClient();
                Global.HttpClient.BaseAddress = new Uri("https://api.vrchat.cloud/api/1/");
                Logger.Info(() => $"VRChat API base address set to {Global.HttpClient.BaseAddress}");
            }

            string authEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{UserApi.Username}:{UserApi.Password}"));

            var header = Global.HttpClient.DefaultRequestHeaders;

            if (header.Contains("Authorization"))
            {
                Logger.Debug(() => "Removing existing Authorization header");
                header.Remove("Authorization");
            }
            header.Add("Authorization", $"Basic {authEncoded}");
            Logger.Trace(() => $"Added new Authorization header");
        }
コード例 #4
0
ファイル: FriendsApiTests.cs プロジェクト: dotted/VRChat.Net
        public void CanHandleInternalServerErrorHttpStatusSendFriendRequestResponse()
        {
            MockHttpMessageHandler.SetResponse(string.Empty, HttpStatusCode.InternalServerError);
            var api    = new FriendsApi();
            var result = api.SendRequest("some user id", "my username").Result;

            result.Should().BeNull();
        }
コード例 #5
0
ファイル: FriendsApiTests.cs プロジェクト: dotted/VRChat.Net
        public void CanHandleInternalServerErrorHttpStatusFriendsOfCurrentUserResponse()
        {
            MockHttpMessageHandler.SetResponse(string.Empty, HttpStatusCode.InternalServerError);
            var api    = new FriendsApi();
            var result = api.Get().Result;

            result.Should().BeNull();
        }
コード例 #6
0
ファイル: FriendsApiTests.cs プロジェクト: dotted/VRChat.Net
        public void CanHandleSuccessfulDeleteFriendRequestResponse()
        {
            MockHttpMessageHandler.SetResponse(new JObject(
                                                   new JProperty("success", new JObject(
                                                                     new JProperty("message", "some message"),
                                                                     new JProperty("status_code", 200)))));
            var api    = new FriendsApi();
            var result = api.DeleteFriend("some user id").Result;

            result.Should().NotBeNullOrEmpty();
        }
コード例 #7
0
ファイル: Frdpage.xaml.cs プロジェクト: wesdhy/ACTIVE
        async void OnButtonClicked2(object sender, EventArgs e)
        {
            try
            {
                var response = await DisplayAlert("Question", "delete friend ?", "YES", "NO");

                if (response)
                {
                    errcode ercode = await FriendsApi.DeleteFriend(usid.Text);
                    await DisplayAlert(ercode.success.status_code, ercode.success.message, "ok");
                }
            }
            catch
            {
                await DisplayAlert("errer", " now, not your friend.", "ok");
            }
        }
コード例 #8
0
        /// <summary>
        /// Creates a client to work with VK API methods.
        /// </summary>
        public CitrinaClient()
        {
            AuthHelper = new AuthHelper();
            Execute    = new ExecuteApi();

            Account       = new AccountApi();
            Ads           = new AdsApi();
            Apps          = new AppsApi();
            Auth          = new AuthApi();
            Board         = new BoardApi();
            Database      = new DatabaseApi();
            Docs          = new DocsApi();
            Fave          = new FaveApi();
            Friends       = new FriendsApi();
            Gifts         = new GiftsApi();
            Groups        = new GroupsApi();
            Leads         = new LeadsApi();
            Likes         = new LikesApi();
            Market        = new MarketApi();
            Messages      = new MessagesApi();
            Newsfeed      = new NewsfeedApi();
            Notes         = new NotesApi();
            Notifications = new NotificationsApi();
            Orders        = new OrdersApi();
            Pages         = new PagesApi();
            Photos        = new PhotosApi();
            Places        = new PlacesApi();
            Polls         = new PollsApi();
            Search        = new SearchApi();
            Secure        = new SecureApi();
            Stats         = new StatsApi();
            Status        = new StatusApi();
            Storage       = new StorageApi();
            Users         = new UsersApi();
            Utils         = new UtilsApi();
            Video         = new VideoApi();
            Wall          = new WallApi();
            Widgets       = new WidgetsApi();
        }
コード例 #9
0
ファイル: FriendsApiTests.cs プロジェクト: dotted/VRChat.Net
        public void CanHandleSendFriendRequestResponse()
        {
            MockHttpMessageHandler.SetResponse(new JObject(
                                                   new JProperty("id", "some id"),
                                                   new JProperty("type", "friendrequest"),
                                                   new JProperty("senderUserId", "some sender user id"),
                                                   new JProperty("receiverUserId", "some receiver user id"),
                                                   new JProperty("message", "some message"),
                                                   new JProperty("details", new JObject()),
                                                   new JProperty("jobName", "some job name"),
                                                   new JProperty("jobColor", "some job color")));

            var api    = new FriendsApi();
            var result = api.SendRequest("some user id", "my username").Result;

            result.id.Should().Be("some id");
            result.type.Should().Be("friendrequest");
            result.senderUserId.Should().Be("some sender user id");
            result.receiverUserId.Should().Be("some receiver user id");
            result.message.Should().Be("some message");
            result.details.Should().BeEmpty();
            result.jobName.Should().Be("some job name");
            result.jobColor.Should().Be("some job color");
        }
コード例 #10
0
        public async void FriendList()
        {
            var friends = await FriendsApi.GetFriends();

            Assert.True(friends.Value != null);
        }
コード例 #11
0
 public void Init()
 {
     instance = new FriendsApi();
 }