MambuPy.rest.mambugroup

Mambu Groups objects.

MambuGroup holds a group.

MambuGroups holds a list of groups.

Uses mambugeturl.getgroupurl as default urlfunc

Classes

MambuGroup([urlfunc, entid])

A Group from Mambu.

MambuGroups([urlfunc, entid])

A list of Groups from Mambu.

class MambuPy.rest.mambugroup.MambuGroup(urlfunc=<function getgroupurl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A Group from Mambu.

With the default urlfunc, entid argument must be the ID of the group you wish to retrieve.

__init__(urlfunc=<function getgroupurl>, entid='', *args, **kwargs)[source]

Tasks done here:

Just initializes the MambuStruct.

__module__ = 'MambuPy.rest.mambugroup'
_notUpdateData()[source]

Data that would not be updated/overwritten in case of POST

Dictionary with group data copied

addMembers(newMembers=[], *args, **kwargs)[source]

Adds a list of members to the group

Parameters:

newMembers (list) – list with encoded keys of the members to add to group

create(data, *args, **kwargs)[source]

Creates a group in Mambu

Parameters -data dictionary with data to send

preprocess()[source]

Preprocessing.

Flattens the object. Important data comes on the ‘theGroup’ dictionary inside of the response. Instead, every element of the ‘theGroup’ dictionary is taken out to the main attrs dictionary.

Notes on the group get some html tags removed.

Todo

use mambuutil.strip_tags() method

A ‘name’ field is added, equivalent to the ‘groupName’ field. This is useful on loan accounts. They get a ‘holder’ field added somewhere, which may be an individual client, or a group. So to get the holder name, you just access the ‘holder’[‘name’]. No matter if you have a client loan or a group loan, you get the name of the holder.

setActivities(*args, **kwargs)[source]

Adds the activities for this group to a ‘activities’ field.

Activities are MambuActivity objects.

Activities get sorted by activity timestamp.

Returns the number of requests done to Mambu.

setBranch(*args, **kwargs)[source]

Adds the branch to which this groups belongs

setCentre(*args, **kwargs)[source]

Adds the centre to which this groups belongs

setClients(*args, **kwargs)[source]

Adds the clients for this group to a ‘clients’ field.

The ‘groupMembers’ field of the group holds the encodedKeys of the member clients of the group. Since Mambu REST API accepts both ids or encodedKeys to retrieve entities, we use that here.

You may wish to get the full details of each client by passing a fullDetails=True argument here.

Returns the number of requests done to Mambu.

update(data, *args, **kwargs)[source]

Updates a group in Mambu

Uses PATCH and POST methods, for update “groupMembers”, “groupRoles” and “group fields” PATCH method is used, for “customInformation” also Patch is used but url needs to be changed, in order to update “addresses” POST method is needed.

https://support.mambu.com/docs/groups-api#post-group https://support.mambu.com/docs/groups-api#patch-group-information https://support.mambu.com/docs/groups-api#patch-group-custom-field-values

Parameters -data dictionary with data to update

update_patch(data, *args, **kwargs)[source]

Updates a group Mambu using method PATCH

Parameters:

data (dictionary) – dictionary with data to update

https://support.mambu.com/docs/groups-api#patch-group-information

update_post(data, *args, **kwargs)[source]

Updates a group in Mambu using method POST

Parameters:

data (dictionary) – dictionary with data to update

https://support.mambu.com/docs/groups-api#post-group

class MambuPy.rest.mambugroup.MambuGroups(urlfunc=<function getgroupurl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A list of Groups from Mambu.

With the default urlfunc, entid argument must be empty at instantiation time to retrieve all the groups according to any other filter you send to the urlfunc.

__init__(urlfunc=<function getgroupurl>, entid='', *args, **kwargs)[source]

By default, entid argument is empty. That makes perfect sense: you want several groups, not just one

__iter__()[source]
__module__ = 'MambuPy.rest.mambugroup'
convert_dict_to_attrs(*args, **kwargs)[source]

The trick for iterable Mambu Objects comes here:

You iterate over each element of the responded List from Mambu, and create a Mambu Group object for each one, initializing them one at a time, and changing the attrs attribute (which just holds a list of plain dictionaries) with a MambuGroup just created.

Todo

pass a valid (perhaps default) urlfunc, and its corresponding id to entid to each MambuGroup, telling MambuStruct not to connect() by default. It’s desirable to connect at any other further moment to refresh some element in the list.