Skip to content

Commit 7acbd43

Browse files
committed
Removed credit related methods
Removed any methods involving credits
1 parent 157ea45 commit 7acbd43

File tree

7 files changed

+1
-485
lines changed

7 files changed

+1
-485
lines changed

src/__tests__/index.js

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,7 @@ exports.defineAutoTests = function() {
6666
expect(window.Branch.userCompletedAction).toBeDefined();
6767
expect(_typeof(window.Branch.userCompletedAction)).toBe("function");
6868
});
69-
it("should contain a method called loadRewards()", function() {
70-
expect(window.Branch.loadRewards).toBeDefined();
71-
expect(_typeof(window.Branch.loadRewards)).toBe("function");
72-
});
73-
it("should contain a method called redeemRewards()", function() {
74-
expect(window.Branch.redeemRewards).toBeDefined();
75-
expect(_typeof(window.Branch.redeemRewards)).toBe("function");
76-
});
77-
it("should contain a method called creditHistory()", function() {
78-
expect(window.Branch.creditHistory).toBeDefined();
79-
expect(_typeof(window.Branch.creditHistory)).toBe("function");
80-
});
69+
8170
});
8271

8372
describe("Branch.getLatestReferringParams()", function() {
@@ -219,80 +208,4 @@ exports.defineAutoTests = function() {
219208
10000
220209
);
221210
});
222-
223-
describe("Branch.loadRewards()", function() {
224-
beforeEach(function(done) {
225-
initSession().then(function() {
226-
done();
227-
});
228-
}, 3000);
229-
it(
230-
"should return an object response",
231-
function(done) {
232-
window.Branch.loadRewards().then(
233-
function(res) {
234-
expect(
235-
typeof res === "undefined" ? "undefined" : _typeof(res)
236-
).toBe("number");
237-
done();
238-
},
239-
function(err) {
240-
expect(
241-
typeof err === "undefined" ? "undefined" : _typeof(err)
242-
).toBe("string");
243-
done();
244-
}
245-
);
246-
},
247-
10000
248-
);
249-
});
250-
251-
describe("Branch.redeemRewards()", function() {
252-
beforeEach(function(done) {
253-
initSession().then(function() {
254-
done();
255-
});
256-
}, 3000);
257-
it(
258-
"should return an object/string error response",
259-
function(done) {
260-
window.Branch.redeemRewards(100).then(
261-
function(res) {
262-
expect(
263-
typeof res === "undefined" ? "undefined" : _typeof(res)
264-
).toBe("object");
265-
done();
266-
},
267-
function(err) {
268-
expect(
269-
typeof err === "undefined" ? "undefined" : _typeof(err)
270-
).toBe("string");
271-
done();
272-
}
273-
);
274-
},
275-
10000
276-
);
277-
});
278-
279-
describe("Branch.creditHistory()", function() {
280-
beforeEach(function(done) {
281-
initSession().then(function() {
282-
done();
283-
});
284-
}, 3000);
285-
it(
286-
"should return the credit balance",
287-
function(done) {
288-
window.Branch.creditHistory().then(function(res) {
289-
expect(typeof res === "undefined" ? "undefined" : _typeof(res)).toBe(
290-
"object"
291-
);
292-
done();
293-
});
294-
},
295-
10000
296-
);
297-
});
298211
};

src/android/io/branch/BranchSDK.java

Lines changed: 0 additions & 227 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
170170
} else if (action.equals("logout")) {
171171
cordova.getActivity().runOnUiThread(r);
172172
return true;
173-
} else if (action.equals("loadRewards")) {
174-
cordova.getActivity().runOnUiThread(r);
175-
return true;
176-
} else if (action.equals("redeemRewards")) {
177-
if (args.length() < 1 && args.length() > 2) {
178-
callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
179-
return false;
180-
}
181-
cordova.getActivity().runOnUiThread(r);
182-
return true;
183-
} else if (action.equals("getCreditHistory")) {
184-
cordova.getActivity().runOnUiThread(r);
185-
return true;
186173
} else if (action.equals("createBranchUniversalObject")) {
187174
if (args.length() != 1) {
188175
callbackContext.error(String.format("Parameter mismatched. 1 is required but %d is given", args.length()));
@@ -305,64 +292,6 @@ private void logout(CallbackContext callbackContext) {
305292

306293
}
307294

308-
/**
309-
* <p>Redeems the specified number of credits from the "default" bucket, if there are sufficient
310-
* credits within it. If the number to redeem exceeds the number available in the bucket, all of
311-
* the available credits will be redeemed instead.</p>
312-
*
313-
* @param value An {@link Integer} specifying the number of credits to attempt to redeem from
314-
* the bucket.
315-
* @param callbackContext A callback to execute at the end of this method
316-
*/
317-
private void redeemRewards(final int value, CallbackContext callbackContext) {
318-
319-
this.instance.redeemRewards(value, new RedeemRewardsListener(callbackContext));
320-
321-
}
322-
323-
/**
324-
* <p>Redeems the specified number of credits from the "default" bucket, if there are sufficient
325-
* credits within it. If the number to redeem exceeds the number available in the bucket, all of
326-
* the available credits will be redeemed instead.</p>
327-
*
328-
* @param value An {@link Integer} specifying the number of credits to attempt to redeem from
329-
* the bucket.
330-
* @param bucket The name of the bucket to remove the credits from.
331-
* @param callbackContext A callback to execute at the end of this method
332-
*/
333-
private void redeemRewards(int value, String bucket, CallbackContext callbackContext) {
334-
335-
this.instance.redeemRewards(bucket, value, new RedeemRewardsListener(callbackContext));
336-
337-
}
338-
339-
/**
340-
* <p>Retrieves rewards for the current session, with a callback to perform a predefined
341-
* action following successful report of state change. You'll then need to call getCredits
342-
* in the callback to update the credit totals in your UX.</p>
343-
*
344-
* @param callbackContext A callback to execute at the end of this method
345-
* @param bucket Load reward of a specific bucket
346-
*/
347-
private void loadRewards(String bucket, CallbackContext callbackContext) {
348-
349-
this.instance.loadRewards(new LoadRewardsListener(bucket, callbackContext, this.instance));
350-
351-
}
352-
353-
/**
354-
* <p>Retrieves rewards for the current session, with a callback to perform a predefined
355-
* action following successful report of state change. You'll then need to call getCredits
356-
* in the callback to update the credit totals in your UX.</p>
357-
*
358-
* @param callbackContext A callback to execute at the end of this method
359-
*/
360-
private void loadRewards(CallbackContext callbackContext) {
361-
362-
this.instance.loadRewards(new LoadRewardsListener(callbackContext, this.instance));
363-
364-
}
365-
366295
/**
367296
* <p>Returns the parameters associated with the link that referred the session. If a user
368297
* clicks a link, and then opens the app, initSession will return the paramters of the link
@@ -852,18 +781,6 @@ public void sendBranchEvent(String eventName, JSONObject metaData, CallbackConte
852781
//callbackContext.success();
853782
}
854783

855-
/**
856-
* <p>Gets the credit history of the specified bucket and triggers a callback to handle the
857-
* response.</p>
858-
*
859-
* @param callbackContext A callback to execute at the end of this method
860-
*/
861-
private void getCreditHistory(CallbackContext callbackContext) {
862-
863-
this.instance.getCreditHistory(new CreditHistoryListener(callbackContext));
864-
865-
}
866-
867784
/**
868785
* @access protected
869786
* @class BranchUniversalObjectWrapper
@@ -1097,78 +1014,6 @@ public void onRegisterViewFinished(boolean registered, BranchError error) {
10971014
}
10981015
}
10991016

1100-
protected class LoadRewardsListener implements Branch.BranchReferralStateChangedListener {
1101-
private CallbackContext _callbackContext;
1102-
private Branch _instance;
1103-
private String _bucket;
1104-
1105-
public LoadRewardsListener(String bucket, CallbackContext callbackContext, Branch instance) {
1106-
this._callbackContext = callbackContext;
1107-
this._instance = instance;
1108-
this._bucket = bucket;
1109-
}
1110-
1111-
public LoadRewardsListener(CallbackContext callbackContext, Branch instance) {
1112-
this._callbackContext = callbackContext;
1113-
this._instance = instance;
1114-
this._bucket = "";
1115-
}
1116-
1117-
// Listener that implements BranchReferralStateChangedListener for loadRewards
1118-
@Override
1119-
public void onStateChanged(boolean changed, BranchError error) {
1120-
if (error == null) {
1121-
1122-
int credits = 0;
1123-
1124-
if (this._bucket.length() > 0) {
1125-
credits = this._instance.getCreditsForBucket(this._bucket);
1126-
} else {
1127-
credits = this._instance.getCredits();
1128-
}
1129-
1130-
this._callbackContext.success(credits);
1131-
1132-
} else {
1133-
1134-
String errorMessage = error.getMessage();
1135-
1136-
Log.d(LCAT, errorMessage);
1137-
1138-
this._callbackContext.error(errorMessage);
1139-
1140-
}
1141-
1142-
}
1143-
}
1144-
1145-
protected class RedeemRewardsListener implements Branch.BranchReferralStateChangedListener {
1146-
private CallbackContext _callbackContext;
1147-
1148-
// Constructor that takes in a required callbackContext object
1149-
public RedeemRewardsListener(CallbackContext callbackContext) {
1150-
this._callbackContext = callbackContext;
1151-
}
1152-
1153-
// Listener that implements BranchReferralStateChangedListener for redeemRewards
1154-
@Override
1155-
public void onStateChanged(boolean changed, BranchError error) {
1156-
1157-
if (error == null) {
1158-
1159-
this._callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, /* send boolean: is changed */ changed));
1160-
1161-
} else {
1162-
1163-
String errorMessage = error.getMessage();
1164-
1165-
Log.d(LCAT, errorMessage);
1166-
1167-
this._callbackContext.error(errorMessage);
1168-
}
1169-
}
1170-
}
1171-
11721017
protected class GenerateShortUrlListener implements Branch.BranchLinkCreateListener {
11731018
private CallbackContext _callbackContext;
11741019

@@ -1342,64 +1187,6 @@ public void onChannelSelected(String channelName) {
13421187
}
13431188
}
13441189

1345-
protected class CreditHistoryListener implements Branch.BranchListResponseListener {
1346-
private CallbackContext _callbackContext;
1347-
1348-
// Constructor that takes in a required callbackContext object
1349-
public CreditHistoryListener(CallbackContext callbackContext) {
1350-
this._callbackContext = callbackContext;
1351-
}
1352-
1353-
// Listener that implements BranchListResponseListener for getCreditHistory()
1354-
@Override
1355-
public void onReceivingResponse(JSONArray list, BranchError error) {
1356-
1357-
ArrayList<String> errors = new ArrayList<String>();
1358-
1359-
if (error == null) {
1360-
1361-
JSONArray data = new JSONArray();
1362-
1363-
if (list != null) {
1364-
1365-
for (int i = 0, limit = list.length(); i < limit; ++i) {
1366-
1367-
JSONObject entry;
1368-
1369-
try {
1370-
entry = list.getJSONObject(i);
1371-
data.put(entry);
1372-
} catch (JSONException e) {
1373-
e.printStackTrace();
1374-
errors.add(e.getMessage());
1375-
}
1376-
1377-
}
1378-
1379-
}
1380-
1381-
if (errors.size() > 0) {
1382-
StringBuilder sb = new StringBuilder();
1383-
for (String s : errors) {
1384-
sb.append(s);
1385-
sb.append("\n");
1386-
}
1387-
this._callbackContext.error(sb.toString());
1388-
} else {
1389-
this._callbackContext.success(data);
1390-
}
1391-
} else {
1392-
1393-
String errorMessage = error.getMessage();
1394-
1395-
Log.d(LCAT, errorMessage);
1396-
1397-
this._callbackContext.error(errorMessage);
1398-
1399-
}
1400-
}
1401-
}
1402-
14031190
protected class RunnableThread implements Runnable {
14041191

14051192
private String action;
@@ -1449,20 +1236,6 @@ public void run() {
14491236
getLatestReferringParams(this.callbackContext);
14501237
} else if (this.action.equals("logout")) {
14511238
logout(this.callbackContext);
1452-
} else if (this.action.equals("loadRewards")) {
1453-
if (this.args.length() == 1) {
1454-
loadRewards(this.args.getString(0), this.callbackContext);
1455-
} else {
1456-
loadRewards(this.callbackContext);
1457-
}
1458-
} else if (this.action.equals("redeemRewards")) {
1459-
if (this.args.length() == 1) {
1460-
redeemRewards(this.args.getInt(0), this.callbackContext);
1461-
} else if (this.args.length() == 2) {
1462-
redeemRewards(this.args.getInt(0), this.args.getString(1), this.callbackContext);
1463-
}
1464-
} else if (this.action.equals("getCreditHistory")) {
1465-
getCreditHistory(this.callbackContext);
14661239
} else if (this.action.equals("createBranchUniversalObject")) {
14671240
createBranchUniversalObject(this.args.getJSONObject(0), this.callbackContext);
14681241
} else if (this.action.equals("crossPlatformIds")) {

0 commit comments

Comments
 (0)