checkScopes static method

List<String> checkScopes(
  1. List<String> scopes
)

Raise an exception if scopes are not included in allowedScopes

Implementation

static List<String> checkScopes(List<String> scopes) {
  const allowedScopes = <String>{
    "direct_debit",
    "cashback",
    "get_balance",
    "quick_pay",
    "continuous_payments",
    "merchant_topup",
    "pending_payments",
    "user_notification",
    "user_topup",
    "user_profile",
    "preauth_capture_native",
    "preauth_capture_transaction",
    "push_notification",
    "notification_center_ob",
    "notification_center_ab",
    "notification_center_tl"
  };
  if (!allowedScopes.containsAll(scopes)) {
    final scopeset = scopes.toSet();
    final diff = scopeset.difference(allowedScopes.intersection(scopeset));
    throw Exception('Invalid Scope found. [${diff.toString()}]');
  }
  return scopes;
}