summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLWeatherServiceData.m
blob: 59ed81be34c1e29c78787710c9dc868a79795d5f (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
//
//  SDLWeatherServiceData.m
//  SmartDeviceLink
//
//  Created by Nicole on 2/7/19.
//  Copyright © 2019 smartdevicelink. All rights reserved.
//

#import "SDLWeatherServiceData.h"

#import "NSMutableDictionary+Store.h"
#import "SDLRPCParameterNames.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SDLWeatherServiceData

- (instancetype)initWithLocation:(SDLLocationDetails *)location {
    self = [super init];
    if (!self) {
        return nil;
    }

    self.location = location;

    return self;
}

- (instancetype)initWithLocation:(SDLLocationDetails *)location currentForecast:(nullable SDLWeatherData *)currentForecast minuteForecast:(nullable NSArray<SDLWeatherData *> *)minuteForecast hourlyForecast:(nullable NSArray<SDLWeatherData *> *)hourlyForecast multidayForecast:(nullable NSArray<SDLWeatherData *> *)multidayForecast alerts:(nullable NSArray<SDLWeatherAlert *> *)alerts {
    self = [self initWithLocation:location];
    if (!self) {
        return nil;
    }

    self.currentForecast = currentForecast;
    self.minuteForecast = minuteForecast;
    self.hourlyForecast = hourlyForecast;
    self.multidayForecast = multidayForecast;
    self.alerts = alerts;

    return self;
}

- (void)setLocation:(SDLLocationDetails *)location {
    [store sdl_setObject:location forName:SDLRPCParameterNameLocation];
}

- (SDLLocationDetails *)location {
    NSError *error = nil;
    return [store sdl_objectForName:SDLRPCParameterNameLocation ofClass:SDLLocationDetails.class error:&error];
}

- (void)setCurrentForecast:(nullable SDLWeatherData *)currentForecast {
    [store sdl_setObject:currentForecast forName:SDLRPCParameterNameCurrentForecast];
}

- (nullable SDLWeatherData *)currentForecast {
    return [store sdl_objectForName:SDLRPCParameterNameCurrentForecast ofClass:SDLWeatherData.class error:nil];
}

- (void)setMinuteForecast:(nullable NSArray<SDLWeatherData *> *)minuteForecast {
    [store sdl_setObject:minuteForecast forName:SDLRPCParameterNameMinuteForecast];
}

- (nullable NSArray<SDLWeatherData *> *)minuteForecast {
    return [store sdl_objectsForName:SDLRPCParameterNameMinuteForecast ofClass:SDLWeatherData.class error:nil];
}

- (void)setHourlyForecast:(nullable NSArray<SDLWeatherData *> *)hourlyForecast {
    [store sdl_setObject:hourlyForecast forName:SDLRPCParameterNameHourlyForecast];
}

- (nullable NSArray<SDLWeatherData *> *)hourlyForecast {
    return [store sdl_objectsForName:SDLRPCParameterNameHourlyForecast ofClass:SDLWeatherData.class error:nil];
}

- (void)setMultidayForecast:(nullable NSArray<SDLWeatherData *> *)multidayForecast {
    [store sdl_setObject:multidayForecast forName:SDLRPCParameterNameMultidayForecast];
}

- (nullable NSArray<SDLWeatherData *> *)multidayForecast {
    return [store sdl_objectsForName:SDLRPCParameterNameMultidayForecast ofClass:SDLWeatherData.class error:nil];
}

- (void)setAlerts:(nullable NSArray<SDLWeatherAlert *> *)alerts {
    [store sdl_setObject:alerts forName:SDLRPCParameterNameAlerts];
}

- (nullable NSArray<SDLWeatherAlert *> *)alerts {
    return [store sdl_objectsForName:SDLRPCParameterNameAlerts ofClass:SDLWeatherAlert.class error:nil];
}

@end

NS_ASSUME_NONNULL_END