api docs update

This commit is contained in:
John Woodlock
2012-05-28 15:02:39 +10:00
parent 74a94a09bc
commit ff4b011824
3 changed files with 128 additions and 355 deletions
+126 -353
View File
@@ -3174,76 +3174,35 @@ No Request Body
<a id="roles_list" name="roles_list" class="old-syle-anchor">&nbsp;</a> <a id="roles_list" name="roles_list" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
<h4>Retrieve list of roles</h4> <h4>List Roles</h4>
<p>Returns all roles.</p> <p>Example Requests: </p>
<p>Example Request: <a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles?pretty=true">https://localhost:8443/mifosng-provider/api/v1/roles?pretty=true</a>
<a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles">https://localhost:8443/mifosng-provider/api/v1/roles</a> <br><br>
</p> <a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles?pretty=true&fields=name">https://localhost:8443/mifosng-provider/api/v1/roles?pretty=true&fields=name</a>
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration">GET https://thedomainname/api/v1/roles</code> <code class="method-declaration">GET https://thedomainname/api/v1/roles</code>
<code class="method-request">GET https://localhost:8443/mifosng-provider/api/v1/roles</code> <code class="method-response">[ {
<code class="method-response"> "id" : 1,
{ "name" : "Super user",
"roles": [ "description" : "This role provides all application permissions."
{ }, {
"id": 1, "id" : 2,
"orgId": 1, "name" : "Field officer",
"name": "Super user", "description" : "A field officer role allows the user to add client and loans and view reports but nothing else."
"description": "This role provides all application permissions.", }, {
"availablePermissions": [], "id" : 3,
"selectedPermissions": [] "name" : "Data Entry (Portfolio only)",
}, "description" : "This role allows a user full permissions around client and loan functionality but nothing else."
{ }, {
"id": 2, "id" : 4,
"orgId": 1, "name" : "Credit Committe Member",
"name": "Field officer", "description" : "This role allows a user to approve reject or withdraw loans (with reporting)."
"description": "A field officer role allows the user to add client and loans and view reports but nothing else.", }, {
"availablePermissions": [], "id" : 5,
"selectedPermissions": [] "name" : "Manager",
}, "description" : "This role allows a manager to do anything related to portfolio management and also view all reports."
{ } ]
"id": 3,
"orgId": 1,
"name": "Data Entry (Portfolio only)",
"description": "This role allows a user full permissions around client and loan functionality but nothing else.",
"availablePermissions": [],
"selectedPermissions": []
},
{
"id": 4,
"orgId": 1,
"name": "Credit Committe Member",
"description": "This role allows a user to approve reject or withdraw loans (with reporting).",
"availablePermissions": [],
"selectedPermissions": []
},
{
"id": 5,
"orgId": 1,
"name": "Manager",
"description": "This role allows a manager to do anything related to portfolio management and also view all reports.",
"availablePermissions": [],
"selectedPermissions": []
},
{
"id": 6,
"orgId": 1,
"name": "new role test",
"description": "test new role description...",
"availablePermissions": [],
"selectedPermissions": []
},
{
"id": 7,
"orgId": 1,
"name": "new",
"description": "test",
"availablePermissions": [],
"selectedPermissions": []
}
]
}
</code> </code>
</div> </div>
</div> </div>
@@ -3251,50 +3210,38 @@ No Request Body
<a id="roles_template" name="roles_template" class="old-syle-anchor">&nbsp;</a> <a id="roles_template" name="roles_template" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
<h4>Retrieve new role template details</h4> <h4>Retrieve Role Details Template</h4>
<p>Returns details for new role screen</p> <p>This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:
<p>Example Request: <ul>
<a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles/template">https://localhost:8443/mifosng-provider/api/v1/roles/template</a> <li class=normalli>Field Defaults</li>
</p> <li class=normalli>Allowed Value Lists</li>
</ul>
</p>
<p>Example Request: </p>
<a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles/template?pretty=true">https://localhost:8443/mifosng-provider/api/v1/roles/template?pretty=true</a>
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration">GET https://thedomainname/api/v1/roles/template</code> <code class="method-declaration">GET https://thedomainname/api/v1/roles/template</code>
<code class="method-request">GET https://localhost:8443/mifosng-provider/api/v1/roles/template</code> <code class="method-response">{
<code class="method-response"> "availablePermissions" : [ {
{ "id" : 1,
"id": null, "name" : "User administration ALL",
"orgId": null, "description" : "An application user will have permission to execute all tasks related to user administration.",
"name": null, "code" : "USER_ADMINISTRATION_SUPER_USER_ROLE",
"description": null, "groupType" : 1
"availablePermissions": [ }, {
{ "id" : 2,
"id": 1, "name" : "Organisation adminsitration ALL",
"orgId": 1, "description" : "An application user will have permission to execute all tasks related to organisation administration.",
"name": "User administration ALL", "code" : "ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE",
"description": "An application user will have permission to execute all tasks related to user administration.", "groupType" : 2
"code": "USER_ADMINISTRATION_SUPER_USER_ROLE", }, {
"groupType": 1 "id" : 3,
}, "name" : "Portfolio management ALL",
{ "description" : "An application user will have permission to execute all tasks related to portfolio management.",
"id": 2, "code" : "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE",
"orgId": 1, "groupType" : 3
"name": "Organisation adminsitration ALL", }...]
"description": "An application user will have permission to execute all tasks related to organisation administration.",
"code": "ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE",
"groupType": 2
},
...
...
{
"id": 20,
"orgId": 1,
"name": "Can add a new client.",
"description": "Allows an application user to add a new client.",
"code": "CAN_ENROLL_NEW_CLIENT_ROLE",
"groupType": 3
}
],
"selectedPermissions": []
} }
</code> </code>
</div> </div>
@@ -3303,69 +3250,45 @@ No Request Body
<a id="roles_retrieve" name="roles_retrieve" class="old-syle-anchor">&nbsp;</a> <a id="roles_retrieve" name="roles_retrieve" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
<h4>Retrieve existing role details</h4> <h4>Retrieve a Role</h4>
<p>Returns details for existing application role</p> <p>Example Requests: </p>
<p>Example Request: <a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles/1?pretty=true">https://localhost:8443/mifosng-provider/api/v1/roles/1?pretty=true</a>
<a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles/1">https://localhost:8443/mifosng-provider/api/v1/roles/1</a> <br><br>
</p> <a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles/1?pretty=true&template=true">https://localhost:8443/mifosng-provider/api/v1/roles/1?pretty=true&template=true</a>
<br><br>
<a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/roles/1?pretty=true&fields=name,selectedPermissions">https://localhost:8443/mifosng-provider/api/v1/roles/1?pretty=true&fields=name,selectedPermissions</a>
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration">GET https://thedomainname/api/v1/roles/1</code> <code class="method-declaration">GET https://thedomainname/api/v1/roles/{roleId}</code>
<code class="method-request">GET https://localhost:8443/mifosng-provider/api/v1/roles/1</code> <code class="method-response">{
<code class="method-response"> "id" : 1,
{ "name" : "Super user",
"id": 1, "description" : "This role provides all application permissions.",
"orgId": 1, "selectedPermissions" : [ {
"name": "Super user", "id" : 1,
"description": "This role provides all application permissions.", "name" : "User administration ALL",
"availablePermissions": [ "description" : "An application user will have permission to execute all tasks related to user administration.",
{ "code" : "USER_ADMINISTRATION_SUPER_USER_ROLE",
"id": 5, "groupType" : 1
"orgId": 1, }, {
"name": "Can submit new loan application", "id" : 4,
"description": "Allows an application user to sumit new loan application.", "name" : "Reporting ALL",
"code": "CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE", "description" : "An application user will have permission to execute and view all reports.",
"groupType": 3 "code" : "REPORTING_SUPER_USER_ROLE",
}, "groupType" : 4
... }, {
... "id" : 3,
{ "name" : "Portfolio management ALL",
"id": 19, "description" : "An application user will have permission to execute all tasks related to portfolio management.",
"orgId": 1, "code" : "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE",
"name": "Can enter a repayment against a loan in the past", "groupType" : 3
"description": "Allows an application user to enter a repayment on the loan where the repayment date is in the past.", }, {
"code": "CAN_MAKE_LOAN_REPAYMENT_IN_THE_PAST_ROLE", "id" : 2,
"groupType": 3 "name" : "Organisation adminsitration ALL",
}, "description" : "An application user will have permission to execute all tasks related to organisation administration.",
{ "code" : "ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE",
"id": 20, "groupType" : 2
"orgId": 1, } ]
"name": "Can add a new client.",
"description": "Allows an application user to add a new client.",
"code": "CAN_ENROLL_NEW_CLIENT_ROLE",
"groupType": 3
}
],
"selectedPermissions": [
{
"id": 1,
"orgId": 1,
"name": "User administration ALL",
"description": "An application user will have permission to execute all tasks related to user administration.",
"code": "USER_ADMINISTRATION_SUPER_USER_ROLE",
"groupType": 1
},
...
...
{
"id": 2,
"orgId": 1,
"name": "Organisation adminsitration ALL",
"description": "An application user will have permission to execute all tasks related to organisation administration.",
"code": "ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE",
"groupType": 2
}
]
} }
</code> </code>
</div> </div>
@@ -3374,18 +3297,17 @@ No Request Body
<a id="roles_create" name="roles_create" class="old-syle-anchor">&nbsp;</a> <a id="roles_create" name="roles_create" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
<h4>Create new role</h4> <h4>Create a New Role</h4>
<p>Adds new application role to the platform.</p>
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration">POST https://thedomainname/api/v1/roles</code> <code class="method-declaration">POST https://thedomainname/api/v1/roles</code>
<code class="method-request">POST https://localhost:8443/mifosng-provider/api/v1/roles <code class="method-request">POST https://localhost:8443/mifosng-provider/api/v1/roles
Content-Type: application/json Content-Type: application/json
Request body: Request body:
{ {
"name": "Some role name", "name": "Another Role Name",
"description": "A description outlining the purpose of this role in relation to the application.", "description": "A description outlining the purpose of this role in relation to the application.",
"selectedItems": ["1", "2", "3"] "permissions": ["1", "2", "3"]
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
@@ -3398,18 +3320,16 @@ Request body:
<a id="roles_update" name="roles_update" class="old-syle-anchor">&nbsp;</a> <a id="roles_update" name="roles_update" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
<h4>Update existing role</h4> <h4>Update a Role</h4>
<p>Update details of an existing application role.</p>
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration">PUT https://thedomainname/api/v1/roles/8</code> <code class="method-declaration">PUT https://thedomainname/api/v1/roles/{roleId}</code>
<code class="method-request">PUT https://localhost:8443/mifosng-provider/api/v1/roles/8 <code class="method-request">PUT https://localhost:8443/mifosng-provider/api/v1/roles/8
Content-Type: application/json Content-Type: application/json
Request body: Request body:
{ {
"name": "Some role name update", "name": "Updated Role Name",
"description": "A description outlining the purpose of this role in relation to the application. [updated]", "permissions": ["1"]
"selectedItems": ["1", "2", "3", "4", "5"]
} }
</code> </code>
<code class="method-response">{ <code class="method-response">{
@@ -3432,180 +3352,33 @@ Request body:
<a id="permissions_list" name="permissions_list" class="old-syle-anchor">&nbsp;</a> <a id="permissions_list" name="permissions_list" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
<h4>Retrieve list of permissions</h4> <h4>List Application Permissions</h4>
<p>Returns all permissions.</p> <p>Example Requests: </p>
<p>Example Request: <a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/permissions?pretty=true">https://localhost:8443/mifosng-provider/api/v1/permissions?pretty=true</a>
<a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/permissions">https://localhost:8443/mifosng-provider/api/v1/permissions</a> <br><br>
</p> <a style="word-wrap: break-word;" href="https://localhost:8443/mifosng-provider/api/v1/permissions?pretty=true&fields=id,code">https://localhost:8443/mifosng-provider/api/v1/permissions?pretty=true&fields=id,code</a>
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration">GET https://thedomainname/api/v1/permissions</code> <code class="method-declaration">GET https://thedomainname/api/v1/permissions</code>
<code class="method-request">GET https://localhost:8443/mifosng-provider/api/v1/permissions</code> <code class="method-response">[ {
<code class="method-response"> "id" : 1,
{ "name" : "User administration ALL",
"permissions": [ "description" : "An application user will have permission to execute all tasks related to user administration.",
{ "code" : "USER_ADMINISTRATION_SUPER_USER_ROLE",
"id": 1, "groupType" : 1
"orgId": 1, }, {
"name": "User administration ALL", "id" : 2,
"description": "An application user will have permission to execute all tasks related to user administration.", "name" : "Organisation adminsitration ALL",
"code": "USER_ADMINISTRATION_SUPER_USER_ROLE", "description" : "An application user will have permission to execute all tasks related to organisation administration.",
"groupType": 1 "code" : "ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE",
}, "groupType" : 2
{ }, {
"id": 2, "id" : 3,
"orgId": 1, "name" : "Portfolio management ALL",
"name": "Organisation adminsitration ALL", "description" : "An application user will have permission to execute all tasks related to portfolio management.",
"description": "An application user will have permission to execute all tasks related to organisation administration.", "code" : "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE",
"code": "ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE", "groupType" : 3
"groupType": 2 }...]
},
{
"id": 3,
"orgId": 1,
"name": "Portfolio management ALL",
"description": "An application user will have permission to execute all tasks related to portfolio management.",
"code": "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE",
"groupType": 3
},
{
"id": 4,
"orgId": 1,
"name": "Reporting ALL",
"description": "An application user will have permission to execute and view all reports.",
"code": "REPORTING_SUPER_USER_ROLE",
"groupType": 4
},
{
"id": 5,
"orgId": 1,
"name": "Can submit new loan application",
"description": "Allows an application user to sumit new loan application.",
"code": "CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE",
"groupType": 3
},
{
"id": 6,
"orgId": 1,
"name": "Can submit historic loan application",
"description": "Allows an application user to sumit new loan application where the submitted on date is in the past.",
"code": "CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE",
"groupType": 3
},
{
"id": 7,
"orgId": 1,
"name": "Can approve loan application",
"description": "Allows an application user to approve a loan application.",
"code": "CAN_APPROVE_LOAN_ROLE",
"groupType": 3
},
{
"id": 8,
"orgId": 1,
"name": "Can approve loan application in the past",
"description": "Allows an application user to approve a loan application where the approval date is in the past.",
"code": "CAN_APPROVE_LOAN_IN_THE_PAST_ROLE",
"groupType": 3
},
{
"id": 9,
"orgId": 1,
"name": "Can reject loan application",
"description": "Allows an application user to reject a loan application.",
"code": "CAN_REJECT_LOAN_ROLE",
"groupType": 3
},
{
"id": 10,
"orgId": 1,
"name": "Can reject loan application in the past",
"description": "Allows an application user to reject a loan application where the rejected date is in the past.",
"code": "CAN_REJECT_LOAN_IN_THE_PAST_ROLE",
"groupType": 3
},
{
"id": 11,
"orgId": 1,
"name": "Can withdraw loan application",
"description": "Allows an application user to mark loan application as withdrawn by client.",
"code": "CAN_WITHDRAW_LOAN_ROLE",
"groupType": 3
},
{
"id": 12,
"orgId": 1,
"name": "Can withdraw loan application in the past",
"description": "Allows an application user to mark loan application as withdrawn by client where the withdran on date is in the past.",
"code": "CAN_WITHDRAW_LOAN_IN_THE_PAST_ROLE",
"groupType": 3
},
{
"id": 13,
"orgId": 1,
"name": "Can delete submitted loan application",
"description": "Allows an application user to complete delete the loan application if it is submitted but not approved.",
"code": "CAN_DELETE_LOAN_THAT_IS_SUBMITTED_AND_NOT_APPROVED",
"groupType": 3
},
{
"id": 14,
"orgId": 1,
"name": "Can undo loan approval",
"description": "Allows an application user to undo a loan approval.",
"code": "CAN_UNDO_LOAN_APPROVAL_ROLE",
"groupType": 3
},
{
"id": 15,
"orgId": 1,
"name": "Can disburse loan",
"description": "Allows an application user to disburse a loan application.",
"code": "CAN_DISBURSE_LOAN_ROLE",
"groupType": 3
},
{
"id": 16,
"orgId": 1,
"name": "Can disburse loan in the past",
"description": "Allows an application user to disburse a loan where the disbursement date is in the past.",
"code": "CAN_DISBURSE_LOAN_IN_THE_PAST_ROLE",
"groupType": 3
},
{
"id": 17,
"orgId": 1,
"name": "Can undo loan disbursal",
"description": "Allows an application user to undo a loan disbursal if not payments already made.",
"code": "CAN_UNDO_LOAN_DISBURSAL_ROLE",
"groupType": 3
},
{
"id": 18,
"orgId": 1,
"name": "Can enter a repayment against a loan",
"description": "Allows an application user to enter a repayment on the loan.",
"code": "CAN_MAKE_LOAN_REPAYMENT_LOAN_ROLE",
"groupType": 3
},
{
"id": 19,
"orgId": 1,
"name": "Can enter a repayment against a loan in the past",
"description": "Allows an application user to enter a repayment on the loan where the repayment date is in the past.",
"code": "CAN_MAKE_LOAN_REPAYMENT_IN_THE_PAST_ROLE",
"groupType": 3
},
{
"id": 20,
"orgId": 1,
"name": "Can add a new client.",
"description": "Allows an application user to add a new client.",
"code": "CAN_ENROLL_NEW_CLIENT_ROLE",
"groupType": 3
}
]
}
</code> </code>
</div> </div>
</div> </div>
@@ -33,7 +33,7 @@ public class PermissionReadPlatformServiceImpl implements PermissionReadPlatform
AppUser currentUser = context.authenticatedUser(); AppUser currentUser = context.authenticatedUser();
PermissionMapper mapper = new PermissionMapper(); PermissionMapper mapper = new PermissionMapper();
String sql = "select " + mapper.schema() + " where p.org_id = ?"; String sql = "select " + mapper.schema() + " where p.org_id = ? order by p.id";
return this.jdbcTemplate.query(sql, mapper, new Object[] { currentUser return this.jdbcTemplate.query(sql, mapper, new Object[] { currentUser
.getOrganisation().getId() }); .getOrganisation().getId() });
@@ -65,7 +65,7 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
} }
public String schema() { public String schema() {
return " r.id as id, r.org_id as orgId, r.name as name, r.description as description from admin_role r "; return " r.id as id, r.org_id as orgId, r.name as name, r.description as description from admin_role r order by r.id";
} }
} }
} }