Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FEATURE REQUEST] Rename Clients #16

Closed
JaronrH opened this issue Nov 2, 2020 · 1 comment
Closed

[FEATURE REQUEST] Rename Clients #16

JaronrH opened this issue Nov 2, 2020 · 1 comment

Comments

@JaronrH
Copy link

JaronrH commented Nov 2, 2020

I needed the ability to rename clients so I added the following to your API:

        /// <summary>
        /// Rename Client
        /// </summary>
        /// <param name="client">Client to rename</param>
        /// <param name="name">New Name</param>
        public async Task<Responses.ResponseEnvelope<Responses.Clients>> RenameClient(Responses.Clients client, string name)
        {
            return await RenameClient(client.Id, name);
        }

        /// <summary>
        /// Rename Client
        /// </summary>
        /// <param name="userId">Client's User Id for client to be renamed.</param>
        /// <param name="name">New Name</param>
        public async Task<Responses.ResponseEnvelope<Responses.Clients>> RenameClient(string userId, string name)
        {
            // Make the POST request towards the UniFi API to rename a client.
            var resultString = await HttpUtility.PostRequest(new Uri(BaseUri, $"/api/s/{SiteId}/upd/user/{userId}"),
                JsonConvert.SerializeObject(new {name}),
                _cookieContainer,
                ConnectionTimeout);
            var resultJson = JsonConvert.DeserializeObject<Responses.ResponseEnvelope<Responses.Clients>>(resultString);

            return resultJson;
        }
@JaronrH JaronrH added the Reviewing Item is being reviewed label Nov 2, 2020
@KoenZomers
Copy link
Owner

Thanks for the suggestion! Just released a new version in which this has been included.
https://www.nuget.org/packages/KoenZomers.UniFi.Api/1.1.8

@KoenZomers KoenZomers added enhancement resolved and removed Reviewing Item is being reviewed labels Nov 16, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants