OSDN Git Service

NyukyoDockMapperを作成
authormasakih <masakih@users.sourceforge.jp>
Fri, 24 Feb 2017 13:29:36 +0000 (22:29 +0900)
committermasakih <masakih@users.sourceforge.jp>
Fri, 24 Feb 2017 13:29:36 +0000 (22:29 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMMemberNDockCommand.swift
KCD/NyukyoDockMapper.swift [new file with mode: 0644]

index 62b8182..50b8fda 100644 (file)
                F47C3EAC1E5F1AD900D97449 /* ShipMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47C3EAB1E5F1AD900D97449 /* ShipMapper.swift */; };
                F47C3EAE1E5F26E900D97449 /* DeckMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47C3EAD1E5F26E900D97449 /* DeckMapper.swift */; };
                F47C3EB01E60500700D97449 /* MaterialMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47C3EAF1E60500700D97449 /* MaterialMapper.swift */; };
+               F47C3EB21E60616E00D97449 /* NyukyoDockMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47C3EB11E60616E00D97449 /* NyukyoDockMapper.swift */; };
                F490977B1E19C3910085A45D /* HMSuppliesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F490977A1E19C3910085A45D /* HMSuppliesView.swift */; };
                F490977D1E19DF390085A45D /* HMSlotItemFrameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F490977C1E19DF390085A45D /* HMSlotItemFrameView.swift */; };
                F490977F1E19ED400085A45D /* HMStrengthenListItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F490977E1E19ED400085A45D /* HMStrengthenListItemView.swift */; };
                F47C3EAB1E5F1AD900D97449 /* ShipMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShipMapper.swift; sourceTree = "<group>"; };
                F47C3EAD1E5F26E900D97449 /* DeckMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeckMapper.swift; sourceTree = "<group>"; };
                F47C3EAF1E60500700D97449 /* MaterialMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialMapper.swift; sourceTree = "<group>"; };
+               F47C3EB11E60616E00D97449 /* NyukyoDockMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NyukyoDockMapper.swift; sourceTree = "<group>"; };
                F490977A1E19C3910085A45D /* HMSuppliesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMSuppliesView.swift; sourceTree = "<group>"; };
                F490977C1E19DF390085A45D /* HMSlotItemFrameView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMSlotItemFrameView.swift; sourceTree = "<group>"; };
                F490977E1E19ED400085A45D /* HMStrengthenListItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMStrengthenListItemView.swift; sourceTree = "<group>"; };
                                F47C3EAB1E5F1AD900D97449 /* ShipMapper.swift */,
                                F47C3EAD1E5F26E900D97449 /* DeckMapper.swift */,
                                F47C3EAF1E60500700D97449 /* MaterialMapper.swift */,
+                               F47C3EB11E60616E00D97449 /* NyukyoDockMapper.swift */,
                                F4A0D7161E2FB7E000224DCE /* HMCompositCommand.swift */,
                                F44BC6D01E224299004644E3 /* HMPortCommand.swift */,
                                F44BC6CA1E223208004644E3 /* HMIgnoreCommand.swift */,
                                F4D05BDF1E0F8B6900688D66 /* HMPowerUpSupportViewController.swift in Sources */,
                                F44BC6F31E23D32B004644E3 /* HMRealPowerUpCommand.swift in Sources */,
                                F4E5FF021E150A850026868C /* HMAncherageRepairTimerViewController.swift in Sources */,
+                               F47C3EB21E60616E00D97449 /* NyukyoDockMapper.swift in Sources */,
                                F4AA59521E1E607F001667AF /* HMJSONViewWindowController.swift in Sources */,
                                F47C3EA61E5F050D00D97449 /* MasterSlotItemMapper.swift in Sources */,
                                F47215AA1E1F96B60083D3BC /* HMResourceHistoryDataStore.swift in Sources */,
index ea34913..afa42db 100644 (file)
@@ -21,6 +21,7 @@ class HMMemberNDockCommand: HMJSONCommand {
     }
     
     override func execute() {
-        commitJSON(toEntityNamed: "NyukyoDock")
+//        commitJSON(toEntityNamed: "NyukyoDock")
+        NyukyoDockMapper(apiResponse).commit()
     }
 }
diff --git a/KCD/NyukyoDockMapper.swift b/KCD/NyukyoDockMapper.swift
new file mode 100644 (file)
index 0000000..a9db174
--- /dev/null
@@ -0,0 +1,35 @@
+//
+//  NyukyoDockMapper.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2017/02/24.
+//  Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+fileprivate enum DeckAPI: String {
+    case getMemberNDock = "/kcsapi/api_get_member/ndock"
+    case port = "/kcsapi/api_port/port"
+}
+
+fileprivate func dataKey(_ apiResponse: HMAPIResponse) -> String {
+    guard let deckApi = DeckAPI(rawValue: apiResponse.api)
+        else { return "api_data" }
+    switch deckApi {
+    case .port: return "api_data.api_ndock"
+    default: return "api_data"
+    }
+}
+
+class NyukyoDockMapper: JSONMapper {
+    required init(_ apiResponse: HMAPIResponse) {
+        self.apiResponse = apiResponse
+        self.configuration = MappingConfiguration(entityName: "NyukyoDock",
+                                                  dataKey: dataKey(apiResponse),
+                                                  editorStore: HMServerDataStore.oneTimeEditor())
+    }
+    
+    let apiResponse: HMAPIResponse
+    let configuration: MappingConfiguration
+}