//
 /***************************************************************
 * Copyright © 2017 HERE Global B.V. All rights reserved. *
 **************************************************************/

#import "HereSDKDemandRideStatusLog+Dictionary.h"
#import "HereSDKDemandRideStatusUpdate+Dictionary.h"
#import "NSString+Utilities.h"
#import "NSDate+NSNumber.h"

@implementation HereSDKDemandRideStatusLog (Dictionary)

- (NSDictionary *)dictionary
{
    NSMutableArray *formattedPrevStatusesArray = [NSMutableArray new];
    for (HereSDKDemandRideStatusUpdate *update in self.prevStatusesArray)
    {
        [formattedPrevStatusesArray addObject:update.dictionary];
    }

    return @{
             @"lastUpdateTime": self.lastUpdateTime.hereSdk_toNumber,
             @"createTime": self.createTime.hereSdk_toNumber,
             @"closedTime": (self.closedTime) ? self.closedTime.hereSdk_toNumber : [NSNull null],
             @"isRideLocationAvailable": [NSNumber numberWithBool:self.isRideLocationAvailable] ,
             @"currentStatus": [HereSDKDemandRideStatusUpdate updateStatusToString:self.currentStatus],
             @"previousStatuses": formattedPrevStatusesArray,
             };
}

@end
