
#import "RNTestConnecthings.h"
@import AdtagConnection;

@implementation RNTestConnecthings

- (dispatch_queue_t)methodQueue
{
    return dispatch_get_main_queue();
}

+ (Optin) convertToOptin:(NSString *) optin {
    return [optin isEqualToString:@"USER_DATA"] ? OptinUSER_DATA : OptinSTATUS;
}

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(allOptinsAreUpdated)
{
    [[AdtagInitializer shared] allOptinsAreUpdated];
}

RCT_EXPORT_METHOD(optinsNeverAsked:(RCTResponseSenderBlock) callback)
{
    bool result = [[AdtagInitializer shared] optinsNeverAsked];
    callback(@[[NSNull null], [NSNumber numberWithBool:result]]);
}

RCT_EXPORT_METHOD(updateOptin:(NSString *)optin permission:(Bool) permission)
{
    [[AdtagInitializer shared] updateOptin:[RNTestConnecthings convertToOptin:optin] permission:permission];
}

RCT_EXPORT_METHOD(isOptinAuthorized:(NSString *)optin callback: (RCTResponseSenderBlock) callback)
{
    bool result = [[AdtagInitializer shared] isOptinAuthorized:[RNTestConnecthings convertToOptin:optin]];
    callback(@[[NSNull null], [NSNumber numberWithBool:result]]);
}



@end
  
