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

import Foundation

public struct EventsResponse {
    
domenicw's avatar
domenicw committed
13
    public let events: [AMIVEvent]
domenicw's avatar
domenicw committed
14
15
16
17
18
    
}

extension EventsResponse: Decodable {
    
19
    private enum EventsSignupResponseCodingKeys: String, CodingKey {
domenicw's avatar
domenicw committed
20
21
22
23
        case events = "_items"
    }
    
    public init(from decoder: Decoder) throws {
24
        let container = try decoder.container(keyedBy: EventsSignupResponseCodingKeys.self)
domenicw's avatar
domenicw committed
25
        
domenicw's avatar
domenicw committed
26
        self.events = try container.decode([AMIVEvent].self, forKey: .events)
domenicw's avatar
domenicw committed
27
28
29
    }
    
}