box / box-salesforce-sdk

This is the Salesforce SDK for integrating with the Box Platform.
https://developer.box.com/guides/tooling/sdks/salesforce/
Apache License 2.0
58 stars 51 forks source link

BoxApiRequest.checkContextForCallout() method does nothing #48

Open Feldhacker opened 5 years ago

Feldhacker commented 5 years ago

The current checkContextForCallout() method looks like this:

private void checkContextForCallout() {
   if (Limits.getLimitCallouts() < 1) {
      throw new BoxApiRequestException('BoxApiRequest unable to make a callout due to no remaining callouts allowed (Limits.getLimitCallouts() == 0).');
   }
}

However, getLimitCallouts() returns the per transaction callout limit -- so, 100 is always returned. If the intent is to make sure that the number of callouts made so far hasn't hit the limit, then the method should probably be:

private void checkContextForCallout() {
   if (Limits.getLimitCallouts() <= Limits.getCallouts()) {
      throw new BoxApiRequestException('BoxApiRequest unable to make a callout due to no remaining callouts allowed.');
   }
}