Skip to content

Commit

Permalink
[CHORE] Added optional string parameter 'bucket' for redeemRewards me…
Browse files Browse the repository at this point in the history
…thod. [Android]
  • Loading branch information
renesansz committed Feb 28, 2016
1 parent 77776e3 commit 2aa8e28
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
25 changes: 23 additions & 2 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
this.loadRewards();
return true;
} else if (action.equals("redeemRewards")) {
this.redeemRewards(args.getInt(0));
if (args.length() == 1) {
this.redeemRewards(args.getInt(0));
} else if (args.length() == 2) {
this.redeemRewards(args.getInt(0), args.getString(1));
}
return true;
} else if (action.equals("getCreditHistory")) {
this.getCreditHistory();
Expand Down Expand Up @@ -200,7 +204,7 @@ private void logout()
* @param count A {@link Integer} specifying the number of credits to attempt to redeem from
* the bucket.
*/
private void redeemRewards(int value)
private void redeemRewards(final int value)
{

Log.d(LCAT, "start redeemRewards()");
Expand All @@ -209,6 +213,23 @@ private void redeemRewards(int value)

}

/**
* <p>Redeems the specified number of credits from the "default" bucket, if there are sufficient
* credits within it. If the number to redeem exceeds the number available in the bucket, all of
* the available credits will be redeemed instead.</p>
*
* @param count A {@link Integer} specifying the number of credits to attempt to redeem from
* the bucket.
*/
private void redeemRewards(int value, String bucket)
{

Log.d(LCAT, "start redeemRewards()");

this.instance.redeemRewards(bucket, value, new LoadRewardsListener());

}

/**
* <p>Retrieves rewards for the current session, with a callback to perform a predefined
* action following successful report of state change. You'll then need to call getCredits
Expand Down
13 changes: 10 additions & 3 deletions www/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,20 @@ Branch.prototype.loadRewards = function () {
/**
* Redeem rewards to your account.
*
* @param (Int) value - The amount to redeem
* @param (Int) value - The amount to redeem.
* @param (String) bucket - The value containing the name of the referral bucket to attempt to redeem credits from. [OPTIONAL]
*
* @return (Promise)
*/
Branch.prototype.redeemRewards = function (value) {
Branch.prototype.redeemRewards = function (value, bucket) {

return execute('redeemRewards', [value]);
var params = [value];

if (bucket) {
params.push(bucket);
}

return execute('redeemRewards', params);

};

Expand Down

0 comments on commit 2aa8e28

Please sign in to comment.