/// <summary>
        /// Lists all groups and roles for an entity
        /// </summary>
        public static void ListMembership(ListMembershipRequest request, Action <ListMembershipResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;


            PlayFabHttp.MakeApiCall("/Group/ListMembership", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context);
        }
Exemplo n.º 2
0
        public void ListGroups(Action <ListMembershipResponse> callback)
        {
            var request = new ListMembershipRequest {
                Entity = PlayFabManager.Instance.GetUserGroupEntity()
            };

            PlayFabGroupsAPI.ListMembership(request, callback, (PlayFabError e) => callback(null));
        }
        /// <summary>
        /// Lists all groups and roles for an entity
        /// </summary>
        public void ListMembership(ListMembershipRequest request, Action <ListMembershipResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context      = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
            var callSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (!context.IsEntityLoggedIn())
            {
                throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn, "Must be logged in to call this method");
            }
            PlayFabHttp.MakeApiCall("/Group/ListMembership", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lists all groups and roles for an entity
        /// </summary>
        /// <param name="Entity">The entity to perform this action on. (Optional)</param>
        public static Task <ListMembershipResponse> ListMembership(EntityKey Entity = default,
                                                                   PlayFabAuthenticationContext customAuthContext = null, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            ListMembershipRequest request = new ListMembershipRequest()
            {
                Entity = Entity,
            };

            var context = GetContext(customAuthContext);

            return(PlayFabHttp.MakeApiCallAsync <ListMembershipResponse>("/Group/ListMembership", request,
                                                                         AuthType.EntityToken,
                                                                         customData, extraHeaders, context));
        }
Exemplo n.º 5
0
    /*
     *  Upon successful login, set up the store for our game and find the user's wish list.
     *
     *  @param result: the PlayFab LoginResult object which occurs upon a successful call to LoginWithPlayFab
     *
     *  When the player clicks the button to log in, the Client calls LoginWithPlayFabRequest to return
     *  the login token. Authenticate the client in order to call other PlayFab Client APIs.
     *
     */

    private void OnLoginSuccess(LoginResult result)
    {
        LoginClass.player_entityKeyId   = result.EntityToken.Entity.Id;
        LoginClass.player_entityKeyType = result.EntityToken.Entity.Type;

        PlayFab.GroupsModels.EntityKey entity = new PlayFab.GroupsModels.EntityKey {
            Id = LoginClass.player_entityKeyId, Type = LoginClass.player_entityKeyType
        };

        var request = new ListMembershipRequest {
            Entity = entity
        };

        /* Set up the store buttons for the Unity game. This will change depending on the nature of your game. */

        StoreSetup.StoreStart();

        /* Now that the player has logged in, find their wish list. If not found, create it. */

        WishList.FindOrCreateWishList(LoginClass.player_entityKeyId, LoginClass.player_entityKeyType);
    }
        /// <summary>
        /// Lists all groups and roles for an entity
        /// </summary>
        public static async Task <PlayFabResult <ListMembershipResponse> > ListMembershipAsync(ListMembershipRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            if ((request?.AuthenticationContext?.EntityToken ?? PlayFabSettings.staticPlayer.EntityToken) == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call GetEntityToken before calling this method");
            }


            var httpResult = await PlayFabHttp.DoPost("/Group/ListMembership", request, "X-EntityToken", PlayFabSettings.staticPlayer.EntityToken, extraHeaders);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <ListMembershipResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <ListMembershipResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <ListMembershipResponse> {
                Result = result, CustomData = customData
            });
        }
Exemplo n.º 7
0
 /// <summary>
 /// Lists all groups and roles for an entity
 /// </summary>
 public static void ListMembership(ListMembershipRequest request, Action <ListMembershipResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
 {
     PlayFabHttp.MakeApiCall("/Group/ListMembership", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders);
 }
Exemplo n.º 8
0
    /*
     *  Find the entity group for the player's wish list, or create one if does not exist
     *
     *  @param player_entityKeyId: the entity ID of the player; for a title entity the ID should be;
     *      in most cases, this can be found in LoginResult.EntityToken.Entity.Id
     *  @param player_entityKeyType: the entity type of the player whose wish list we are searching
     *      for; should be title_player_account entity in most cases
     *
     *  Upon login, this function examines all entity groups that the player belongs to. For each group,
     *  the group name is compared to the nomenclature for wish list groups. If the group is not found,
     *  then one is created
     */

    public static void FindOrCreateWishList(string player_entityKeyId, string player_entityKeyType)
    {
        /* Create entity key for the ListMembership request */

        PlayFab.GroupsModels.EntityKey entity = new PlayFab.GroupsModels.EntityKey {
            Id = player_entityKeyId, Type = player_entityKeyType
        };

        var request = new ListMembershipRequest {
            Entity = entity
        };

        PlayFabGroupsAPI.ListMembership(request, membershipResult => {
            bool found = false; // Will tell us whether the wish list entity group exists

            /*
             *  Iterate through all groups the player belongs to. If the wish list entity group exists,
             *  it should be one of these groups
             */

            for (int i = 0; i < membershipResult.Groups.Count; i++)
            {
                string group_name = LoginClass.getPlayerEntityKeyId() + "wishlist";

                /* Compare the name of the group to the nomenclature the wish list entity group name will follow */

                if (membershipResult.Groups[i].GroupName.Equals(group_name))
                {
                    found = true; // If the name matches, we found the wish list entity group

                    /* Set the wish list group's entity ID and entity type so we can access the group in other functions */
                    WishList.group_entityKeyId   = membershipResult.Groups[i].Group.Id;
                    WishList.group_entityKeyType = membershipResult.Groups[i].Group.Type;

                    PlayFab.DataModels.EntityKey group_ek = new PlayFab.DataModels.EntityKey {
                        Id = membershipResult.Groups[i].Group.Id, Type = membershipResult.Groups[i].Group.Type
                    };
                    GetObjectsRequest getObjectsRequest = new GetObjectsRequest {
                        Entity = group_ek
                    };

                    /*  This is the wish list entity group. To get the wish list CSV, we need to get the object in that entity
                     *  group with the "wishlist" key
                     */

                    PlayFabDataAPI.GetObjects(getObjectsRequest, objectResult => {
                        if (!string.IsNullOrEmpty((string)objectResult.Objects["wishlist"].DataObject))
                        {
                            string wl = (string)objectResult.Objects["wishlist"].DataObject;
                            /* Set up the Unity game store. Specifically, change colors and button text if an item is on the wishlist */
                            StoreSetup.SetUpStore(wl, false);
                        }
                    }, error => { Debug.LogError(error.GenerateErrorReport()); });
                }
            }

            // AddPlayFabIdToGroup(); // Where should this go?


            /* Wish list entity group does not exist, so create one */
            if (!found)
            {
                /*
                 *  Wish list entity groups should follow the following nomenclature:
                 *  [PlayFab title ID] + "wishlist.
                 *
                 *  This nomenclature allows us to find the group by name in the future.
                 */
                string group_name = LoginClass.getPlayerEntityKeyId() + "wishlist";
                CreateWishlist(group_name);
            }
        }, error => { Debug.LogError(error.GenerateErrorReport()); });
    }