fineract-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Geiß <markus.ge...@live.de>
Subject RE: Chained Command and Batch API
Date Wed, 20 Apr 2016 05:37:27 GMT
Hey Terence,

according to the API documentation the following actions can be batched:

- Create a new Client
- Update an existing Client
- Apply a Loan to a Client
- Apply Savings to a Client
- Add a new Loan Charge
- Collect an existing Loan Charge
- Activate a Pending Client
- Approve a Pending Loan
- Disburse a Loan

Data tables are currently not supported, and would need to be implemented.

Best,

Markus

.::YAGNI likes a DRY KISS::.


----------------------------------------
> Date: Tue, 19 Apr 2016 16:34:32 +0530
> Subject: Chained Command and Batch API
> From: terence@sanjosesolutions.in
> To: dev@fineract.incubator.apache.org
>
> Hi Devs,
>
> While building the offline app, we have a need to run multiple commands
> because of the way Mifos separates out data into core entities and
> datatables. Let's say I have a datatable for client called Client_Fields
> with optional fields Email, Occupation, Country, City, StreetAddr, PIN. If
> I create a client while offline with the usual fields: firstname, lastname,
> dateOfBirth and so on and I also can enter the Email, Occupation, Country,
> City, StreetAddr and PIN and these need to go into the Client_Fields
> datatable, in online mode its as simple as:
>
> *1. Create Client Request*
> method: POST,
> url: baseUrl + "/clients",
> body: {
> firstname: "John",
> lastname: "Wayne",
> dateOfBirth: "1978-05-12",
> officeId: 4,
> ....
> }
>
> Response:
> {
> "officeId": 4,
> "resourceId": 12,
> "clientId": 12
> }
>
> 2. Create Client_Fields record
> method: POST
> url: baseUrl + "/datatables/Client_Fields/12",
> body: {
> Country: "India",
> City: "Kolkata",
> ...
> }
>
> Now, if I have to do the same set of operations offline, I don't have
> connectivity to server for long periods and I need to save the additional
> fields and take a client photo in the same offline session, storing the
> state on the device and executing the cached commands when I come back
> online. The challenge is that I don't have the client id till the client
> was created and hence it's difficult to execute dependent operations like
> uploading a photo or creating a datatable record which needs the client id.
> While investigating this, I found the batch API and explored it, but am
> stuck while trying to create datatables. Here's a sample request and
> response for client create and datatable record create:
>
> [
> {
> requestId: 1,
> relativeUrl: "clients",
> method: "POST",
> body: "{ officeId: 4, firstname: 'John', lastname: 'Wayne' }"
> },
> {
> requestId: 2,
> relativeUrl: "datatables/Client_Fields/$.clientId/",
> method: "POST",
> reference: 1,
> body: "{ Country: 'India', City: 'Kolkata' }"
> }
> ]
>
> The response to the first is a 200 but the second yields a 501 Resource
> datatables/Client_Fields/216 does not exist. However if I POST the same
> content manually to the same generated URL datatables/Client_Fields/216,
> I'm able to successfully create the datatable record. Is datatables
> supported in the Batch API and this the expected behaviour for this kind of
> input or should I report a Jira issue if I want this feature?
>
> As an extension of the same requirement, lets say I wanted to upload a
> photo and I have the base64 photo in a string in my application. Can I
> substitute the request above with this:
>
> {
> requestId: 2,
> relativeUrl: "client/$.clientId/images",
> method: "POST",
> reference: 1,
> body: "...."
> }
>
> Is this supported and would it work?
>
> --
> Best Regards,
> Terence Monteiro
> ​,​
> www.sanjosesolutions.in
 		 	   		  
Mime
View raw message