//
//  LSQuestionList+RCTNativeModel.m
//  ReactLightspeedSDK
//
//  Created by marc matta on 12/21/17.
//  Copyright © 2017 com.lightspeed. All rights reserved.
//


#import "LSQuestionList+RCTNativeModel.h"
#import "RCTLSUtils.h"
#import "LSQuestion+RCTNativeModel.h"

NSString * DailyQuizStatusStringFromValue(NSNumber * _Nullable value) {
    if (!value) {
        return nil;
    }
    
    DailyQuizStatus status = [value integerValue];
    
    switch (status) {
        case DailyQuizStatusNotCompleted:
            return @"DailyQuizStatusNotCompleted";
        case DailyQuizStatusCompleted:
            return @"DailyQuizStatusCompleted";
        case DailyQuizStatusLost:
            return @"DailyQuizStatusLost";
    }
}

NSString *QuestionsStatusFromValue(QuestionsStatus value) {
    switch (value) {
        case QuestionsStatusAvailable:
            return @"QuestionsStatusAvailable";
        case QuestionsStatusQuestionsCompleted:
            return @"QuestionsStatusQuestionsCompleted";
        case QuestionsStatusNoQuestionsAvailable:
            return @"QuestionsStatusNoQuestionsAvailable";
    }
}


@implementation LSQuestionList (RCTNativeModel)

- (NSDictionary *)reactNativeRepresentation {
    return @{@"dailyQuizStatus": RCTNullIfNil(DailyQuizStatusStringFromValue(self.dailyQuizStatus)),
             @"questionsStatus":QuestionsStatusFromValue(self.questionsStatus),
             @"remainingDays":RCTNullIfNil(self.remainingDays),
             @"remainingQuestions":RCTNullIfNil(self.remainingQuestions),
             @"questions": [RCTLSUtils LSArrayFromNativeModels:self.questions]
             };
}

@end
