MambuPy.rest.mambuclient

Mambu Clients objects.

MambuClient holds a client.

MambuClients holds a list of clients.

Uses mambugeturl.getclienturl as default urlfunc

Classes

MambuClient([urlfunc, entid])

A Client from Mambu.

MambuClients([urlfunc, entid])

A list of Clients from Mambu.

class MambuPy.rest.mambuclient.MambuClient(urlfunc=<function getclienturl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A Client from Mambu.

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

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

Tasks done here:

Just initializes the MambuStruct.

__module__ = 'MambuPy.rest.mambuclient'
create(data, *args, **kwargs)[source]

Create a client in Mambu

Parameters -data dictionary with data to send

postprocess()[source]

Postprocessing.

Just in case some elements on the addresses was converted to anything but string, it gets converted back to only string (unicode). Things on addresses are not useful but by what they say, not what they are.

Todo

do the same thing to the ‘address’ field created on preprocessing.

preprocess()[source]

Preprocessing.

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

Removes repeated chars from firstName, middleName and lastName fields. Adds a firstLastName and secondLastName fields for clients using more than one last name.

Adds a ‘name’ field joining all names in to one string. IMHO Mambu does an awful job with names. Besides, 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.

Creates and ‘address’ field that holds the very first address on the addresses field, to ease the use of the perhaps-current-or-most-important address of the client.

Creates a field for each documentId type with the value of the documentId, to ease the use of docuemnt IDs. That way if you have a document Id named ‘CURP’, then you access it directly via the ‘CURP’ field, instead of going all the way through the idDocuments field.

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

Adds the branch to which the client belongs.

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

Adds the groups to which this client belongs.

The ‘groupKeys’ field of the client holds a list of the encodedKeys of the groups to which this client belongs.

Returns the number of requests done to Mambu.

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

Updates a client in Mambu

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

https://support.mambu.com/docs/clients-api#post-clients https://support.mambu.com/docs/clients-api#patch-client https://support.mambu.com/docs/clients-api#patch-client-custom-field-values

Parameters -data dictionary with data to update

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

Updates a client Mambu using method PATCH

Parameters:

data (dictionary) – dictionary with data to update

https://support.mambu.com/docs/clients-api#patch-client

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

Updates a client in Mambu using method POST

Parameters:

data (dictionary) – dictionary with data to update

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

class MambuPy.rest.mambuclient.MambuClients(urlfunc=<function getclienturl>, entid='', *args, **kwargs)[source]

Bases: MambuStruct

A list of Clients from Mambu.

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

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

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

__iter__()[source]
__module__ = 'MambuPy.rest.mambuclient'
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 Client 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 MambuClient just created.

Todo

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