-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGEOCountryDomainData.swift
More file actions
60 lines (49 loc) · 1.55 KB
/
GEOCountryDomainData.swift
File metadata and controls
60 lines (49 loc) · 1.55 KB
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
//
// GEOCountryDomainData.swift
// RKGeonames
//
// Created by Stefan Buretea on 1/17/17.
// Copyright © 2017 Stefan Burettea. All rights reserved.
//
import Foundation
import RxCocoa
import RxSwift
import RxDataSources
struct GEOCountryDomainDataItem {
var title: String
var value: String
}
struct GEOSectionOfCountryDomainDataItem {
var header: String
var items: [Item]
}
extension GEOSectionOfCountryDomainDataItem: SectionModelType {
typealias Item = GEOCountryDomainDataItem
init(original: GEOSectionOfCountryDomainDataItem, items: [Item]) {
self = original
self.items = items
}
}
protocol GEOCountryDomainData {
var country: GEOCountry { get }
var year: String { get }
init(country: GEOCountry, year: String)
func retrieve() -> Observable<[GEOCountryDomainDataItem]>
}
enum GEOCountryDomainDataType {
case administration(GEOCountry, String)
case demographic(GEOCountry, String)
case economic(GEOCountry, String)
}
enum GEOCountryDomainDataFactory {
static func domainData(for type: GEOCountryDomainDataType) -> GEOCountryDomainData {
switch type {
case .administration(let country, let year):
return GEOCountryAdministrationData(country: country, year: year)
case .demographic(let country, let year):
return GEOCountryDemographicData(country: country, year: year)
case .economic(let country, let year):
return GEOCountryEconomicData(country: country, year: year)
}
}
}