forked from Runnect/Runnect-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
288 additions
and
27 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
23 changes: 23 additions & 0 deletions
23
...ect-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/RequestDto/CourseDrawingRequestDto.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,23 @@ | ||
// | ||
// CourseDrawingRequestDto.swift | ||
// Runnect-iOS | ||
// | ||
// Created by sejin on 2023/01/10. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - CourseDrawingRequestDto | ||
|
||
struct CourseDrawingRequestDto: Codable { | ||
let image: Data | ||
let data: CourseDrawingRequestData | ||
} | ||
|
||
// MARK: - CourseDrawingRequestData | ||
|
||
struct CourseDrawingRequestData: Codable { | ||
let path: [RNLocationModel] | ||
let distance: Float | ||
let departureAddress, departureName: String | ||
} |
21 changes: 21 additions & 0 deletions
21
...-iOS/Runnect-iOS/Network/Dto/CourseDrawingDto/ResponseDto/CourseDrawingResponseData.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,21 @@ | ||
// | ||
// CourseDrawingResponseData.swift | ||
// Runnect-iOS | ||
// | ||
// Created by sejin on 2023/01/10. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - DataClass | ||
|
||
struct CourseDrawingResponseData: Codable { | ||
let course: CourseDrawingResponse | ||
} | ||
|
||
// MARK: - Course | ||
|
||
struct CourseDrawingResponse: Codable { | ||
let id: Int | ||
let createdAt: String | ||
} |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
Runnect-iOS/Runnect-iOS/Network/Model/CourseDrawingModel/RNLocationModel.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,13 @@ | ||
// | ||
// RNLocationModel.swift | ||
// Runnect-iOS | ||
// | ||
// Created by sejin on 2023/01/10. | ||
// | ||
|
||
import Foundation | ||
|
||
struct RNLocationModel: Codable { | ||
let lat: Double | ||
let long: Double | ||
} |
Empty file.
18 changes: 18 additions & 0 deletions
18
Runnect-iOS/Runnect-iOS/Network/Model/RunningModel/RunningModel.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,18 @@ | ||
// | ||
// RunningModel.swift | ||
// Runnect-iOS | ||
// | ||
// Created by sejin on 2023/01/10. | ||
// | ||
|
||
import Foundation | ||
|
||
import NMapsMap | ||
|
||
struct RunningModel { | ||
var courseId: Int? | ||
var publicCourseId: Int? | ||
var locations: [NMGLatLng] | ||
var distance: String? | ||
var pathImage: UIImage? | ||
} |
83 changes: 83 additions & 0 deletions
83
Runnect-iOS/Runnect-iOS/Network/Router/CourseDrawingRouter/CourseDrawingRouter.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,83 @@ | ||
// | ||
// CourseDrawingRouter.swift | ||
// Runnect-iOS | ||
// | ||
// Created by sejin on 2023/01/10. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
enum CourseDrawingRouter { | ||
case uploadCourseDrawing(param: CourseDrawingRequestDto) | ||
} | ||
|
||
extension CourseDrawingRouter: TargetType { | ||
var baseURL: URL { | ||
guard let url = URL(string: Config.baseURL) else { | ||
fatalError("baseURL could not be configured") | ||
} | ||
|
||
return url | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case .uploadCourseDrawing: | ||
return "/course" | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .uploadCourseDrawing: | ||
return .post | ||
} | ||
} | ||
|
||
var task: Moya.Task { | ||
switch self { | ||
case .uploadCourseDrawing(let param): | ||
var multipartFormData: [MultipartFormData] = [] | ||
|
||
let imageData = MultipartFormData(provider: .data(param.image), | ||
name: "image", fileName: "image.jpeg", | ||
mimeType: "image/jpeg") | ||
|
||
multipartFormData.append(imageData) | ||
|
||
var content = [String: Any]() | ||
|
||
var path = [[String: Any]]() | ||
|
||
do { | ||
for location in param.data.path { | ||
let locationData = try location.asParameter() | ||
path.append(locationData) | ||
} | ||
|
||
content["path"] = path | ||
content["distance"] = param.data.distance | ||
content["departureAddress"] = param.data.departureAddress | ||
content["departureName"] = param.data.departureName | ||
|
||
let jsonData = try JSONSerialization.data(withJSONObject: content) | ||
let formData = MultipartFormData(provider: .data(jsonData), name: "data", mimeType: "application/json") | ||
multipartFormData.append(formData) | ||
} catch { | ||
print(error.localizedDescription) | ||
} | ||
|
||
return .uploadMultipart(multipartFormData) | ||
} | ||
} | ||
|
||
var headers: [String: String]? { | ||
switch self { | ||
case .uploadCourseDrawing: | ||
return ["Content-Type": "multipart/form-data", | ||
"machineId": Config.deviceId] | ||
} | ||
} | ||
} |
Empty file.
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
Oops, something went wrong.