class RateLimiterClient {

  public Single<Boolean> isRateLimited(RateLimit limit) {
    return getRateLimits()
        .switchIfEmpty(Maybe.just(RateLimitProto.RateLimit.getDefaultInstance()))
        .map(storedLimits -> storedLimits.getLimitsOrDefault(limit.limiterKey(), newCounter()))
        .filter(counter -> isLimitExpired(counter, limit) || counter.getValue() < limit.limit())
        .isEmpty();
  }

  @Inject  RateLimiterClient(
      @com.google.firebase.inappmessaging.internal.injection.qualifiers.RateLimit
          ProtoStorageClient storageClient,
      Clock clock);

}