//
//  HanselConfigsRn.m
//  AwesomeProject
//
//  Created by Rajeev Rajeshuni on 22/10/19.
//  Copyright © 2019 Facebook. All rights reserved.
//

#import "HanselConfigsRn.h"

@implementation HanselConfigsRn

- (void)getString:(NSString* _Nonnull)configName fallbackValue:(NSString* _Nonnull)fallbackValue callback:(RCTResponseSenderBlock)callback {
    @try {
        [HanselRnUtils returnResult:[HanselConfigs getString:configName withDefaultValue:fallbackValue] withCallback:callback];
    } @catch (NSException *exception) {
        NSLog(@"Hansel error: Exception caught in getString method in HanselConfigsRn bridge.");
    }
}

- (void)getDouble:(NSString* _Nonnull)configName fallbackValue:(double)fallbackValue callback:(RCTResponseSenderBlock)callback {
    @try {
        [HanselRnUtils returnResult:[HanselConfigs getDouble:configName withDefaultValue:[NSNumber numberWithDouble:fallbackValue]] withCallback:callback];
    } @catch (NSException *exception) {
        NSLog(@"Hansel error: Exception caught in getDouble method in HanselConfigsRn bridge.");
    }
}

- (void)getBoolean:(NSString* _Nonnull)configName fallbackValue:(BOOL)fallbackValue callback:(RCTResponseSenderBlock)callback {
    @try {
        [HanselRnUtils returnResult:[NSNumber numberWithBool:[HanselConfigs getBool:configName withDefaultValue:fallbackValue]] withCallback:callback];
    } @catch (NSException *exception) {
        NSLog(@"Hansel error: Exception caught in getBool method in HanselConfigsRn bridge.");
    }
}

- (void)getJSONObject:(NSString* _Nonnull)configName defaultValue:(NSDictionary*)defaultValue callback:(RCTResponseSenderBlock)callback {
    @try {
        [HanselRnUtils returnResult:[HanselConfigs getJSON:configName withDefaultValue:defaultValue] withCallback:callback];
    } @catch (NSException *exception) {
        NSLog(@"Hansel error: Exception caught in getJSON method in HanselConfigsRn bridge.");
    }
}

- (void)getList:(NSString* _Nonnull)configName defaultValue:(NSArray*)defaultValue callback:(RCTResponseSenderBlock)callback {
    @try {
        [HanselRnUtils returnResult:[HanselConfigs getList:configName withDefaultValue:defaultValue] withCallback:callback];
    } @catch (NSException *exception) {
        NSLog(@"Hansel error: Exception caught in getList method in HanselConfigsRn bridge.");
    }
}

- (void)getJSONArray:(NSString* _Nonnull)configName defaultValue:(NSArray*)defaultValue callback:(RCTResponseSenderBlock)callback {
    @try {
        [HanselRnUtils returnResult:[HanselConfigs getJSONArray:configName withDefaultValue:defaultValue] withCallback:callback];
    } @catch (NSException *exception) {
        NSLog(@"Hansel error: Exception caught in getJSONArray method in HanselConfigsRn bridge.");
    }
}

@end

