blob: 87ee7f204a8e1eff905125aa223e2ca8b2888e18 (
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
|
//
// DeviceManagementInteractor.swift
// MullvadVPN
//
// Created by pronebird on 26/07/2022.
// Copyright © 2022 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadREST
import MullvadTypes
import Operations
class DeviceManagementInteractor {
private let devicesProxy: REST.DevicesProxy
private let accountNumber: String
init(accountNumber: String, devicesProxy: REST.DevicesProxy) {
self.accountNumber = accountNumber
self.devicesProxy = devicesProxy
}
@discardableResult
func getDevices(
_ completionHandler: @escaping (OperationCompletion<[REST.Device], Error>)
-> Void
) -> Cancellable {
return devicesProxy.getDevices(
accountNumber: accountNumber,
retryStrategy: .default
) { completion in
completionHandler(completion.eraseFailureType())
}
}
@discardableResult
func deleteDevice(
_ identifier: String,
completionHandler: @escaping (OperationCompletion<Bool, Error>) -> Void
) -> Cancellable {
return devicesProxy.deleteDevice(
accountNumber: accountNumber,
identifier: identifier,
retryStrategy: .default
) { completion in
completionHandler(completion.eraseFailureType())
}
}
}
|