Skip to content

Commit 20027db

Browse files
authored
Merge pull request #73 from Iterable/feature/MOB-141-add-updateEmail-callbacks
[MOB-141] Add updateEmail method with success & failure callbacks
2 parents 7f71bbb + a8e737a commit 20027db

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

iterableapi/src/main/java/com/iterable/iterableapi/IterableApi.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,17 @@ public void sendPush(String email, int campaignId, Date sendAt, JSONObject dataF
701701
* @param newEmail New email
702702
*/
703703
public void updateEmail(final String newEmail) {
704+
updateEmail(newEmail, null, null);
705+
}
706+
707+
/**
708+
* Updates the current user's email.
709+
* Also updates the current email in this IterableAPI instance if the API call was successful.
710+
* @param newEmail New email
711+
* @param successHandler Success handler. Called when the server returns a success code.
712+
* @param failureHandler Failure handler. Called when the server call failed.
713+
*/
714+
public void updateEmail(final String newEmail, final IterableHelper.SuccessHandler successHandler, IterableHelper.FailureHandler failureHandler) {
704715
if (_email != null) {
705716
JSONObject requestJSON = new JSONObject();
706717

@@ -713,8 +724,11 @@ public void updateEmail(final String newEmail) {
713724
public void onSuccess(JSONObject data) {
714725
_email = newEmail;
715726
storeEmailAndUserId();
727+
if (successHandler != null) {
728+
successHandler.onSuccess(data);
729+
}
716730
}
717-
}, null);
731+
}, failureHandler);
718732
}
719733
catch (JSONException e) {
720734
e.printStackTrace();

0 commit comments

Comments
 (0)