-
Notifications
You must be signed in to change notification settings - Fork 0
/
RBDatabase.h
57 lines (40 loc) · 2.23 KB
/
RBDatabase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// RBDatabase.h
// RadBlock
//
// Created by Mike Pulaski on 23/10/2019.
// Copyright © 2019 Young Dynasty. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "RBAllowlistEntry.h"
#import "RBDateRange.h"
#import "RBStat.h"
NS_ASSUME_NONNULL_BEGIN
#if TARGET_OS_OSX
extern NSNotificationName RBDatabaseDidAddEntryNotification;
extern NSNotificationName RBDatabaseDidUpdateEntryNotification;
extern NSNotificationName RBDatabaseDidRemoveEntryNotification;
extern NSString *const RBAllowlistEntryDomainKey;
extern NSString *const RBDatabaseLocalModificationKey;
#endif
NS_SWIFT_NAME(RadBlockDatabase)
@interface RBDatabase : NSObject <NSCopying>
@property(class,readonly) RBDatabase *sharedDatabase;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithFileURL:(NSURL *)fileURL NS_DESIGNATED_INITIALIZER;
@property(nonatomic,readonly) NSURL *fileURL;
#pragma mark - allowList
- (void)allowlistEntryForDomain:(NSString *)domain completionHandler:(void(^)(RBAllowlistEntry *__nullable, NSError *__nullable))completionHandler;
- (void)writeAllowlistEntryForDomain:(NSString *)domain usingBlock:(nullable void(^)(RBMutableAllowlistEntry*, BOOL*))block completionHandler:(void(^)(RBAllowlistEntry *__nullable, NSError *__nullable))completionHandler;
- (void)removeAllowlistEntryForDomain:(NSString *)domain completionHandler:(void(^)(NSError *__nullable))completionHandler;
- (void)removeAllowlistEntriesForDomains:(NSArray *)domains completionHandler:(void(^)(NSError *__nullable))completionHandler;
typedef NS_ENUM(short, RBAllowlistEntrySortOrder) {
RBAllowlistEntrySortOrderDomain,
RBAllowlistEntrySortOrderCreateDate
};
- (void)allowlistEntryEnumeratorForGroup:(nullable NSString *)group domain:(nullable NSString *)domain sortOrder:(RBAllowlistEntrySortOrder)sortOrder completionHandler:(void(^)(NSEnumerator <RBAllowlistEntry*>*__nullable, NSError*__nullable))completionHandler;
#pragma mark - Stats
- (void)incrementStatWithName:(NSString *)name by:(NSUInteger)delta completionHandler:(nullable void(^)(NSError *__nullable))completionHandler;
- (void)getStatsInDateRange:(RBDateRange *)dateRange completionHandler:(void(^)(NSArray<RBStat *> *__nullable, NSError *__nullable))completionHandler;
@end
NS_ASSUME_NONNULL_END