Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Latest commit

 

History

History
65 lines (51 loc) · 2.85 KB

File metadata and controls

65 lines (51 loc) · 2.85 KB

Removing a participant from a group.

Implementation note
This method is available in both synchronous and asynchronous implementations.

Request

Parameter Description The data type of the parameter Required parameter
GroupId Unique ID of the group String
ParticipantPhone The phone number of the participant being added to the group String
  • Only ParticipantPhone is specified
  • Only ParticipantChatId is specified
ParticipantChatId Unique ID of the participant to add to the group String
  • Only ParticipantChatId is specified
  • Only ParticipantPhone is specified

Response

Parameter Description The data type of the parameter
GroupId Unique ID of the group String
IsSuccess Flag for adding a participant to the group Boolean
StatusMessage Status of adding a participant to the group String

Example

using System;

using ChatApi.Core.Connect;
using ChatApi.Core.Connect.Interfaces;
using ChatApi.Core.Response.Interfaces;

using ChatApi.WA.Dialogs;
using ChatApi.WA.Dialogs.Operations.Interfaces;

using ChatApi.WA.Dialogs.Requests;
using ChatApi.WA.Dialogs.Requests.Interfaces;
using ChatApi.WA.Dialogs.Responses.Interfaces;

using ChatApiClient.Properties;
namespace ChatApiClient
{
    internal class Program
    {
        internal static IWhatsAppConnect Connect { get; set; }

        internal static void Main()
        {
            // put your chat-api's data
            Connect = new WhatsAppConnect(WhatsApp_Server, WhatsApp_Instance, WhatsApp_Token); 
            IDialogOperations operation = new DialogOperations(Connect);
            IGroupOperations groupOperations = operation.GroupOperations.Value;
            IGroupParticipantOperations participantOperations = groupOperations.GroupParticipantOperations.Value;
            
            IDemoteGroupParticipantRequest request = new DemoteGroupParticipantRequest
            {
                ParticipantPhone = "+7(999) 111-11-11"// or ParticipantChatId = "79991111111@c.us"
            };

            var chatApiResponse = participantOperations.DemoteParticipant(request);
            if (!chatApiResponse.IsSuccess) throw chatApiResponse.Exception!;

            var response = chatApiResponse.GetResult();
            Console.WriteLine(response?.PrintMembers());
        }
    }
}