MambuPy.api.connector.rest
Connectors to Mambu.
Currently supports REST.
Classes
|
A connector for Mambu REST API |
- class MambuPy.api.connector.rest.MambuConnectorREST(user='mambu_api_user', pwd='mambu_api_password', url='domain.mambu.com', **kwargs)[source]
Bases:
MambuConnector
,MambuConnectorReader
,MambuConnectorWriter
A connector for Mambu REST API
- _RETRIES = 5
- __abstractmethods__ = frozenset({})
- __init__(user='mambu_api_user', pwd='mambu_api_password', url='domain.mambu.com', **kwargs)[source]
- __list_request(method, url, params=None, data=None)
Request for a list, appending responses with limit and offset.
Makes several requests adjusting limits and offsets, appending responses, just as if you have made a single request with a big response.
Useful for services where you have a Maximum limit of response elements but wish to make a single call as if doing a single request (but not, you make as many as necessary until covering the given limit).
- __list_request_args(params)
- __list_request_cat_response(list_resp, resp)
- __module__ = 'MambuPy.api.connector.rest'
- __request(method, url, params=None, data=None, content_type=None)
requests an url.
- Parameters:
- Returns:
response content (json)
- Raises:
MambuError – in case of 400 or 500 response codes
- __request_data(data)
- __request_headers(method, content_type)
- __request_params(params)
- __validate_filter_criteria(filterCriteria)
Validate search filter criteria
- Parameters:
filterCriteria (list of dicts) – filter criteria
- Returns:
validated_filterCriteria (list of dicts) – validated filter criteria
- Raises:
MambuPyError (obj) – when invalid filterCriteria
- __validate_query_params(**kwargs)
Validate query params
- Parameters:
**kwargs (dict) – query params
- Returns:
params (dict) – validated params for a query
- __validate_sorting_criteria(sortingCriteria)
Validate search sorting criteria
- Parameters:
sortingCriteria (dict) – sorting criteria
- Returns:
sortingCriteria (dict) – validated sorting criteria
- Raises:
MambuPyError (obj) – when invalid sortingCriteria
- _abc_impl = <_abc_data object>
- _headers = {}
- _tenant = ''
- mambu_delete_document(documentId)[source]
deletes an attachment by its documentId
- Parameters:
documentId (str) – the id or encodedkey of the document to be deleted
- mambu_get(entid, prefix, detailsLevel='BASIC')[source]
get, a single entity, identified by its entid.
- mambu_get_all(prefix, filters=None, offset=None, limit=None, paginationDetails='OFF', detailsLevel='BASIC', sortBy=None, **kwargs)[source]
get_all, several entities, filtering allowed
- Parameters:
prefix (str) – entity’s URL prefix
filters (dict) – key-value filters (depends on each entity)
offset (int) – pagination, index to start searching
limit (int) – pagination, number of elements to retrieve
paginationDetails (str ON/OFF) – ask for details on pagination
detailsLevel (str BASIC/FULL) – ask for extra details or not
sortBy (str) –
field1:ASC,field2:DESC
, sorting criteria for resultskwargs (dict) – extra parameters that a specific entity may receive in its get_all method
- Returns:
response content (str json [])
- mambu_get_comments(owner_id, owner_type, offset=None, limit=None, paginationDetails='OFF')[source]
Retrieves the comments of entity with owner_id.
- mambu_get_customfield(customfieldid)[source]
Retrieves a Custom Field.
- Parameters:
customfieldid (str) – the id or encoded key of the custom field
- mambu_get_documents_metadata(entid, owner_type, offset=None, limit=None, paginationDetails='OFF')[source]
Gets metadata for all the documents attached to an entity
- Parameters:
- mambu_loanaccount_getSchedule(loanid)[source]
Retrieves the installments schedule of a loan account
- Parameters:
loanid (str) – the id or encoded key of the loan account
- mambu_make_disbursement(loan_id, notes, firstRepaymentDate, valueDate, allowed_fields, **kwargs)[source]
Make a disbursement transacton on a loan account.
- Parameters:
loan_id (str) – loan account id to disburse
firstRepaymentDate (str) – first repayment date in ISO format
notes (str) – notes for the disbursement transaction
valueDate (str) – entrydate for disbursement transaction in ISO format
allowed_fields (list) – extra fields allowed for the transaction
kwargs (dict) – key-values of extra fields for the transaction
- mambu_make_repayment(loan_id, amount, notes, valueDate, allowed_fields, **kwargs)[source]
Make a repayment transaction on a loan account.
- Parameters:
loan_id (str) – loan account id to make a repayment
amount (float) – the amount of the repayment
notes (str) – notes for the repayment transaction
valueDate (str) – date for the repayment transaction in ISO format
allowed_fields (list) – extra fields allowed for the transaction
kwargs (dict) – key-values of extra fields for the transaction
- mambu_patch(entid, prefix, fields_ops=None)[source]
patches certain parts of a mambu entity
https://api.mambu.com/?python#tocspatchoperation
Supported: add, remove, replace (move not yet supported)
- Parameters:
entid (str) – the id or encoded key of the entity
prefix (str) – entity’s URL prefix
fields_ops (list of tuples) – each tuple has: OP (str): operation (“ADD”, “REPLACE”, “REMOVE”) PATH (str): json pointer referencing the location in the target entity VALUE (obj, opc): the value of the field (not for REMOVE op)
- mambu_search(prefix, filterCriteria=None, sortingCriteria=None, offset=None, limit=None, paginationDetails='OFF', detailsLevel='BASIC')[source]
search, several entities, filtering criteria allowed
- Parameters:
prefix (str) – entity’s URL prefix
filterCriteria (list of dicts) – fields according to LoanAccountFilterCriteria schema
sortingCriteria (dict) – fields according to LoanAccountSortingCriteria
offset (int) – pagination, index to start searching
limit (int) – pagination, number of elements to retrieve
paginationDetails (str ON/OFF) – ask for details on pagination
detailsLevel (str BASIC/FULL) – ask for extra details or not
- Returns:
response content (str json [])
- mambu_upload_document(owner_type, entid, filename, name, notes)[source]
uploads an attachment to this entity
- Parameters:
owner_type (str) – the type of the owner of the document
entid (str) – the id or encoded key of the entity owning the document
filename (str) – path and filename of file to upload as attachment
name (str) – name to assign to the attached file in Mambu
notes (str) – notes to associate to the attached file in Mambu
- Returns:
response content (str json {}) metadata of the attached document