AMIVApiEvents.swift 1.19 KB
Newer Older
domenicw's avatar
domenicw committed
1
//
2
//  AMIVApiEvents.swift
domenicw's avatar
domenicw committed
3
4
5
6
7
8
9
10
//  Amiv
//
//  Created by Domenic Wüthrich on 23.09.18.
//  Copyright © 2018 Amiv an der ETH. All rights reserved.
//

import Foundation

11
public enum AMIVApiEvents {
domenicw's avatar
domenicw committed
12
13
    
    case events
14
    case eventSignups
domenicw's avatar
domenicw committed
15
    case media(_ path: String)
domenicw's avatar
domenicw committed
16
17
18
    
}

19
extension AMIVApiEvents: EndPointType {
domenicw's avatar
domenicw committed
20
21
22
23
    
    public var path: String {
        switch self {
        case .events:
domenicw's avatar
domenicw committed
24
            return "/events"
25
26
        case .eventSignups:
            return "/eventsignups"
domenicw's avatar
domenicw committed
27
28
        case .media(let path):
            return path
domenicw's avatar
domenicw committed
29
30
31
32
33
        }
    }
    
    public var httpMethod: HTTPMethod {
        switch self {
34
        case .events, .media, .eventSignups:
domenicw's avatar
domenicw committed
35
36
37
38
39
40
            return .get
        }
    }
    
    public var task: HTTPTask {
        switch self {
41
        case .events, .media, .eventSignups:
domenicw's avatar
domenicw committed
42
43
44
45
46
47
            return .request
        }
    }
    
    public var headers: HTTPHeaders? {
        switch self {
48
        case .events, .media, .eventSignups:
domenicw's avatar
domenicw committed
49
50
51
52
            return nil
        }
    }
    
53
54
    public var isAuthenticationRequired: Bool {
        switch self {
domenicw's avatar
domenicw committed
55
        case .events, .media:
56
            return false
57
58
        case .eventSignups:
            return true
59
60
61
        }
    }
    
domenicw's avatar
domenicw committed
62
}