### Install MambuPy using pip Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This command installs the core MambuPy library using the pip package manager. It's the standard way to get started with MambuPy. ```bash pip install MambuPy ``` -------------------------------- ### Install MambuPy using uv Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This command demonstrates how to install MambuPy using the `uv` package manager, an alternative to pip. ```bash uv pip install MambuPy ``` -------------------------------- ### Working with MambuClient: Get and access client properties Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This Python example shows how to retrieve a Mambu client by ID or encodedKey using `MambuClient.get()`. It demonstrates accessing client properties using both dot notation and dictionary-style indexing, and how to retrieve full details including custom fields. ```python from mambupy.api.mambuclient import MambuClient # Get a specific client by ID client = MambuClient.get("0512N0025") # detailsLevel="BASIC" by default # Read basic client information print(f"Name: {client.firstName} {client.lastName}") print(f"ID: {client.id}") print(f"State: {client.state}") # MambuPy entity properties can also be accessed using dictionary-style interface: print(f"Name: {client['firstName']} {client['lastName']}") print(f"ID: {client['id']}") print(f"State: {client['state']}") # You can get the same entity using its Mambu encodedKey: client = MambuClient.get("8a099a673f1f25a0013f1fd0a1c318a5") # Get all client details, including custom fields: client = MambuClient.get("24N12345", detailsLevel="FULL") print(f"ID: {client.id}") print(f"Addresses: {client.addresses}") # list of MambuAddress VOs print(f"ID Documents: {client.idDocuments}") # list of MambuIDDocument VOs ``` -------------------------------- ### Install MambuPy with development dependencies Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This command installs MambuPy along with various optional dependencies useful for MambuPy development, including dev, devtools, and doc packages. ```bash pip install MambuPy[dev,devtools,doc] ``` -------------------------------- ### Install MambuPy with full features including ORM Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This command installs MambuPy along with optional dependencies for the ORM module, which provides SQLAlchemy mappings for querying Mambu's database dumps. Use this if you need the ORM functionality. ```bash pip install MambuPy[full] ``` -------------------------------- ### Example Mambu Centre GET Request JSON Response Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest_v2.rst Illustrates the typical JSON structure returned when performing a GET request to retrieve a Mambu Centre entity, including examples of custom fields and nested custom field groups. ```JSON { "_Example_Custom_Fields": { "exampleCheckboxField": "TRUE", "exampleFreeTextField": "A free text field up to 255 characters in length", "exampleNumberField": "46290", "exampleSelectField": "Option 1" }, "_centres_custom_field_set": { "centre_cf_1": "string", "cntr_cf_2": "TRUE", "cntr_cf_usr_lnk": "string" }, "_cntr_cf_grp": [ { "cntr_cf_Grp_1": "string", "cntr_cf_grp_2": "option 1", "cntr_cf_slct_2": "dep 1 a" }, { ``` -------------------------------- ### Managing Mambu Groups: Retrieval and Member Access with MambuPy Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This example demonstrates how to interact with Mambu groups using the `MambuGroup` class. It covers retrieving a single group by ID, fetching multiple groups with filters, and accessing detailed group information including members. To retrieve group members, the `detailsLevel` parameter must be set to 'FULL' during instantiation, after which individual client members can be accessed. ```python from mambupy.api.mambuclient import MambuClient from mambupy.api.mambugroup import MambuGroup # Get a specific group by ID group = MambuGroup.get("24G23446") # View group information print(f"Group name: {group.groupName}") print(f"ID: {group.id}") # Get multiple groups with filters groups = MambuGroup.get_all( limit=20, offset=0, filters={ "creditOfficerUsername": "a.alas" } ) for group in groups: print(f"Group: {group.groupName}") print(f"Status: {group.loanCycle}") # To get details like group members, # the group must be instantiated using detailsLevel="FULL" group = MambuGroup.get("25G54321", detailsLevel="FULL") members = group.groupMembers for member in members: # MambuClient instances still need to be instantiated one by one client = MambuClient.get(member.clientKey) print(f"Member {client.id}: {client.firstName} {client.lastName}") ``` -------------------------------- ### Handle Mambu Entity Assignments and Relationships Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This example demonstrates how to access and instantiate assigned entities (branches, centres, users) for Mambu clients, groups, and loans using 'get_assigned*' methods. These methods efficiently retrieve full instances of related entities, improving data access and avoiding manual key lookups. ```python from mambupy.api.mambuclient import MambuClient from mambupy.api.mambugroup import MambuGroup from mambupy.api.mambuloan import MambuLoan # Check client assignments client = MambuClient.get("0512N0025") # Branch print(f"Assigned branch: {client.assignedBranchKey}") # instantiate the branch assigned to the client: client.get_assignedBranch() print(f"Assigned branch: {client.assignedBranch}") # MambuBranch object # Centre print(f"Assigned centre: {client.assignedCentreKey}") # instantiate the centre assigned to the client: client.get_assignedCentre() print(f"Assigned centre: {client.assignedCentre}") # MambuCentre object # NOTE: if an entity doesn't have an assignment level, e.g. user, # MambuPy would raise an exception # Also works with Groups group = MambuGroup.get("24G23446") print(f"Assigned officer: {group.assignedUserKey}") # instantiate the user assigned to the group group.get_assignedUser() print(f"Assigned officer: {group.assignedUser}") # MambuUser object # And also works with Loans loan = MambuLoan.get("54321") print(f"Assigned branch: {loan.assignedBranchKey}") print(f"Assigned centre: {loan.assignedCentreKey}") print(f"Assigned officer: {loan.assignedUserKey}") loan.get_assignedBranch() loan.get_assignedCentre() loan.get_assignedUser() ``` -------------------------------- ### Retrieving Mambu Branches with MambuPy Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This example demonstrates how to interact with Mambu organizational elements, specifically branches, using the `MambuBranch` class. It shows how to retrieve a specific branch by its ID and how to fetch all available branches, printing their names and states. ```python from mambupy.api.mambubranch import MambuBranch # Get a specific branch branch = MambuBranch.get("CCAZ") print(f"Branch: {branch.name}") print(f"State: {branch.state}") # Get all branches branches = MambuBranch.get_all() ``` -------------------------------- ### MambuPy REST API Endpoint Examples with urlfuncs Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This section demonstrates how MambuPy's REST classes, like `MambuLoan`, utilize default `urlfunc` functions to build specific Mambu API endpoints. It shows how the same class can interact with different endpoints (e.g., `/loans/LOAN_ID` vs. `/groups/GROUP_ID/loans`) by changing the `urlfunc` passed to its constructor, allowing flexible API access. ```APIDOC GET /loans/LOAN_ID GET /groups/GROUP_ID/loans ``` -------------------------------- ### Instantiate MambuClient Object in Python Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This code example shows how to create an instance of the MambuClient object using a specific entity ID. This is the third step in the process of retrieving a Mambu entity's details. ```python client = mambuclient.MambuClient(entid="MY_CLIENT_ID") ``` -------------------------------- ### Python Project Dependencies Source: https://github.com/jstitch/mambupy/blob/master/requirements.light.txt Specifies the exact Python packages and their versions that are necessary for the 'jstitch/mambupy' project to function correctly. These dependencies are typically installed via pip. ```Python PyYAML==6.0.1 requests==2.31.0 requests_toolbelt==1.0.0 dateutils==0.6.12 future==0.18.3 ``` -------------------------------- ### Handle MambuError for Non-Existent Client ID Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This example illustrates a MambuError when attempting to retrieve a client that does not exist in the Mambu system. The API responds with a 404 status and a specific error code (301) for 'INVALID_CLIENT_ID', which MambuPy translates into a MambuError. ```python from mambupy.api.mambuclient import MambuClient client = MambuClient.get("I DONT EXIST") ``` ```bash MambuError: 301 (404) - INVALID_CLIENT_ID ``` ```bash 404 Client Error: for url: https://podemos.sandbox.mambu.com/api/clients/NOEXISTO?detailsLevel=BASIC on GET request: params {'detailsLevel': 'BASIC'}, data None, headers [('Accept', 'application/vnd.mambu.v2+json'))] HTTPError, resp content: b'{"errors":[{"errorCode":301,"errorReason":"INVALID_CLIENT_ID"}]}' ``` -------------------------------- ### Handle MambuCommError for Invalid API URL Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This example shows a MambuCommError, which signifies a communication failure with the Mambu API, specifically when the configured API URL is invalid or unresolvable. MambuPy raises this error when it cannot establish a connection to the specified endpoint. ```python mambuconfig.apiurl="BLAHBLAHBLAH" # assuming there's no environment variable or mambupy.rc file with this configuration set client = MambuClient.get("0512N0025") ``` ```bash MambuCommError: Unknown comm error with Mambu: HTTPSConnectionPool(host='BLAHBLAHBLAH', port=443): Max retries exceeded with url: /api/clients/0512N0025?detailsLevel=BASIC (Caused by NameResolutionError(": Failed to resolve 'BLAHBLAHBLAH' ([Errno -2] Name or service not known)")) ``` ```bash HTTPSConnectionPool(host='BLAHBLAHBLAH', port=443): Max retries exceeded with url: /api/clients/0512N0025?detailsLevel=BASIC (Caused by NameResolutionError(": Failed to resolve 'BLAHBLAHBLAH' ([Errno -2] Name or service not known)")) Exception () on GET request: url https://BLAHBLAHBLAH/api/clients/0512N0025, params {'detailsLevel': 'BASIC'}, data None, headers [('Accept', 'application/vnd.mambu.v2+json')] ``` -------------------------------- ### MambuPy Configuration Options API Reference Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst Details the configuration options for MambuPy's REST module, including API credentials and URL. It outlines the various mechanisms for setting these options, such as RC files and environment variables, and their override hierarchy. ```APIDOC MambuPy.mambuconfig: apiurl: Type: string Description: The URL of the Mambu tenant. Configuration Sources: /etc/mambupyrc, $HOME/.mambupy.rc, MAMBUPY_APIRUL environment variable. apiuser: Type: string Description: A Mambu user with API permissions. Configuration Sources: /etc/mambupyrc, $HOME/.mambupy.rc, MAMBUPY_APIUSER environment variable. apipwd: Type: string Description: The password for the Mambu API user. Configuration Sources: /etc/mambupyrc, $HOME/.mambupy.rc, MAMBUPY_APIPWD environment variable. ``` -------------------------------- ### Perform Advanced Searches for Mambu Loans Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This snippet demonstrates how to use the 'search' method to query Mambu loans based on multiple criteria, such as account state and amount. It also highlights the importance of the 'limit' parameter for controlling the number of results and managing memory usage during large data retrievals. ```python from mambupy.api.mambugroup import MambuGroup from mambupy.api.mambuloan import MambuLoan # Search loans by specific criteria loans = MambuLoan.search( filterCriteria=[ {"field": "accountState", "operator": "EQUALS", "value": "ACTIVE_IN_ARREARS"}, {"field": "amount", "operator": "MORE_THAN", "value": 750000} ], limit=20 ) # here we are limiting the maximum results, no matter how many there are in # Mambu, it will only bring 20. You can use this argument along with offset to # paginate on your own. If you omit the limit parameter, MambuPy will handle # this bringing ALL entities that meet the criteria in chunks of # mambuconfig.apipagination, which may delay an excessive time to load, or even # fill your computer's RAM after a while ``` -------------------------------- ### Configure MambuPy using environment variables Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst These environment variables set the Mambu API URL, username, and password. They have the highest configuration priority, overriding any other configuration method. ```bash export MAMBU_API_URL=yourtenant.sandbox.mambu.com export MAMBU_API_USER=yourapiuser export MAMBU_API_PWD=your_secret_password ``` -------------------------------- ### Configure MambuPy using an RC file Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This INI-formatted configuration snippet shows how to set Mambu API credentials in an RC file (e.g., `/etc/mambupy.rc` or `~/.mambupy.rc`). Comments can be included, and values are prioritized based on file location. ```ini [API] apiurl=yourtenant.sandbox.mambu.com apiuser=yourapiuser apipwd=your_secret_password # comments can be included # and there may be more configurations not mentioned here # See mambuconfig documentation for more details ``` -------------------------------- ### Interacting with Mambu Loans: Retrieval, Details, and Financial Data with MambuPy Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This snippet illustrates how to manage loan accounts using `MambuLoan`. It demonstrates retrieving specific loans by ID, fetching multiple loans with various filters, and accessing detailed loan information including automatic data type conversions. Furthermore, it shows how to identify the loan holder (client or group), and how to retrieve and iterate through payment schedules and transaction histories. ```python from mambupy.api.mambuloan import MambuLoan # Get a specific loan by ID loan = MambuLoan.get("54321") # View basic loan information print(f"Loan ID: {loan.id}") print(f"Status: {loan.accountState}") # MambuPy automatically converts data types obtained via REST: print(f"Disbursement date: {loan.disbursementDetails.disbursementDate}") # datetime object print(f"Amount: {loan.loanAmount}") # float # Get multiple loans with filters loans = MambuLoan.get_all( limit=100, offset=0, filters={ "accountState": "ACTIVE_IN_ARREARS", "creditOfficerUsername": "a.alas" } ) for loan in loans: print(f"Loan ID: {loan.id}") print(f"Amount: {loan.loanAmount}") print(f"Status: {loan.accountState}") # Get the loan holder (can be client or group) holder = loan.get_accountHolder() # instantiates a MambuPy entity if loan.accountHolderType == 'GROUP': print(f"Holder (Group) {holder.id}: {holder.groupName}") else: print(f"Holder (Client) {holder.id}: {holder.firstName} {holder.lastName}") # Get payment schedule loan.get_schedule() # loan.schedule property doesn't exist before this installments = loan.schedule for installment in installments: print(f"Installment: {installment.number}") print(f"Status: {installment.state}") print(f"Due date: {installment.dueDate}") print(f"Principal paid: {installment.principal['amount']['paid']}") # Get transactions loan.get_transactions() # loan.transactions property doesn't exist before this transactions = loan.transactions for transaction in transactions: print(f"Transaction: {transaction.id}") print(f"Type: {transaction.type}") print(f"Date: {transaction.valueDate}") print(f"Amount: {transaction.amount}") ``` -------------------------------- ### MambuPy Utility Functions and System Improvements Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Covers general utility function updates and system-wide improvements, including API header management, task URL parameter support, and database backup enhancements. ```APIDOC gettasksurl: - Now supports limit and offset parameters (v1.2.2) mambuutil.backup_db: - Auth parameters were incorrectly set (v1.3.7) - GET call to Mambu needs application/json headers (v1.3.15) - Save file using "wb" mode when backing up Database dump from Mambu (v1.8.7) API Headers: - Accept Headers for all requests, using v1 API Accept Header (v1.7) ``` -------------------------------- ### Retrieve Mambu Users and Roles with MambuPy Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This snippet illustrates how to fetch individual Mambu users by ID with different detail levels, instantiate their roles into MambuRole objects, and retrieve all users belonging to a specific branch. It highlights the importance of the 'limit' parameter for pagination when fetching multiple entities. ```python from mambupy.api.mambuuser import MambuUser # Get a specific user user = MambuUser.get("a.alas", detailsLevel="FULL") print(f"User: {user.firstName} {user.lastName}") print(f"Role: {user.role}") # role doesn't come with detailsLevel "BASIC" # instantiate user's role in a MambuRole entity, # replacing the role property with the instantiated object: user.get_role() print(f"Role: {user.role}") # MambuRole object # Get all users from a specific branch users = MambuUser.get_all( filters={"branchId": "CCAZ"} ) # BEWARE of missing limit parameter! # MambuPy will download by pages according to mambuconfig.apipagination config # but without a limit, it will make as many requests as needed # to exhaust all entities from Mambu ``` -------------------------------- ### MambuPy MambuStruct.connect() Method API Interaction Flow Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This outlines the internal process of the `MambuPy.rest.mambustruct.MambuStruct.connect` method. It details the sequence of operations from determining the HTTP verb and using the appropriate `urlfunc` to making the request, handling Mambu API errors by throwing `MambuError`, and finally preprocessing the successful JSON response. ```APIDOC 1. determine the type of request to do (basically the HTTP verb, which depends on certain data present on the object) 2. using the given urlfunc (which may be the default one for the object), make the corresponding request to Mambu 3. the resulting JSON is then preprocessed: if Mambu gave an error (say for an invalid Mambu ID), a MambuPy.mambuutil.MambuError is thrown 4. if no error was thrown by Mambu, MambuPy.rest.mambustruct.MambuStruct.init is called, which basically executes some custom preprocessing, converts the ``` -------------------------------- ### Manage Mambu Centres with MambuPy Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This code demonstrates how to retrieve specific Mambu Centre units by ID, fetch all available centres, and filter centres by their assigned branch using the MambuCentre class in MambuPy. It showcases both direct retrieval and filtered queries. ```python from mambupy.api.mambucentre import MambuCentre # Get a specific unit centre = MambuCentre.get("TribeAZ-1") print(f"Unit: {centre.name}") print(f"Branch: {centre.assignedBranchKey}") # Get all units centres = MambuCentre.get_all() for centre in centres: print(f"ID: {centre.id}, Name: {centre.name}") # Get units belonging to a specific branch: centres = MambuCentre.get_all( filters={ "branchId": "CCAZ", } ) ``` -------------------------------- ### Accessing Client Custom Fields and Retrieving Clients with MambuPy Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This snippet demonstrates how to access custom fields associated with a Mambu client using MambuPy, showing how the library converts raw custom field data into accessible properties. It also illustrates how to retrieve multiple clients using `get_all` with filters for pagination and `search` for advanced criteria, iterating through the results to display client details. ```python print(f"A custom fields group: {client._customfields_integrante}") # as they come from Mambu print(f"Another custom fields group: {client._datoscrediticios_integrante}") # MambuPy extracts each field, # and converts it to a MambuPy object and sets it as an entity property: print( f"One of the fields from _customfields_integrante group: {client.Actividad_economica_Clients}" ) # MambuEntityCF VO # Get multiple clients with filters clients = MambuClient.get_all( limit=50, # Results limit offset=0, # Page start filters={ "firstName": "JOSEFA", "state": "ACTIVE" } ) for client in clients: print(f"Client {client.id}: {client.firstName} {client.lastName}") # Search clients with advanced search clients = MambuClient.search( filterCriteria=[ {"field": "firstName", "operator": "EQUALS", "value": "JOSEFA"} ] ) ``` -------------------------------- ### Configure MambuPy programmatically Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This Python code demonstrates how to set Mambu API configuration values directly within your application using the `mambuconfig` module. This method is used if environment variables or RC files are not found. ```python from mambupy import mambuconfig # Basic configuration mambuconfig.apiurl = "yourtenant.sandbox.mambu.com" mambuconfig.apiuser = "yourapiuser" mambuconfig.apipwd = "your_secret_password" ``` -------------------------------- ### MambuPy ORM Module Configuration Parameters Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_orm.rst Details the configuration options required for MambuPy's ORM module to establish a read-only connection to a Mambu database backup. These settings can be provided via INI files or environment variables, with environment variables taking precedence. ```APIDOC Configuration Parameters: - dbname: Description: The name of the database holding the Mambu DB backup. Type: string Source: MambuPy.mambuconfig.dbname, MAMBUPY_DBNAME environment variable - dbuser: Description: The username with read permissions to the database. Type: string Source: MambuPy.mambuconfig.dbuser, MAMBUPY_DBUSER environment variable - dbpwd: Description: The password for the database user. Type: string Source: MambuPy.mambuconfig.dbpwd, MAMBUPY_DBPWD environment variable - dbhost: Description: The host address to access the database. Type: string Source: MambuPy.mambuconfig.dbhost, MAMBUPY_DBHOST environment variable - dbport: Description: The port number for connecting to the database host. Type: integer Source: MambuPy.mambuconfig.dbport, MAMBUPY_DBPORT environment variable - dbeng: Description: The database engine to use (MySQL by default). Type: string Source: MambuPy.mambuconfig.dbeng, MAMBUPY_DBENG environment variable ``` -------------------------------- ### MambuPy Entity Base Classes and Interfaces Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest_v2.rst Documents the core MambuPy classes and interfaces that define common and extended functionalities for interacting with Mambu entities via the REST API. Includes base entity operations like get/get_all and specific interfaces for write, search, attachment, and commenting capabilities. ```APIDOC MambuPy.api.entities.MambuEntity: Description: Base class for all Mambu entities, providing common 'get' and 'get_all' operations. Inherits from: MambuPy.api.mambustruct.MambuStruct MambuPy.api.entities.MambuEntityWritable: Description: Interface for entities supporting 'create', 'patch', and 'update' operations. MambuPy.api.entities.MambuEntitySearchable: Description: Interface for entities supporting 'search' operations. MambuPy.api.entities.MambuEntityAttachable: Description: Interface for entities supporting attached documents. MambuPy.api.entities.MambuEntityCommentable: Description: Interface for entities supporting commenting. ``` -------------------------------- ### MambuUser and MambuRoles API Updates Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Outlines changes related to user management, including role assignment, branch setting, and methods for updating user information. ```APIDOC MambuUser: - setRoles() method (v0.8.3) - setBranch() method (v1.8.3) - update() method (v1.8.8) - updatePatch() method (v1.8.8) MambuRoles: - Module implementation (v0.8.3) ``` -------------------------------- ### Python urlfunc Function Signature in MambuPy Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This snippet illustrates the general signature for `getSOMETHINGurl` functions within MambuPy's `mambuutil` module. These functions are responsible for constructing URLs to interact with Mambu's REST API, typically accepting an optional entity ID and keyword arguments for query parameters. ```python def getSOMETHINGurl(idSOMETHING, *args, **kwargs) ``` -------------------------------- ### MambuPy MambuStruct Class API Reference Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst Documents key methods and behaviors of the MambuPy.rest.mambustruct.MambuStruct class, including error handling, custom postprocessing, and automatic pagination for retrieving multiple objects. ```APIDOC MambuPy.rest.mambustruct.MambuStruct: connect(): Description: Connects to Mambu, handles communication errors, and performs automatic pagination. Throws: MambuPy.mambuutil.MambuCommError (if Mambu is down) preprocess(): Description: Method involved in custom postprocessing step 4. postprocess(): Description: Method involved in custom postprocessing step 4. convertDict2Attrs(): Description: Method involved in custom postprocessing step 4. __init__(limit: int): Description: Constructor for MambuStruct. The 'limit' argument controls pagination behavior, allowing users to manage the size of retrieved data. ``` -------------------------------- ### MambuStruct Core Functionality and API Enhancements Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Documents the evolution of the MambuStruct class, detailing new HTTP method support (PATCH, DELETE, POST), improved error handling, constructor behavior, dictionary-like access, and internal data management. ```APIDOC MambuStruct: - Supports PATCH request method (v0.8) - convertDict2Attrs: - constantFields: Added 'email' (v0.8.3) - constantFields: Added 'description' (v1.3.6) - __init__(): - Holds a copy of original args and kwargs for reuse on future connect() calls (v1.2.0) - Bugfix: urlfunc parameter treated almost at the end (v1.3.1) - Tries to initialize the entid property (v1.8.1) - connect(): - Catches requests errors and throws MambuCommError only on those cases; other exceptions re-raised (v1.2.1) - Adds support for DELETE method (v1.3.4) - Supports updating info via PATCH and POST (v1.3.10) - json.loads ValueError now raises MambuError with body content (v1.8.9) - Retries on Mambu 500 errors, throwing MambuCommError on RETRIES limit (v1.8.10) - get() method: Added for dict-like MambuStructs (v1.3.2) - __contains__(): Implemented to allow 'in' operator usage (v1.8) - update() method: Comes from parent class, connects to Mambu to refresh info of updated data in internal structures (v1.7.1) ``` -------------------------------- ### MambuTask Entity and Management API Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Details the introduction and subsequent enhancements to the MambuTask entity and its associated iterable, including methods for closing and creating tasks. ```APIDOC MambuTask: - Entity implementation (v0.8) - close() method (v0.8.3) - create() method (v1.10.0) - close() method bugfix: No 'task' in attrs (v1.10.2) MambuTasks: - Iterable implementation (v0.8) ``` -------------------------------- ### MambuGroup Entity Management API Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Documents the evolution of MambuGroup, including support for address management, creation, update, and member addition functionalities. ```APIDOC MambuGroup: - Supports one address via preprocess (v1.3.9) - Supports creating Group entities in Mambu (v1.3.11) - Supports updating Group entities in Mambu (v1.3.12) - addMembers() method (v1.3.14) - addMembers() method: Updates MambuGroup once members are added (v1.3.14b) ``` -------------------------------- ### MambuPy Core Data Structure Classes Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest_v2.rst Details the foundational classes, MambuMapObj and MambuStruct, that underpin MambuPy v2's data handling. MambuMapObj provides dictionary and object-like access, while MambuStruct handles conversion, serialization, extraction, and update behavior for entity attributes. ```APIDOC MambuPy.api.classes.MambuMapObj: Description: Implements dictionary and object-like behavior for accessing the fundamental data structure (_attrs) of MambuPy v2 entities. MambuPy.api.mambustruct.MambuStruct: Description: Inherits from MambuMapObj, implementing conversion, serialization, extraction, and update behavior over the _attrs dictionary. Inherits from: MambuPy.api.classes.MambuMapObj ``` -------------------------------- ### MambuCentre Branch Management API Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Introduces a new method for the MambuCentre class to retrieve its associated MambuBranch. ```APIDOC MambuCentre: - setBranch() method to get the MambuBranch to which the Centre belongs (v1.9.0) ``` -------------------------------- ### Import MambuClient Module in Python Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This snippet demonstrates the necessary import statement to bring the MambuClient module into your Python script. It is the second step required before instantiating a Mambu entity object. ```python from MambuPy.rest import mambuclient ``` -------------------------------- ### MambuLoan and Related Entities API Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Details enhancements to MambuLoan, including URL functions for custom information, holder settings, and repayment management. ```APIDOC MambuLoan: - URL function for loan accounts' custom information (v1.5) - setHolder(): - getRoles=True instantiates Clients with fullDetails=True (v1.6) - BUGFIX: getClients if-branch was not defaulting mambuclientclass to MambuPy's MambuClient (v1.8.13) - setRepayments(): - BUGFIX: mamburepaymentsclass was not considered (v1.10.4) ``` -------------------------------- ### MambuClient Entity Management API Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Covers updates to the MambuClient entity, specifically its ability to update client information within Mambu. ```APIDOC MambuClient: - Supports updating Client entities in Mambu (v1.3.13) ``` -------------------------------- ### Iterate Mambu Branches Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This snippet demonstrates a basic loop to iterate through a collection of Mambu branch objects and print their ID and name. It assumes 'branches' is an iterable of branch entities previously retrieved. ```python for branch in branches: print(f"ID: {branch.id}, Name: {branch.name}") ``` -------------------------------- ### Mambu REST API Single Entity JSON Response Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This JSON snippet illustrates a typical response from Mambu's REST API when retrieving a single entity like a Client or Loan Account. It demonstrates the nested structure of dictionaries and lists that MambuPy processes. ```JSON { "encodedKey": "abcdef1234567890", "id": "ABC432", "creationDate": "2022-05-03T21:00:00-05:00", "accountState": "ACTIVE", "disbursementDetails": { "encodedKey": "987654321fedcba", "disbursementDate": "2022-05-04T12:00:05-05:00" }, "_list_of_values_in_set_cf": [ { "some_value": "12345.67", "another": "TESTING1" }, { "some_value": "0.0", "another": "TESTING2" } ] } ``` -------------------------------- ### Mambu Centre Object API Schema Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest_v2.rst Defines the comprehensive JSON schema for a Mambu Centre object, including its custom fields (e.g., "cntr_cf_Grp_1"), a list of "addresses", and standard attributes like "assignedBranchKey", "creationDate", "id", "name", and "state". This structure represents the data returned or expected by the Mambu API for Centre entities. ```JSON { "customFields": [ { "cntr_cf_Grp_1": "other string", "cntr_cf_grp_2": "option 2", "cntr_cf_slct_2": "dep 2 b" } ], "addresses": [ { "city": "string", "country": "string", "encodedKey": "string", "indexInList": 0, "latitude": 0, "line1": "string", "line2": "string", "longitude": 0, "parentKey": "string", "postcode": "string", "region": "string" } ], "assignedBranchKey": "string", "creationDate": "2016-09-06T13:37:50+03:00", "encodedKey": "string", "id": "string", "lastModifiedDate": "2016-09-06T13:37:50+03:00", "meetingDay": "string", "name": "string", "notes": "string", "state": "ACTIVE" } ``` -------------------------------- ### MambuPy Direct Python Dictionary Translation Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This Python code demonstrates how MambuPy initially translates the raw JSON response from Mambu's API into a standard Python dictionary. It mirrors the JSON structure, preserving string values for all fields before further type conversion. ```Python d = {"encodedKey": "abcdef1234567890", "id": "ABC432", "creationDate": "2022-05-03T21:00:00-05:00", "accountState": "ACTIVE", "disbursementDetails": { "encodedKey": "987654321fedcba", "disbursementDate": "2022-05-04T12:00:05-05:00" }, "_list_of_values_in_set_cf": [ {"some_value": "12345.67", "another": "TESTING1" }, {"some_value": "0.0", "another": "TESTING2"}]} ``` -------------------------------- ### Mambu Savings Related Entities API Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Introduces support for Mambu Savings related entities within the library. ```APIDOC Mambu Savings: - Add support for related entities (unit test still TODO) (v1.3.5) ``` -------------------------------- ### Handle MambuError for Invalid API Credentials Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This snippet demonstrates a MambuError occurring due to incorrect API credentials. When MambuPy attempts to access the API with invalid authentication, the Mambu API returns a 401 Unauthorized status and error code 2, which is then wrapped as a MambuError. ```python mambuconfig.apipwd="BLAHBLAHBLAH" # assuming there's no environment variable or mambupy.rc file with this configuration set client = MambuClient.get("0512N0025") ``` ```bash MambuError: 2 (401) - INVALID_CREDENTIALS (credentials) ``` ```bash 401 Client Error: for url: https://podemos.sandbox.mambu.com/api/clients/0512N0025?detailsLevel=BASIC on GET request: params {'detailsLevel': 'BASIC'}, data None, headers [('Accept', 'application/vnd.mambu.v2+json')] HTTPError, resp content: b'{"errors":[{"errorCode":2,"errorSource":"credentials","errorReason":"INVALID_CREDENTIALS"}]}' ``` -------------------------------- ### ORM Schema and Entity Property Updates Source: https://github.com/jstitch/mambupy/blob/master/docs/source/CHANGELOG_v1.md Describes additions and modifications to the Object-Relational Mapping (ORM) schema, including new scripts, tables, and custom field definitions. ```APIDOC ORM: - schema_tasks script added (v1.3.0) - Added properties to each Mambu entity to support instantiation of attributes with a default related-entity class, allowing overriding (v1.3.0) - Gets Centre table (v1.4) - LoanAccount: Atribute rescheduledAccountKey was added (v1.8.2) - CustomFieldSet class added (v1.8.3) - CustomFieldSelection class added (v1.8.3) ``` -------------------------------- ### Handle MambuPyError for Invalid Argument Type Source: https://github.com/jstitch/mambupy/blob/master/docs/source/cookbook.rst This snippet demonstrates how MambuPy handles an invalid argument type, specifically when a string is provided for an integer-expected parameter like 'offset'. It results in a MambuPyError, indicating an internal library validation failure. ```python from mambupy.api.mambuclient import MambuClient clients = MambuClient.get_all( limit=10, offset="0" # offset parameter must be an int ) ``` ```bash MambuPyError: offset must be integer ``` -------------------------------- ### MambuPy Automatic Native Type Conversion Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest.rst This Python code snippet demonstrates MambuPy's advanced feature of automatically converting string values from the Mambu API's JSON response into appropriate native Python types, such as `datetime` objects for dates and `float` for numerical values. This conversion simplifies data manipulation for developers. ```Python d = {"encodedKey": "abcdef1234567890", "id": "ABC432", "creationDate": datetime(2022, 5, 3, 21, 0), "accountState": "ACTIVE", "disbursementDetails": { "encodedKey": "987654321fedcba", "disbursementDate": datetime(2022, 5, 4, 12, 0, 5) }, "_list_of_values_in_set_cf": [ {"some_value": 12345.67, "another": "TESTING1" }, {"some_value": 0.0, "another": "TESTING2"}]} ``` -------------------------------- ### Mambu Address Object API Schema Source: https://github.com/jstitch/mambupy/blob/master/docs/source/mambu_rest_v2.rst Illustrates the JSON schema for an Address object, typically found within a list of addresses associated with Mambu entities such as Centres, Branches, Clients, or Groups. This structure defines fields like "city", "country", "line1", "postcode", and geographical coordinates. In MambuPy v2, these are managed as Value Objects. ```JSON { "addresses": [ { "city": "string", "country": "string", "encodedKey": "string", "indexInList": 0, "latitude": 0, "line1": "string", "line2": "string", "longitude": 0, "parentKey": "string", "postcode": "string", "region": "string" } ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.