diff --git a/tests/data/responses/people_batch.json b/tests/data/responses/people_batch.json index fea34571..696ba52b 100644 --- a/tests/data/responses/people_batch.json +++ b/tests/data/responses/people_batch.json @@ -20,6 +20,9 @@ "presenceState": "Offline", "presenceText": "Last seen 49m ago: Xbox App", "presenceDevices": null, + "isFriend": true, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": false, "isQuarantined": false, @@ -30,8 +33,8 @@ "search": null, "titleHistory": null, "multiplayerSummary": { - "InMultiplayerSession": 0, - "InParty": 0 + "inMultiplayerSession": 0, + "inParty": 0 }, "recentPlayer": null, "follower": null, @@ -67,7 +70,17 @@ "mute": false, "followerCount": 105, "followingCount": 121, - "hasGamePass": false + "hasGamePass": false, + "isFriend": true, + "canBeFriended": true, + "canBeFollowed": true, + "friendCount": 150, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "isFriendListShared": true, + "isFollowingCaller": false, + "isFollowedByCaller": false, + "isFavorite": true }, "communityManagerTitles": null, "socialManager": null, @@ -99,6 +112,9 @@ "presenceState": "Online", "presenceText": "Online", "presenceDevices": null, + "isFriend": true, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -109,8 +125,8 @@ "search": null, "titleHistory": null, "multiplayerSummary": { - "InMultiplayerSession": 0, - "InParty": 0 + "inMultiplayerSession": 0, + "inParty": 0 }, "recentPlayer": null, "follower": null, @@ -146,7 +162,17 @@ "mute": false, "followerCount": 78, "followingCount": 83, - "hasGamePass": false + "hasGamePass": false, + "isFriend": true, + "canBeFriended": true, + "canBeFollowed": true, + "friendCount": 150, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "isFriendListShared": true, + "isFollowingCaller": false, + "isFollowedByCaller": false, + "isFavorite": true }, "communityManagerTitles": null, "socialManager": null, @@ -178,6 +204,9 @@ "presenceState": "Online", "presenceText": "Amazon Instant Video", "presenceDevices": null, + "isFriend": true, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -188,8 +217,8 @@ "search": null, "titleHistory": null, "multiplayerSummary": { - "InMultiplayerSession": 0, - "InParty": 0 + "inMultiplayerSession": 0, + "inParty": 0 }, "recentPlayer": null, "follower": null, @@ -236,7 +265,17 @@ "mute": false, "followerCount": 27659, "followingCount": 0, - "hasGamePass": false + "hasGamePass": false, + "isFriend": true, + "canBeFriended": true, + "canBeFollowed": true, + "friendCount": 150, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "isFriendListShared": true, + "isFollowingCaller": false, + "isFollowedByCaller": false, + "isFavorite": true }, "communityManagerTitles": null, "socialManager": null, diff --git a/tests/data/responses/people_friends_by_xuid.json b/tests/data/responses/people_friends_by_xuid.json index 1365fe83..3a13a8d6 100644 --- a/tests/data/responses/people_friends_by_xuid.json +++ b/tests/data/responses/people_friends_by_xuid.json @@ -20,6 +20,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": true, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -30,8 +33,8 @@ "search": null, "titleHistory": null, "multiplayerSummary": { - "InMultiplayerSession": 0, - "InParty": 0 + "inMultiplayerSession": 0, + "inParty": 0 }, "recentPlayer": null, "follower": null, @@ -55,7 +58,17 @@ "mute": false, "followerCount": 50, "followingCount": 34, - "hasGamePass": false + "hasGamePass": false, + "isFriend": true, + "canBeFriended": true, + "canBeFollowed": true, + "friendCount": 150, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "isFriendListShared": true, + "isFollowingCaller": false, + "isFollowedByCaller": false, + "isFavorite": true }, "communityManagerTitles": null, "socialManager": null, @@ -87,6 +100,9 @@ "presenceState": "Online", "presenceText": "YouTube", "presenceDevices": null, + "isFriend": true, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -97,8 +113,8 @@ "search": null, "titleHistory": null, "multiplayerSummary": { - "InMultiplayerSession": 0, - "InParty": 0 + "inMultiplayerSession": 0, + "inParty": 0 }, "recentPlayer": null, "follower": null, @@ -145,7 +161,17 @@ "mute": false, "followerCount": 38, "followingCount": 48, - "hasGamePass": false + "hasGamePass": false, + "isFriend": true, + "canBeFriended": true, + "canBeFollowed": true, + "friendCount": 150, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "isFriendListShared": true, + "isFollowingCaller": false, + "isFollowedByCaller": false, + "isFavorite": true }, "communityManagerTitles": null, "socialManager": null, diff --git a/tests/data/responses/people_friends_own.json b/tests/data/responses/people_friends_own.json index df50a214..ff3b61e9 100644 --- a/tests/data/responses/people_friends_own.json +++ b/tests/data/responses/people_friends_own.json @@ -1,93 +1,120 @@ { "people": [ { - "xuid": "2533274838782903", - "isFavorite": true, - "isFollowingCaller": true, - "isFollowedByCaller": true, - "isIdentityShared": true, - "addedDateTimeUtc": "2016-06-29T20:59:22.5050886Z", - "displayName": "Ikken Hissatsuu", - "realName": "", - "displayPicRaw": "https://images-eds-ssl.xboxlive.com/image?url=7OTVnZUMVj4OV2zUUGecWvn3U00nQQLfK7_kwpANogj9vJpb.t4ZQMMLIWOuBZBBZs5MjD7okwh5Zwnit1SAtO3OAsFXxJc1ALIbaVoRo7gsiun9FdcaTpzkM60nqzT8ip1659eQpB1SLyupscP.ec_wAGvXwkhCcTKCNHQMrxg-&format=png", - "showUserAsAvatar": "1", - "gamertag": "Ikken Hissatsuu", - "gamerScore": "27210", - "modernGamertag": "Ikken Hissatsuu", - "modernGamertagSuffix": "", - "uniqueModernGamertag": "Ikken Hissatsuu", - "xboxOneRep": "GoodPlayer", - "presenceState": "Offline", - "presenceText": "Offline", - "presenceDevices": null, - "isBroadcasting": false, - "isCloaked": null, - "isQuarantined": false, - "isXbox360Gamerpic": false, - "lastSeenDateTimeUtc": null, - "suggestion": { - "Type": null, - "Priority": 0, - "Reasons": null, - "TitleId": null - }, - "recommendation": null, - "search": null, - "titleHistory": null, - "multiplayerSummary": { - "InMultiplayerSession": 0, - "InParty": 0 - }, - "recentPlayer": { - "titles": [], - "text": null - }, - "follower": { - "text": null, - "followedDateTime": "0001-01-01T00:00:00" - }, - "preferredColor": { - "primaryColor": "744DA9", - "secondaryColor": "24153B", - "tertiaryColor": "4c208a" - }, - "presenceDetails": [], - "titlePresence": { - "IsCurrentlyPlaying": false, - "PresenceText": null, - "TitleName": null, - "TitleId": null - }, - "titleSummaries": null, - "presenceTitleIds": [], - "detail": { - "accountTier": "Gold", - "bio": "Bio", - "isVerified": false, - "location": "Rock Hill", - "tenure": "8", - "watermarks": [], - "blocked": false, - "mute": false, - "followerCount": 81, - "followingCount": 73, - "hasGamePass": false - }, - "communityManagerTitles": null, - "socialManager": { - "titleIds": [], - "pages": [] - }, - "broadcast": [], - "tournamentSummary": null, - "avatar": { - "updateTimeOffset": "0001-01-01T00:00:00+00:00", - "spritesheetMetadata": null - }, - "linkedAccounts": [], - "colorTheme": "gamerpicblur", - "preferredFlag": "", - "preferredPlatforms": [] + "xuid": "2533274838782903", + "isFavorite": true, + "isFollowingCaller": true, + "isFollowedByCaller": true, + "isIdentityShared": true, + "addedDateTimeUtc": "2016-06-29T20:59:22.5050886Z", + "displayName": "Ikken Hissatsuu", + "realName": "", + "displayPicRaw": "https://images-eds-ssl.xboxlive.com/image?url=7OTVnZUMVj4OV2zUUGecWvn3U00nQQLfK7_kwpANogj9vJpb.t4ZQMMLIWOuBZBBZs5MjD7okwh5Zwnit1SAtO3OAsFXxJc1ALIbaVoRo7gsiun9FdcaTpzkM60nqzT8ip1659eQpB1SLyupscP.ec_wAGvXwkhCcTKCNHQMrxg-&format=png", + "showUserAsAvatar": "1", + "gamertag": "Ikken Hissatsuu", + "gamerScore": "27210", + "modernGamertag": "Ikken Hissatsuu", + "modernGamertagSuffix": "", + "uniqueModernGamertag": "Ikken Hissatsuu", + "xboxOneRep": "GoodPlayer", + "presenceState": "Offline", + "isFriend": true, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "presenceText": "Offline", + "presenceDevices": null, + "isBroadcasting": false, + "isCloaked": null, + "isQuarantined": false, + "isXbox360Gamerpic": false, + "lastSeenDateTimeUtc": null, + "suggestion": { + "Type": null, + "Priority": 0, + "Reasons": null, + "TitleId": null + }, + "recommendation": null, + "search": null, + "titleHistory": null, + "multiplayerSummary": { + "inMultiplayerSession": 0, + "inParty": 0, + "joinableActivities": [], + "partyDetails": [ + { + "sessionRef": { + "scid": "7492baca-c1b4-440d-a391-b7ef364a8d40", + "templateName": "chat", + "name": "51935651-e782-45c6-854a-7a3858fc103a" + }, + "status": "active", + "visibility": "open", + "joinRestriction": "followed", + "accepted": 1 + } + ] + }, + "recentPlayer": { + "titles": [], + "text": null + }, + "follower": { + "text": null, + "followedDateTime": "0001-01-01T00:00:00" + }, + "preferredColor": { + "primaryColor": "744DA9", + "secondaryColor": "24153B", + "tertiaryColor": "4c208a" + }, + "presenceDetails": [], + "titlePresence": { + "IsCurrentlyPlaying": false, + "PresenceText": null, + "TitleName": null, + "TitleId": null + }, + "titleSummaries": null, + "presenceTitleIds": [], + "detail": { + "accountTier": "Gold", + "bio": "Bio", + "isVerified": false, + "location": "Rock Hill", + "tenure": "8", + "watermarks": [], + "blocked": false, + "mute": false, + "followerCount": 81, + "followingCount": 73, + "hasGamePass": false, + "isFriend": true, + "canBeFriended": true, + "canBeFollowed": true, + "friendCount": 150, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "isFriendListShared": true, + "isFollowingCaller": false, + "isFollowedByCaller": false, + "isFavorite": true + }, + "communityManagerTitles": null, + "socialManager": { + "titleIds": [], + "pages": [] + }, + "broadcast": [], + "tournamentSummary": null, + "avatar": { + "updateTimeOffset": "0001-01-01T00:00:00+00:00", + "spritesheetMetadata": null + }, + "linkedAccounts": [], + "colorTheme": "gamerpicblur", + "preferredFlag": "", + "preferredPlatforms": [] }, { "xuid": "2533274913657542", @@ -109,6 +136,9 @@ "presenceState": "Offline", "presenceText": "Last seen 17h ago: Home", "presenceDevices": null, + "isFriend": true, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -124,8 +154,8 @@ "search": null, "titleHistory": null, "multiplayerSummary": { - "InMultiplayerSession": 0, - "InParty": 0 + "inMultiplayerSession": 0, + "inParty": 0 }, "recentPlayer": { "titles": [], @@ -174,7 +204,17 @@ "mute": false, "followerCount": 18, "followingCount": 12, - "hasGamePass": false + "hasGamePass": false, + "isFriend": true, + "canBeFriended": true, + "canBeFollowed": true, + "friendCount": 150, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, + "isFriendListShared": true, + "isFollowingCaller": false, + "isFollowedByCaller": false, + "isFavorite": true }, "communityManagerTitles": null, "socialManager": { diff --git a/tests/data/responses/people_recommendations.json b/tests/data/responses/people_recommendations.json index b3e783a4..836c0cce 100644 --- a/tests/data/responses/people_recommendations.json +++ b/tests/data/responses/people_recommendations.json @@ -20,6 +20,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -73,6 +76,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -126,6 +132,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -179,6 +188,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -232,6 +244,9 @@ "presenceState": "Online", "presenceText": "Home", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -285,6 +300,9 @@ "presenceState": "Offline", "presenceText": "Last seen 7h ago: Xbox App", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -338,6 +356,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -391,6 +412,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -444,6 +468,9 @@ "presenceState": "Offline", "presenceText": "Last seen 11h ago: Home", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -497,6 +524,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -550,6 +580,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -603,6 +636,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -656,6 +692,9 @@ "presenceState": "Offline", "presenceText": "Last seen 11h ago: Online", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -709,6 +748,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -762,6 +804,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -815,6 +860,9 @@ "presenceState": "Offline", "presenceText": "Last seen 11h ago: Xbox App", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -868,6 +916,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -921,6 +972,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -974,6 +1028,9 @@ "presenceState": "Online", "presenceText": "Destiny 2", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1027,6 +1084,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1080,6 +1140,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1133,6 +1196,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1186,6 +1252,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1239,6 +1308,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1292,6 +1364,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1345,6 +1420,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1398,6 +1476,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1451,6 +1532,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1504,6 +1588,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1557,6 +1644,9 @@ "presenceState": "Offline", "presenceText": "Offline", "presenceDevices": null, + "isFriend": false, + "isFriendRequestReceived": false, + "isFriendRequestSent": false, "isBroadcasting": false, "isCloaked": null, "isQuarantined": false, @@ -1598,7 +1688,8 @@ "follower": 10, "VIP": 0, "steamFriend": 0, - "promoteSuggestions": false + "promoteSuggestions": false, + "communitySuggestion": 0 }, "friendFinderState": { "facebookOptInStatus": "OptedIn", diff --git a/tests/data/responses/people_summary_by_gamertag.json b/tests/data/responses/people_summary_by_gamertag.json index 71c06888..48e705fa 100644 --- a/tests/data/responses/people_summary_by_gamertag.json +++ b/tests/data/responses/people_summary_by_gamertag.json @@ -1,4 +1,5 @@ { + "isFriend": false, "targetFollowingCount": 0, "targetFollowerCount": 27660, "isCallerFollowingTarget": false, diff --git a/tests/data/responses/people_summary_by_xuid.json b/tests/data/responses/people_summary_by_xuid.json index 71c06888..48e705fa 100644 --- a/tests/data/responses/people_summary_by_xuid.json +++ b/tests/data/responses/people_summary_by_xuid.json @@ -1,4 +1,5 @@ { + "isFriend": false, "targetFollowingCount": 0, "targetFollowerCount": 27660, "isCallerFollowingTarget": false, diff --git a/tests/data/responses/people_summary_own.json b/tests/data/responses/people_summary_own.json index 39daf366..ff4ab3c2 100644 --- a/tests/data/responses/people_summary_own.json +++ b/tests/data/responses/people_summary_own.json @@ -1,4 +1,5 @@ { + "isFriend": false, "targetFollowingCount": 121, "targetFollowerCount": 105, "isCallerFollowingTarget": false, diff --git a/xbox/webapi/api/provider/people/__init__.py b/xbox/webapi/api/provider/people/__init__.py index 93d3882e..1d19fe1a 100644 --- a/xbox/webapi/api/provider/people/__init__.py +++ b/xbox/webapi/api/provider/people/__init__.py @@ -1,22 +1,24 @@ """ People - Access friendlist from own profiles and others """ -from typing import List -from xbox.webapi.api.provider.ratelimitedprovider import RateLimitedProvider from xbox.webapi.api.provider.people.models import ( PeopleDecoration, PeopleResponse, PeopleSummaryResponse, ) +from xbox.webapi.api.provider.ratelimitedprovider import RateLimitedProvider +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from xbox.webapi.api.client import XboxLiveClient class PeopleProvider(RateLimitedProvider): SOCIAL_URL = "https://social.xboxlive.com" HEADERS_SOCIAL = {"x-xbl-contract-version": "2"} PEOPLE_URL = "https://peoplehub.xboxlive.com" HEADERS_PEOPLE = { - "x-xbl-contract-version": "3", + "x-xbl-contract-version": "7", "Accept-Language": "overwrite in __init__", } SEPERATOR = "," @@ -24,7 +26,9 @@ class PeopleProvider(RateLimitedProvider): # NOTE: Rate Limits are noted for social.xboxlive.com ONLY RATE_LIMITS = {"burst": 10, "sustain": 30} - def __init__(self, client): + client: "XboxLiveClient" + + def __init__(self, client: "XboxLiveClient") -> None: """ Initialize Baseclass, set 'Accept-Language' header from client instance @@ -36,7 +40,7 @@ def __init__(self, client): self._headers.update({"Accept-Language": self.client.language.locale}) async def get_friends_own( - self, decoration_fields: List[PeopleDecoration] = None, **kwargs + self, decoration_fields: list[PeopleDecoration] | None = None, **kwargs ) -> PeopleResponse: """ Get friendlist of own profile @@ -53,13 +57,13 @@ async def get_friends_own( ] decoration = self.SEPERATOR.join(decoration_fields) - url = f"{self.PEOPLE_URL}/users/me/people/social/decoration/{decoration}" + url = f"{self.PEOPLE_URL}/users/me/people/friends/decoration/{decoration}" resp = await self.client.session.get(url, headers=self._headers, **kwargs) resp.raise_for_status() return PeopleResponse(**resp.json()) async def get_friends_by_xuid( - self, xuid: str, decoration_fields: List[PeopleDecoration] = None, **kwargs + self, xuid: str, decoration_fields: list[PeopleDecoration] | None = None, **kwargs ) -> PeopleResponse: """ Get friendlist of own profile @@ -76,15 +80,15 @@ async def get_friends_by_xuid( ] decoration = self.SEPERATOR.join(decoration_fields) - url = f"{self.PEOPLE_URL}/users/xuid({xuid})/people/social/decoration/{decoration}" + url = f"{self.PEOPLE_URL}/users/me/people/xuids({xuid})/decoration/{decoration}" resp = await self.client.session.get(url, headers=self._headers, **kwargs) resp.raise_for_status() return PeopleResponse(**resp.json()) async def get_friends_own_batch( self, - xuids: List[str], - decoration_fields: List[PeopleDecoration] = None, + xuids: list[str], + decoration_fields: list[PeopleDecoration] | None = None, **kwargs, ) -> PeopleResponse: """ @@ -112,14 +116,18 @@ async def get_friends_own_batch( resp.raise_for_status() return PeopleResponse(**resp.json()) - async def get_friend_recommendations(self, **kwargs) -> PeopleResponse: + async def get_friend_recommendations(self, decoration_fields: list[PeopleDecoration] | None = None, **kwargs) -> PeopleResponse: """ Get recommended friends Returns: :class:`PeopleResponse`: People Response """ - url = f"{self.PEOPLE_URL}/users/me/people/recommendations" + if not decoration_fields: + decoration_fields = [PeopleDecoration.DETAIL] + decoration = self.SEPERATOR.join(decoration_fields) + + url = f"{self.PEOPLE_URL}/users/me/people/recommendations/decoration/{decoration}" resp = await self.client.session.get(url, headers=self._headers, **kwargs) resp.raise_for_status() return PeopleResponse(**resp.json()) diff --git a/xbox/webapi/api/provider/people/models.py b/xbox/webapi/api/provider/people/models.py index 822c848b..83190be8 100644 --- a/xbox/webapi/api/provider/people/models.py +++ b/xbox/webapi/api/provider/people/models.py @@ -1,25 +1,30 @@ + +from __future__ import annotations + from datetime import datetime -from enum import Enum -from typing import Any, List, Optional +from enum import StrEnum +from typing import Any + +from pydantic import Field from xbox.webapi.common.models import CamelCaseModel, PascalCaseModel -class PeopleDecoration(str, Enum): +class PeopleDecoration(StrEnum): SUGGESTION = "suggestion" - RECENT_PLAYER = "recentplayer" + RECENT_PLAYER = "recentPlayer" FOLLOWER = "follower" - PREFERRED_COLOR = "preferredcolor" + PREFERRED_COLOR = "preferredColor" DETAIL = "detail" - MULTIPLAYER_SUMMARY = "multiplayersummary" - PRESENCE_DETAIL = "presencedetail" - TITLE_PRESENCE = "titlepresence" - TITLE_SUMMARY = "titlesummary" - PRESENCE_TITLE_IDS = "presencetitleids" - COMMUNITY_MANAGER_TITLES = "communitymanagertitles" - SOCIAL_MANAGER = "socialmanager" + MULTIPLAYER_SUMMARY = "multiplayerSummary" + PRESENCE_DETAIL = "presenceDetail" + TITLE_PRESENCE = "titlePresence" + TITLE_SUMMARY = "titleSummary" + PRESENCE_TITLE_IDS = "presenceTitleIds" + COMMUNITY_MANAGER_TITLES = "communityManagerTitles" + SOCIAL_MANAGER = "socialManager" BROADCAST = "broadcast" - TOURNAMENT_SUMMARY = "tournamentsummary" + TOURNAMENT_SUMMARY = "tournamentSummary" AVATAR = "avatar" @@ -31,93 +36,119 @@ class PeopleSummaryResponse(CamelCaseModel): has_caller_marked_target_as_favorite: bool has_caller_marked_target_as_identity_shared: bool legacy_friend_status: str - available_people_slots: Optional[int] = None - recent_change_count: Optional[int] = None - watermark: Optional[str] = None + available_people_slots: int | None = None + recent_change_count: int | None = None + watermark: str | None = None + is_friend: bool class Suggestion(PascalCaseModel): - type: Optional[str] = None + type: str | None = None priority: int - reasons: Optional[str] = None - title_id: Optional[str] = None + reasons: str | None = None + title_id: str | None = None class Recommendation(PascalCaseModel): type: str - reasons: List[str] - - -class MultiplayerSummary(PascalCaseModel): - in_multiplayer_session: int + reasons: list[str] + +class SessionRef(CamelCaseModel): + scid: str + template_name: str + name: str + +class PartyDetails(CamelCaseModel): + session_ref: SessionRef + status: str + visibility: str + join_restriction: str + accepted: int + +class MultiplayerSummary(CamelCaseModel): + in_multiplayer_session: int | None = None in_party: int + joinable_activities: list = Field(default_factory=list) + party_details: list[PartyDetails] = Field(default_factory=list) class RecentPlayer(CamelCaseModel): - titles: List[str] - text: Optional[str] = None + titles: list[str] + text: str | None = None class Follower(CamelCaseModel): - text: Optional[str] = None - followed_date_time: Optional[datetime] = None + text: str | None = None + followed_date_time_utc: datetime | None = None class PreferredColor(CamelCaseModel): - primary_color: Optional[str] = None - secondary_color: Optional[str] = None - tertiary_color: Optional[str] = None + primary_color: str | None = None + secondary_color: str | None = None + tertiary_color: str | None = None class PresenceDetail(PascalCaseModel): is_broadcasting: bool device: str + device_sub_type: str | None = None + gameplay_type: str | None = None presence_text: str state: str title_id: str - title_type: Optional[str] = None + title_type: str | None = None is_primary: bool is_game: bool - rich_presence_text: Optional[str] = None + rich_presence_text: str | None = None class TitlePresence(PascalCaseModel): is_currently_playing: bool - presence_text: Optional[str] = None - title_name: Optional[str] = None - title_id: Optional[str] = None + presence_text: str | None = None + title_name: str | None = None + title_id: str | None = None class Detail(CamelCaseModel): account_tier: str - bio: Optional[str] = None + bio: str | None = None is_verified: bool - location: Optional[str] = None - tenure: Optional[str] = None - watermarks: List[str] + location: str | None = None + tenure: str | None = None + watermarks: list[str] blocked: bool mute: bool follower_count: int following_count: int has_game_pass: bool + can_be_friended: bool + can_be_followed: bool + is_friend: bool + friend_count: int + is_friend_request_received: bool + is_friend_request_sent: bool + is_friend_list_shared: bool + is_following_caller: bool + is_followed_by_caller: bool + is_favorite: bool class SocialManager(CamelCaseModel): - title_ids: List[str] - pages: List[str] + title_ids: list[str] + pages: list[str] class Avatar(CamelCaseModel): - update_time_offset: Optional[datetime] = None - spritesheet_metadata: Optional[Any] = None + update_time_offset: datetime | None = None + spritesheet_metadata: Any | None = None class LinkedAccount(CamelCaseModel): network_name: str - display_name: Optional[str] = None + display_name: str | None = None show_on_profile: bool is_family_friendly: bool - deeplink: Optional[str] = None + deeplink: str | None = None class Person(CamelCaseModel): @@ -126,8 +157,8 @@ class Person(CamelCaseModel): is_following_caller: bool is_followed_by_caller: bool is_identity_shared: bool - added_date_time_utc: Optional[datetime] = None - display_name: Optional[str] = None + added_date_time_utc: datetime | None = None + display_name: str | None = None real_name: str display_pic_raw: str show_user_as_avatar: str @@ -139,44 +170,51 @@ class Person(CamelCaseModel): xbox_one_rep: str presence_state: str presence_text: str - presence_devices: Optional[Any] = None + presence_devices: Any | None = None is_broadcasting: bool - is_cloaked: Optional[bool] = None + is_cloaked: bool | None = None is_quarantined: bool is_xbox_360_gamerpic: bool - last_seen_date_time_utc: Optional[datetime] = None - suggestion: Optional[Suggestion] = None - recommendation: Optional[Recommendation] = None - search: Optional[Any] = None - titleHistory: Optional[Any] = None - multiplayer_summary: Optional[MultiplayerSummary] = None - recent_player: Optional[RecentPlayer] = None - follower: Optional[Follower] = None - preferred_color: Optional[PreferredColor] = None - presence_details: Optional[List[PresenceDetail]] = None - title_presence: Optional[TitlePresence] = None - title_summaries: Optional[Any] = None - presence_title_ids: Optional[List[str]] = None - detail: Optional[Detail] = None - community_manager_titles: Optional[Any] = None - social_manager: Optional[SocialManager] = None - broadcast: Optional[List[Any]] = None - tournament_summary: Optional[Any] = None - avatar: Optional[Avatar] = None - linked_accounts: Optional[List[LinkedAccount]] = None + last_seen_date_time_utc: datetime | None = None + suggestion: Suggestion | None = None + recommendation: Recommendation | None = None + search: Any | None = None + titleHistory: Any | None = None + multiplayer_summary: MultiplayerSummary | None = None + recent_player: RecentPlayer | None = None + follower: Follower | None = None + preferred_color: PreferredColor | None = None + presence_details: list[PresenceDetail] | None = None + title_presence: TitlePresence | None = None + title_summaries: Any | None = None + presence_title_ids: list[str] | None = None + detail: Detail | None = None + community_manager_titles: Any | None = None + social_manager: SocialManager | None = None + broadcast: list[Any] | None = None + tournament_summary: Any | None = None + avatar: Avatar | None = None + linked_accounts: list[LinkedAccount] | None = None color_theme: str preferred_flag: str - preferred_platforms: List[Any] + preferred_platforms: list[Any] + friended_date_time_utc: datetime | None = None + is_friend: bool + is_friend_request_received: bool + is_friend_request_sent: bool + class RecommendationSummary(CamelCaseModel): - friend_of_friend: int - facebook_friend: int - phone_contact: int - follower: int - VIP: int + friend_of_friend: int | None = None + facebook_friend: int | None = None + phone_contact: int | None = None + follower: int | None = None + VIP: int | None = None steam_friend: int promote_suggestions: bool + community_suggestion: int + class FriendFinderState(CamelCaseModel): @@ -201,9 +239,12 @@ class FriendFinderState(CamelCaseModel): you_tube_opt_in_status: str you_tube_token_status: str +class FriendRequestSummary(CamelCaseModel): + friend_requests_received_count: int class PeopleResponse(CamelCaseModel): - people: List[Person] - recommendation_summary: Optional[RecommendationSummary] = None - friend_finder_state: Optional[FriendFinderState] = None - account_link_details: Optional[List[LinkedAccount]] = None + people: list[Person] + recommendation_summary: RecommendationSummary | None = None + friend_finder_state: FriendFinderState | None = None + account_link_details: list[LinkedAccount] | None = None + friend_request_summary: FriendRequestSummary | None = None \ No newline at end of file