-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from boostcamp-2020/feature/networkframework
Feature/networkframework
- Loading branch information
Showing
19 changed files
with
908 additions
and
70 deletions.
There are no files selected for viewing
365 changes: 340 additions & 25 deletions
365
iOS/IssueTracker/IssueTracker.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
iOS/IssueTracker/IssueTracker/02.LabelScene/Model/Label.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
iOS/IssueTracker/IssueTracker/03.MilestoneScene/Model/Milestone.swift
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// Label.swift | ||
// IssueTracker | ||
// | ||
// Created by sihyung you on 2020/10/27. | ||
// Copyright © 2020 IssueTracker-15. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Label: Codable { | ||
let id: Int | ||
let title: String | ||
let description: String | ||
let hexColor: String | ||
|
||
init(title: String, description: String, hexColor: String) { | ||
self.id = -1 | ||
self.title = title | ||
self.description = description | ||
self.hexColor = hexColor | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: DeCodingKeys.self) | ||
id = try container.decode(Int.self, forKey: .id) | ||
title = try container.decode(String.self, forKey: .title) | ||
description = try container.decode(String.self, forKey: .description) | ||
hexColor = try container.decode(String.self, forKey: .hexColor) | ||
} | ||
|
||
func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: EnCodingKeys.self) | ||
try container.encode(title, forKey: .title) | ||
try container.encode(description, forKey: .description) | ||
try container.encode(hexColor, forKey: .hexColor) | ||
} | ||
|
||
enum EnCodingKeys: String, CodingKey { | ||
case title | ||
case description | ||
case hexColor = "color" | ||
} | ||
|
||
enum DeCodingKeys: String, CodingKey { | ||
case id | ||
case title | ||
case description | ||
case hexColor = "color" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// Milestone.swift | ||
// IssueTracker | ||
// | ||
// Created by 김신우 on 2020/10/29. | ||
// Copyright © 2020 IssueTracker-15. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Milestone: Codable { | ||
let id: Int | ||
let title: String | ||
let description: String | ||
let openIssuesLength: String | ||
let closeIssueLength: String | ||
let dueDate: String | ||
|
||
init(id: Int, title: String, description: String, dueDate: String, openIssuesLength: String, closeIssueLength: String) { | ||
self.id = id | ||
self.title = title | ||
self.description = description | ||
self.dueDate = dueDate | ||
self.openIssuesLength = openIssuesLength | ||
self.closeIssueLength = closeIssueLength | ||
} | ||
|
||
init(id: Int, title: String, description: String, dueDate: String) { | ||
self.init(id: id, title: title, description: description, dueDate: dueDate, openIssuesLength: "0", closeIssueLength: "0") | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: DeCodingKeys.self) | ||
id = try container.decode(Int.self, forKey: .id) | ||
title = try container.decode(String.self, forKey: .title) | ||
description = try container.decode(String.self, forKey: .description) | ||
openIssuesLength = try container.decode(String.self, forKey: .openIssueLength) | ||
closeIssueLength = try container.decode(String.self, forKey: .closeIssueLength) | ||
dueDate = try container.decode(String.self, forKey: .dueDate) | ||
} | ||
|
||
func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: EnCodingKeys.self) | ||
try container.encode(title, forKey: .title) | ||
try container.encode(description, forKey: .description) | ||
try container.encode(dueDate, forKey: .dueDate) | ||
} | ||
|
||
enum EnCodingKeys: CodingKey { | ||
case title | ||
case dueDate | ||
case description | ||
} | ||
|
||
enum DeCodingKeys: String, CodingKey { | ||
case id | ||
case title | ||
case description | ||
case openIssueLength = "OpenIssuesLength" | ||
case closeIssueLength = "CloseIssuesLength" | ||
case dueDate | ||
} | ||
} |
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
iOS/IssueTracker/IssueTracker/06.Extensions/JSONDecoder+Decode.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// JSONDecoder+Decode.swift | ||
// IssueTracker | ||
// | ||
// Created by 김신우 on 2020/11/02. | ||
// Copyright © 2020 IssueTracker-15. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension JSONDecoder { | ||
|
||
static func decode<T: Decodable>(_ type: T.Type, from data: Data) -> T? { | ||
return try? JSONDecoder().decode(type, from: data) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
iOS/IssueTracker/IssueTracker/08.Endpoints/LabelEndPoint.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// | ||
// LabelEndPoint.swift | ||
// IssueTracker | ||
// | ||
// Created by sihyung you on 2020/11/02. | ||
// Copyright © 2020 IssueTracker-15. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import NetworkFramework | ||
|
||
struct LabelEndPoint: EndPoint { | ||
var requestType: RequestType | ||
var parameter: String = "" | ||
var httpBody: Data? | ||
|
||
init(requestType: RequestType, parameter: String, httpBody: Data? = nil) { | ||
self.requestType = requestType | ||
self.parameter = parameter | ||
self.httpBody = httpBody | ||
} | ||
|
||
init(requestType: RequestType, httpBody: Data? = nil) { | ||
self.requestType = requestType | ||
self.httpBody = httpBody | ||
} | ||
|
||
enum RequestType { | ||
case fetch | ||
case create | ||
case edit | ||
case delete | ||
} | ||
|
||
var scheme: String { | ||
switch self { | ||
default: | ||
return "http" | ||
} | ||
} | ||
|
||
var baseURL: String { | ||
switch self { | ||
default: | ||
return "118.67.134.194" | ||
} | ||
} | ||
|
||
var port: Int { | ||
switch self { | ||
default: | ||
return 3000 | ||
} | ||
} | ||
|
||
var path: String { | ||
switch requestType { | ||
case .fetch: | ||
return "/api/label" | ||
case .create: | ||
return "/api/label" | ||
case .edit: | ||
return "/api/label/" + parameter | ||
case .delete: | ||
return "/api/label/" + parameter | ||
} | ||
} | ||
|
||
var method: HTTPMethod { | ||
switch requestType { | ||
case .fetch: | ||
return .get | ||
case .create: | ||
return .post | ||
case .edit: | ||
return .patch | ||
case .delete: | ||
return .delete | ||
} | ||
} | ||
|
||
var statusCode: Int { | ||
switch requestType { | ||
case .fetch, .edit: | ||
return 200 | ||
case .create: | ||
return 201 | ||
case .delete: | ||
return 204 | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.