summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLNavigationServiceData.m
blob: e1ef35a9a3f86297fc215636036419826429986d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
//  SDLNavigationServiceData.m
//  SmartDeviceLink
//
//  Created by Nicole on 2/22/19.
//  Copyright © 2019 smartdevicelink. All rights reserved.
//

#import "SDLNavigationServiceData.h"

#import "NSMutableDictionary+Store.h"
#import "SDLDateTime.h"
#import "SDLLocationDetails.h"
#import "SDLRPCParameterNames.h"
#import "SDLNavigationInstruction.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SDLNavigationServiceData

- (instancetype)initWithTimestamp:(SDLDateTime *)timestamp {
    self = [super init];
    if (!self) {
        return nil;
    }

    self.timestamp = timestamp;

    return self;
}

- (instancetype)initWithTimestamp:(SDLDateTime *)timestamp origin:(nullable SDLLocationDetails *)origin destination:(nullable SDLLocationDetails *)destination destinationETA:(nullable SDLDateTime *)destinationETA instructions:(nullable NSArray<SDLNavigationInstruction *> *)instructions nextInstructionETA:(nullable SDLDateTime *)nextInstructionETA nextInstructionDistance:(float)nextInstructionDistance nextInstructionDistanceScale:(float)nextInstructionDistanceScale prompt:(nullable NSString *)prompt {
    self = [self initWithTimestamp:timestamp];
    if (!self) {
        return nil;
    }

    self.origin = origin;
    self.destination = destination;
    self.destinationETA = destinationETA;
    self.instructions = instructions;
    self.nextInstructionETA = nextInstructionETA;
    self.nextInstructionDistance = @(nextInstructionDistance);
    self.nextInstructionDistanceScale = @(nextInstructionDistanceScale);
    self.prompt = prompt;

    return self;
}

- (void)setTimestamp:(SDLDateTime *)timestamp {
    [store sdl_setObject:timestamp forName:SDLRPCParameterNameTimeStamp];
}

- (SDLDateTime *)timestamp {
    return [store sdl_objectForName:SDLRPCParameterNameTimeStamp ofClass:SDLDateTime.class error:nil];
}

- (void)setOrigin:(nullable SDLLocationDetails *)origin {
    [store sdl_setObject:origin forName:SDLRPCParameterNameOrigin];
}

- (nullable SDLLocationDetails *)origin {
    return [store sdl_objectForName:SDLRPCParameterNameOrigin ofClass:SDLLocationDetails.class error:nil];
}

- (void)setDestination:(nullable SDLLocationDetails *)destination {
    [store sdl_setObject:destination forName:SDLRPCParameterNameDestination];
}

- (nullable SDLLocationDetails *)destination {
    return [store sdl_objectForName:SDLRPCParameterNameDestination ofClass:SDLLocationDetails.class error:nil];
}

- (void)setDestinationETA:(nullable SDLDateTime *)destinationETA {
    [store sdl_setObject:destinationETA forName:SDLRPCParameterNameDestinationETA];
}

- (nullable SDLDateTime *)destinationETA {
    return [store sdl_objectForName:SDLRPCParameterNameDestinationETA ofClass:SDLDateTime.class error:nil];
}

- (void)setInstructions:(nullable NSArray<SDLNavigationInstruction *> *)instructions {
    [store sdl_setObject:instructions forName:SDLRPCParameterNameInstructions];
}

- (nullable NSArray<SDLNavigationInstruction *> *)instructions {
    return [store sdl_objectsForName:SDLRPCParameterNameInstructions ofClass:SDLNavigationInstruction.class error:nil];
}

- (void)setNextInstructionETA:(nullable SDLDateTime *)nextInstructionETA {
    [store sdl_setObject:nextInstructionETA forName:SDLRPCParameterNameNextInstructionETA];
}

- (nullable SDLDateTime *)nextInstructionETA {
    return [store sdl_objectForName:SDLRPCParameterNameNextInstructionETA ofClass:SDLDateTime.class error:nil];
}

- (void)setNextInstructionDistance:(nullable NSNumber<SDLFloat> *)nextInstructionDistance {
    [store sdl_setObject:nextInstructionDistance forName:SDLRPCParameterNameNextInstructionDistance];
}

- (nullable NSNumber<SDLFloat> *)nextInstructionDistance {
    return [store sdl_objectForName:SDLRPCParameterNameNextInstructionDistance ofClass:NSNumber.class error:nil];
}

- (void)setNextInstructionDistanceScale:(nullable NSNumber<SDLFloat> *)nextInstructionDistanceScale {
    [store sdl_setObject:nextInstructionDistanceScale forName:SDLRPCParameterNameNextInstructionDistanceScale];
}

- (nullable NSNumber<SDLFloat> *)nextInstructionDistanceScale {
    return [store sdl_objectForName:SDLRPCParameterNameNextInstructionDistanceScale ofClass:NSNumber.class error:nil];
}

- (void)setPrompt:(nullable NSString *)prompt {
    [store sdl_setObject:prompt forName:SDLRPCParameterNamePrompt];
}

- (nullable NSString *)prompt {
    return [store sdl_objectForName:SDLRPCParameterNamePrompt ofClass:NSString.class error:nil];
}

@end

NS_ASSUME_NONNULL_END