RCNConfigContent.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. typedef NS_ENUM(NSInteger, RCNDBSource) {
  18. RCNDBSourceActive,
  19. RCNDBSourceDefault,
  20. RCNDBSourceFetched,
  21. };
  22. @class RCNConfigDBManager;
  23. /// This class handles all the config content that is fetched from the server, cached in local
  24. /// config or persisted in database.
  25. @interface RCNConfigContent : NSObject
  26. /// Shared Singleton Instance
  27. + (instancetype)sharedInstance;
  28. /// Fetched config (aka pending config) data that is latest data from server that might or might
  29. /// not be applied.
  30. @property(nonatomic, readonly, copy) NSDictionary *fetchedConfig;
  31. /// Active config that is available to external users;
  32. @property(nonatomic, readonly, copy) NSDictionary *activeConfig;
  33. /// Local default config that is provided by external users;
  34. @property(nonatomic, readonly, copy) NSDictionary *defaultConfig;
  35. - (instancetype)init NS_UNAVAILABLE;
  36. /// Designated initializer;
  37. - (instancetype)initWithDBManager:(RCNConfigDBManager *)DBManager NS_DESIGNATED_INITIALIZER;
  38. /// Returns true if initialization succeeded.
  39. - (BOOL)initializationSuccessful;
  40. /// Update config content from fetch response in JSON format.
  41. - (void)updateConfigContentWithResponse:(NSDictionary *)response
  42. forNamespace:(NSString *)FIRNamespace;
  43. /// Copy from a given dictionary to one of the data source.
  44. /// @param fromDictionary The data to copy from.
  45. /// @param source The data source to copy to(pending/active/default).
  46. - (void)copyFromDictionary:(NSDictionary *)fromDictionary
  47. toSource:(RCNDBSource)source
  48. forNamespace:(NSString *)FIRNamespace;
  49. /// Sets the fetched Personalization metadata to active.
  50. - (void)activatePersonalization;
  51. /// Gets the active config and Personalization metadata.
  52. - (NSDictionary *)getConfigAndMetadataForNamespace:(NSString *)FIRNamespace;
  53. @end