예제 #1
0
        /// <summary>
        ///     Get all users filtered by user access type [user kind].
        /// </summary>
        /// <param name="userAccessType">The user access type.</param>
        /// <returns></returns>
        public async Task <List <User> > GetUsers(UserAccessTypes userAccessType)
        {
            var request = new GraphQLRequest
            {
                Query     = @"query request($userKind:UserKind) { users(kind:$userKind) { id name email url photo_original title birthday country_code location time_zone_identifier phone mobile_phone is_guest is_pending enabled created_at }}",
                Variables = new
                {
                    userKind = userAccessType.GetVariableUserAccessType()
                }
            };

            var result = await _graphQlHttpClient.SendQueryAsync <GetUsersResponse>(request);

            ThrowResponseErrors(result.Errors);

            return(result.Data.Users);
        }
        internal static string GetVariableUserAccessType(this UserAccessTypes userAccessType)
        {
            switch (userAccessType)
            {
            case UserAccessTypes.All:
                return("all");

            case UserAccessTypes.NonGuests:
                return("non_guests");

            case UserAccessTypes.Guests:
                return("guests");

            case UserAccessTypes.NonPending:
                return("non_pending");
            }

            return(null);
        }