Skip to content

Commit

Permalink
add #44
Browse files Browse the repository at this point in the history
  • Loading branch information
fa0311 committed Jun 30, 2022
1 parent f61f7c0 commit c6bcf4e
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 4 deletions.
105 changes: 104 additions & 1 deletion lib/api/data_class.dart
Expand Up @@ -12,7 +12,7 @@ class VRChatStatus {
message = json[status]['message'];
statusCode = json[status]['status_code'];
}
} on NoSuchMethodError catch (e) {
} on NoSuchMethodError {
return;
}
}
Expand All @@ -38,6 +38,108 @@ class VRChatLogin {
}
}

class VRChatUserOverload {
late dynamic source;
late VRChatStatus vrchatStatus;
late String id;
late String username;
late String displayName;
late String userIcon;
late String bio;
late List<String> bioLinks;
late String profilePicOverride;
late String statusDescription;
late List<Map<String, String>> pastDisplayNames;
late bool hasEmail;
late bool hasPendingEmail;
late String obfuscatedEmail;
late String obfuscatedPendingEmail;
late bool emailVerified;
late bool hasBirthday;
late bool unsubscribe;
late List<String> statusHistory;
late bool statusFirstTime;
late List<String> friends;
late String friendGroupNames;
late String currentAvatarImageUrl;
late String currentAvatarThumbnailImageUrl;
late String currentAvatar;
late String currentAvatarAssetUrl;
late String fallbackAvatar;
late DateTime? accountDeletionDate;
late int acceptedTOSVersion;
late String steamId;
late dynamic steamDetails; //default {}
late String oculusId;
late bool hasLoggedInFromClient;
late String homeLocation;
late bool twoFactorAuthEnabled;
late String twoFactorAuthEnabledDate;
late String state;
late List<String> tags;
late String developerType;
late String lastLogin;
late String lastPlatform;
late bool allowAvatarCopying;
late String status;
late String dateJoined;
late bool isFriend;
late String friendKey;
late String lastActivity;

VRChatUserOverload.fromJson(dynamic json) {
source = json;
vrchatStatus = VRChatStatus.fromJson(json);
if (vrchatStatus.status == "error") return;

id = json['id'];
username = json['username'];
displayName = json['displayName'];
userIcon = json['userIcon'];
bio = json['bio'];
bioLinks = json['bioLinks'].cast<String>();
profilePicOverride = json['profilePicOverride'];
statusDescription = json['statusDescription'];
pastDisplayNames = json['pastDisplayNames'];
hasEmail = json['hasEmail'];
hasPendingEmail = json['hasPendingEmail'];
obfuscatedEmail = json['obfuscatedEmail'];
obfuscatedPendingEmail = json['obfuscatedPendingEmail'];
emailVerified = json['emailVerified'];
hasBirthday = json['hasBirthday'];
unsubscribe = json['unsubscribe'];
statusHistory = json['statusHistory'].cast<String>();
statusFirstTime = json['statusFirstTime'];
friends = json['friends'].cast<String>();
friendGroupNames = json['friendGroupNames'];
currentAvatarImageUrl = json['currentAvatarImageUrl'];
currentAvatarThumbnailImageUrl = json['currentAvatarThumbnailImageUrl'];
currentAvatar = json['currentAvatar'];
currentAvatarAssetUrl = json['currentAvatarAssetUrl'];
fallbackAvatar = json['fallbackAvatar'];
accountDeletionDate = json['accountDeletionDate'];
acceptedTOSVersion = json['acceptedTOSVersion'];
steamId = json['steamId'];
steamDetails = json['steamDetails'];
oculusId = json['oculusId'];
hasLoggedInFromClient = json['hasLoggedInFromClient'];
homeLocation = json['homeLocation'];
twoFactorAuthEnabled = json['twoFactorAuthEnabled'];
twoFactorAuthEnabledDate = json['twoFactorAuthEnabledDate'];
state = json['state'];
tags = json['tags'].cast<String>();
developerType = json['developerType'];
lastLogin = json['last_login'];
lastPlatform = json['last_platform'];
allowAvatarCopying = json['allowAvatarCopying'];
status = json['status'];
dateJoined = json['date_joined'];
isFriend = json['isFriend'];
friendKey = json['friendKey'];
lastActivity = json['last_activity'];
}
}

class VRChatUsers {
dynamic source;
late VRChatStatus vrchatStatus;
Expand Down Expand Up @@ -90,6 +192,7 @@ class VRChatUser {
VRChatUser.fromJson(Map<String, dynamic> json) {
source = json;
vrchatStatus = VRChatStatus.fromJson(json);
if (vrchatStatus.status == "error") return;
id = json['id'];
username = json['username'];
displayName = json['displayName'];
Expand Down
14 changes: 12 additions & 2 deletions lib/api/main.dart
Expand Up @@ -233,13 +233,23 @@ class VRChatAPI {

// Change

Future<Map<dynamic, dynamic>> changeName(String uid, String username, String password) {
Future<VRChatUserOverload> changeName(String uid, String username, String password) {
return vrchatSession.put(
endpoint(
'api/1/users/$uid',
apiKey(),
),
{"currentPassword": password, "displayName": username},
);
).then((value) => VRChatUserOverload.fromJson(value));
}

Future<VRChatUserOverload> changeBio(String uid, String bio) {
return vrchatSession.put(
endpoint(
'api/1/users/$uid',
apiKey(),
),
{"bio": bio},
).then((value) => VRChatUserOverload.fromJson(value));
}
}
11 changes: 10 additions & 1 deletion lib/widgets/drawer.dart
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';

// Package imports:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:vrchat_mobile_client/api/main.dart';

// Project imports:
import 'package:vrchat_mobile_client/assets/storage.dart';
Expand Down Expand Up @@ -124,7 +125,15 @@ Drawer drawer(BuildContext context) {
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(AppLocalizations.of(context)!.close),
)
),
TextButton(
onPressed: () => {
getLoginSession("login_session").then((cookie) {
VRChatAPI(cookie: cookie ?? "").changeName("aaa", "aaa", "aaa").then((value) => print(value));
})
},
child: Text(AppLocalizations.of(context)!.close),
),
],
),
),
Expand Down

0 comments on commit c6bcf4e

Please sign in to comment.