-
Notifications
You must be signed in to change notification settings - Fork 1
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 #80 from AR-TTUBEOG/feat/RefactorBookMark
Feat/refactor book mark
- Loading branch information
Showing
6 changed files
with
226 additions
and
26 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
64 changes: 64 additions & 0 deletions
64
ttubeokAR/ttubeokAR/ExploreView/ExploreAPI/APITarget/GuestBookAPITarget.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,64 @@ | ||
// | ||
// GuestBookAPITarget.swift | ||
// ttubeokAR | ||
// | ||
// Created by 정의찬 on 5/9/24. | ||
// | ||
|
||
import Foundation | ||
import Moya | ||
|
||
enum GuestBookAPITarget { | ||
case getImage(guestBookId: Int, token: String) | ||
case getSpotGuestBookData(spotId: Int, page: Int, token: String) | ||
case getStoreGuestBookData(storeId: Int, page: Int, token: String) | ||
} | ||
|
||
extension GuestBookAPITarget: TargetType { | ||
var baseURL: URL { return URL(string: "http://43.201.79.99:8080")!} | ||
|
||
var path: String { | ||
switch self { | ||
case .getImage: | ||
return "/api/v1/image/guestbook" | ||
case .getSpotGuestBookData: | ||
return "/api/v1/guestbook" | ||
case .getStoreGuestBookData: | ||
return "/api/v1/guestbook" | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .getImage: | ||
return .get | ||
case .getSpotGuestBookData: | ||
return .get | ||
case .getStoreGuestBookData: | ||
return .get | ||
} | ||
} | ||
|
||
var task: Task { | ||
switch self { | ||
case .getImage(let id, _): | ||
return .requestParameters(parameters: ["guestBookId": id], encoding: URLEncoding.queryString) | ||
case .getSpotGuestBookData(let id, let page, _): | ||
return .requestParameters(parameters: ["spotId": id, "pageNum": page], encoding: URLEncoding.queryString) | ||
case .getStoreGuestBookData(let id, let page, _): | ||
return .requestParameters(parameters: ["storeId": id, "pageNum": page] , encoding: URLEncoding.queryString) | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
let token: String | ||
switch self { | ||
case .getSpotGuestBookData(_, _, let tokenValue), .getStoreGuestBookData(_, _, let tokenValue) ,.getImage(_, let tokenValue): | ||
token = tokenValue | ||
} | ||
return [ | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer \(token)" | ||
] | ||
} | ||
} |
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
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