OSDN Git Service

Squashed commit of the following: Swiftに変換した
[kcd/KCD.git] / KCD / NyukyoDockMapper.swift
1 //
2 //  NyukyoDockMapper.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/02/24.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 fileprivate enum DeckAPI: String {
12     case getMemberNDock = "/kcsapi/api_get_member/ndock"
13     case port = "/kcsapi/api_port/port"
14 }
15
16 fileprivate func dataKey(_ apiResponse: APIResponse) -> String {
17     guard let deckApi = DeckAPI(rawValue: apiResponse.api)
18         else { return "api_data" }
19     switch deckApi {
20     case .port: return "api_data.api_ndock"
21     default: return "api_data"
22     }
23 }
24
25 class NyukyoDockMapper: JSONMapper {
26     let apiResponse: APIResponse
27     let configuration: MappingConfiguration
28     
29     required init(_ apiResponse: APIResponse) {
30         self.apiResponse = apiResponse
31         self.configuration = MappingConfiguration(entityName: "NyukyoDock",
32                                                   dataKey: dataKey(apiResponse),
33                                                   editorStore: ServerDataStore.oneTimeEditor())
34     }
35 }