Module: Whatsapp::Concerns::GroupMethods

Included in:
AccountProxy, Session
Defined in:
lib/whatsapp/concerns/group_methods.rb

Overview

Shared group management methods.

The includer must define a private +whatsapp_client+ method returning a Whatsapp::Client instance.

Instance Method Summary collapse

Instance Method Details

#add_group_participants(group_id, participants:) ⇒ Hash

Add participants to a group.

Parameters:

  • group_id (String)

    group JID

  • participants (Array<String>)

    phone numbers or JIDs

Returns:

  • (Hash)


47
48
49
# File 'lib/whatsapp/concerns/group_methods.rb', line 47

def add_group_participants(group_id, participants:)
  whatsapp_client.add_group_participants(group_id, participants: participants)
end

#create_group(subject:, participants:) ⇒ Group

Create a new group.

Parameters:

  • subject (String)

    group name

  • participants (Array<String>)

    phone numbers or JIDs

Returns:



28
29
30
# File 'lib/whatsapp/concerns/group_methods.rb', line 28

def create_group(subject:, participants:)
  whatsapp_client.create_group(subject: subject, participants: participants)
end

#group(group_id) ⇒ Group

Get detailed info about a group.

Parameters:

  • group_id (String)

    group JID

Returns:



19
20
21
# File 'lib/whatsapp/concerns/group_methods.rb', line 19

def group(group_id)
  whatsapp_client.group(group_id)
end

#groupsArray<Group>

List all groups the account participates in.

Returns:



11
12
13
# File 'lib/whatsapp/concerns/group_methods.rb', line 11

def groups
  whatsapp_client.groups
end

#remove_group_participants(group_id, participants:) ⇒ Hash

Remove participants from a group.

Parameters:

  • group_id (String)

    group JID

  • participants (Array<String>)

    phone numbers or JIDs

Returns:

  • (Hash)


56
57
58
# File 'lib/whatsapp/concerns/group_methods.rb', line 56

def remove_group_participants(group_id, participants:)
  whatsapp_client.remove_group_participants(group_id, participants: participants)
end

#update_group(group_id, subject: nil, description: nil) ⇒ Hash

Update a group's subject and/or description.

Parameters:

  • group_id (String)

    group JID

  • subject (String, nil) (defaults to: nil)

    new subject

  • description (String, nil) (defaults to: nil)

    new description

Returns:

  • (Hash)


38
39
40
# File 'lib/whatsapp/concerns/group_methods.rb', line 38

def update_group(group_id, subject: nil, description: nil)
  whatsapp_client.update_group(group_id, subject: subject, description: description)
end