diff --git a/src/main/java/Splitwise.java b/src/main/java/Splitwise.java
index 83e786d..48ff16d 100644
--- a/src/main/java/Splitwise.java
+++ b/src/main/java/Splitwise.java
@@ -86,9 +86,11 @@ public String getUser(String userId) throws Exception {
/**
* Update the parameters of the current user.
* @param id splitwise id of the user
- * @param details details to be updated (http://dev.splitwise.com/?javascript#update_user-id)
+ * @param details details to be updated
* @return JSON response string from splitwise
* @throws Exception
+ * @see Splitwise API
+ * documentation for required and optional parameters
*/
public String updateUser(String id, Map details) throws Exception {
String url = String.format(URL.UPDATE_USER_WITH_ID, id);
@@ -126,9 +128,11 @@ public String getGroup(String id) throws Exception {
/**
* Creates a splitwise group.
- * @param details details of the group (http://dev.splitwise.com/?javascript#create_group)
+ * @param details details of the group
* @return JSON response from splitwise
* @throws Exception
+ * @see Splitwise API
+ * documentation for required and optional parameters
*/
public String createGroup(Map details) throws Exception {
Response response = this.util.makeRequest(URL.CREATE_GROUP_URL, Verb.POST, details);
@@ -153,9 +157,11 @@ public String deleteGroup(String id) throws Exception {
/**
* Add user to a splitwise group.
- * @param userDetails details of the user to be added (http://dev.splitwise.com/?javascript#add_user_to_group)
+ * @param userDetails details of the user to be added
* @return JSON response from splitwise
* @throws Exception
+ * @see Splitwise API
+ * documentation for required and optional parameters
*/
public String addUserToGroup(Map userDetails) throws Exception {
Response response = this.util.makeRequest(URL.ADD_USER_TO_GROUP, Verb.POST, userDetails);
@@ -173,8 +179,8 @@ public String addUserToGroup(Map userDetails) throws Exception {
*/
public String removeUserFromGroup(final String groupId, final String userId) throws Exception {
Map details = new HashMap(){{
- put(Strings.USER_ID, userId);
- put(Strings.GROUP_ID, groupId);
+ put(Strings.USER_ID, userId);
+ put(Strings.GROUP_ID, groupId);
}};
Response response = this.util.makeRequest(URL.REMOVE_USER_FROM_GROUP, Verb.POST, details);
if (response.getCode() == 200)
@@ -256,6 +262,21 @@ public String getComments(String expenseId) throws Exception {
return null;
}
+ /**
+ * Creates a splitwise expense.
+ * @param details details of the expense
+ * @return JSON response from splitwise
+ * @throws Exception
+ * @see Splitwise API
+ * documentation for required and optional parameters
+ */
+ public String createExpense(Map details) throws Exception {
+ Response response = this.util.makeRequest(URL.CREATE_EXPENSE, Verb.POST, details);
+ if (response.getCode() == 200)
+ return response.getBody();
+ return null;
+ }
+
/**
* Get all expenses for the current user.
* @return JSON string containing user expenses
diff --git a/src/main/java/constants/URL.java b/src/main/java/constants/URL.java
index c41112f..67a01d1 100644
--- a/src/main/java/constants/URL.java
+++ b/src/main/java/constants/URL.java
@@ -27,6 +27,7 @@ public class URL {
public static final String DELETE_FRIEND_WITH_ID = BASE_URL + "/delete_friend/%s";
//URLs for Expenses API
+ public static final String CREATE_EXPENSE = BASE_URL + "/create_expense";
public static final String GET_EXPENSES = BASE_URL + "/get_expenses";
public static final String GET_EXPENSE_WITH_ID = BASE_URL + "/get_expense/%s";
public static final String DELETE_EXPENSE_WITH_ID = BASE_URL + "/delete_expense/%s";