コード例 #1
0
ファイル: UserApi.cs プロジェクト: Bluscream/VRChat.Net
        public async Task <UserResponse> UpdateInfo(string userId, string email = null, string birthday = null, string acceptedTOSVersion = null, List <string> tags = null, string status = null, string statusDescription = null)
        {
            Logger.Debug(() => $"Updating user info for {nameof(userId)} = {userId} with {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}, {nameof(tags)} = {tags}, {nameof(status)} = {status}, {nameof(statusDescription)} = {statusDescription}");

            JObject json = new JObject();

            json.AddIfNotNull("email", email);
            json.AddIfNotNull("birthday", birthday);
            json.AddIfNotNull("acceptedTOSVersion", acceptedTOSVersion);
            if (tags != null)
            {
                json.Add("tags", JToken.FromObject(tags));
            }
            json.AddIfNotNull("status", status);
            json.AddIfNotNull("statusDescription", statusDescription);

            Logger.Debug(() => $"Prepared JSON to put: {json}");

            StringContent content = new StringContent(json.ToString(), Encoding.UTF8);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            HttpResponseMessage response = await Global.HttpClient.PutAsync($"users/{userId}?apiKey={Global.ApiKey}", content);

            return(await Utils.ParseResponse <UserResponse>(response));
        }
コード例 #2
0
        private JObject ConvertModule(Module module)
        {
            var item = new JObject
            {
                ["slotName"]     = module.Slot,
                ["itemName"]     = module.Item,
                ["itemHealth"]   = module.Health,
                ["isOn"]         = module.On,
                ["isHot"]        = false, // TODO!
                ["itemPriority"] = module.Priority,
            };

            item.AddIfNotNull("itemAmmoClip", module.AmmoInClip);
            item.AddIfNotNull("itemAmmoHopper", module.AmmoInHopper);
            item.AddIfNotNull("itemValue", module.Value);
            if (module.Engineering != null)
            {
                item["engineering"] = ConvertEngineering(module.Engineering);
            }
            return(item);
        }
コード例 #3
0
        private JObject ConvertEngineering(ModuleEngineering eng)
        {
            var item = new JObject
            {
                ["blueprintName"]    = eng.BlueprintName,
                ["blueprintLevel"]   = eng.Level,
                ["blueprintQuality"] = eng.Quality,
                ["modifiers"]        = new JArray(eng.Modifiers.Select(ConvertModifier).ToArray())
            };

            item.AddIfNotNull("experimentalEffect", eng.ExperimentalEffect);
            return(item);
        }
コード例 #4
0
ファイル: UserApi.cs プロジェクト: Bluscream/VRChat.Net
        public async Task <UserResponse> Register(string username, string password, string email, string birthday = null, string acceptedTOSVersion = null)
        {
            Logger.Debug(() => $"Registering new user with {nameof(username)} = {username}, {nameof(email)} = {email}, {nameof(birthday)} = {birthday}, {nameof(acceptedTOSVersion)} = {acceptedTOSVersion}");

            JObject json = new JObject()
            {
                { "username", username },
                { "password", password }
            };

            json.AddIfNotNull("email", email);
            json.AddIfNotNull("birthday", birthday);
            json.AddIfNotNull("acceptedTOSVersion", acceptedTOSVersion);

            Logger.Debug(() => $"Prepared JSON to post: {json}");

            StringContent content = new StringContent(json.ToString(), Encoding.UTF8);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            HttpResponseMessage response = await Global.HttpClient.PostAsync($"auth/register?apiKey={Global.ApiKey}", content);

            return(await Utils.ParseResponse <UserResponse>(response));
        }