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

#import "SDLGetAppServiceData.h"

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

NS_ASSUME_NONNULL_BEGIN

@implementation SDLGetAppServiceData

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (instancetype)init {
    if (self = [super initWithName:SDLRPCFunctionNameGetAppServiceData]) {
    }
    return self;
}
#pragma clang diagnostic pop

- (instancetype)initWithAppServiceType:(SDLAppServiceType)serviceType {
    self = [self init];
    if (!self) {
        return nil;
    }

    self.serviceType = serviceType;

    return self;
}

- (instancetype)initAndSubscribeToAppServiceType:(SDLAppServiceType)serviceType {
    return [self initWithServiceType:serviceType subscribe:YES];
}

- (instancetype)initAndUnsubscribeToAppServiceType:(SDLAppServiceType)serviceType {
    return [self initWithServiceType:serviceType subscribe:NO];
}

- (instancetype)initWithServiceType:(SDLAppServiceType)serviceType subscribe:(BOOL)subscribe {
    self = [self initWithAppServiceType:serviceType];
    if (!self) {
        return nil;
    }

    self.subscribe = @(subscribe);

    return self;
}

- (void)setServiceType:(NSString *)serviceType {
    [self.parameters sdl_setObject:serviceType forName:SDLRPCParameterNameServiceType];
}

- (NSString *)serviceType {
    NSError *error = nil;
    return [self.parameters sdl_objectForName:SDLRPCParameterNameServiceType ofClass:NSString.class error:&error];
}

- (void)setSubscribe:(nullable NSNumber<SDLBool> *)subscribe {
    [self.parameters sdl_setObject:subscribe forName:SDLRPCParameterNameSubscribe];
}

- (nullable NSNumber<SDLBool> *)subscribe {
    return [self.parameters sdl_objectForName:SDLRPCParameterNameSubscribe ofClass:NSNumber.class error:nil];
}

@end

NS_ASSUME_NONNULL_END