-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Descriptions Models -> App Model : 프로젝트 내에서 사용할 데이터 모델. NetworkModel : 서버통신 시 사용할 데이터 모델. request body 에 넣을 데이터 모델도 여기서 정의. 네이밍 -> `~~Request` 라고 선언하기. MoyaLoggerPlugin : log 확인할 수 있도록 인터페이스 생성해둠. `~~API` : 서버통신을 위해 호출하는 함수. 네이밍 -> (httpMethod)(Service 에서 선언한 열거형) ex) getCardListPatch : 카드리스트 조회 `~~Service` : TargetType 채택해서 path, method, task, headers 설정. NetworkResult : 서버통신 결과 열거형 정의. GenericResponse : 제네릭을 사용한 공통적인 데이터 모델. data 역할만 NetworkModel 에서 선언해서 사용. - pod update 했습니당 - Util 폴더에 Service 와 API 를 작성하는 예시 코드를 주석으로 달아뒀어요! ### Related Issue close #49
- Loading branch information
Showing
17 changed files
with
510 additions
and
49 deletions.
There are no files selected for viewing
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
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,14 @@ | ||
// | ||
// GeneralAPI.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by kimhyungyu on 2021/11/01. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Const { | ||
struct URL { | ||
static let baseURL = "" | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
NADA-iOS-forRelease/Sources/NetworkModel/GenericResponse.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,27 @@ | ||
// | ||
// GenericResult.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by kimhyungyu on 2021/11/01. | ||
// | ||
|
||
import Foundation | ||
|
||
struct GenericResponse<T: Codable>: Codable { | ||
var msg: String | ||
var timestamp: String | ||
var data: T? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case msg | ||
case timestamp | ||
case data | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let values = try decoder.container(keyedBy: CodingKeys.self) | ||
msg = (try? values.decode(String.self, forKey: .msg)) ?? "" | ||
timestamp = (try? values.decode(String.self, forKey: .timestamp)) ?? "" | ||
data = (try? values.decode(T.self, forKey: .data)) ?? nil | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
NADA-iOS-forRelease/Sources/NetworkModel/NetworkResult.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,16 @@ | ||
// | ||
// NetworkResult.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by kimhyungyu on 2021/11/01. | ||
// | ||
|
||
import Foundation | ||
|
||
enum NetworkResult<T> { | ||
case success(T) // 서버 통신 성공 | ||
case requestErr(T) // 요청 에러 발생 | ||
case pathErr // 경로 에러 | ||
case serverErr // 서버의 내부적 에러 | ||
case networkFail // 네트워크 연결 실패 | ||
} |
8 changes: 8 additions & 0 deletions
8
NADA-iOS-forRelease/Sources/NetworkService/Card/CardAPI.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,8 @@ | ||
// | ||
// CardAPI.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by kimhyungyu on 2021/11/01. | ||
// | ||
|
||
import Foundation |
8 changes: 8 additions & 0 deletions
8
NADA-iOS-forRelease/Sources/NetworkService/Card/CardService.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,8 @@ | ||
// | ||
// CardService.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by kimhyungyu on 2021/11/01. | ||
// | ||
|
||
import Foundation |
8 changes: 8 additions & 0 deletions
8
NADA-iOS-forRelease/Sources/NetworkService/Group/GroupAPI.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,8 @@ | ||
// | ||
// GroupAPI.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by kimhyungyu on 2021/11/01. | ||
// | ||
|
||
import Foundation |
8 changes: 8 additions & 0 deletions
8
NADA-iOS-forRelease/Sources/NetworkService/Group/GroupService.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,8 @@ | ||
// | ||
// GroupService.swift | ||
// NADA-iOS-forRelease | ||
// | ||
// Created by kimhyungyu on 2021/11/01. | ||
// | ||
|
||
import Foundation |
Oops, something went wrong.