-
Notifications
You must be signed in to change notification settings - Fork 2
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 #244 from Zatch-Team/dev-api-search
Network/#242-#243: μΈκΈ°μλ κ²μ ν€μλ API μ°κ²° λ° λ΄κ° μνλ μ¬μΉ ViewModel μ€κ³ λ³κ²½
- Loading branch information
Showing
11 changed files
with
249 additions
and
69 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
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
Zatch/Data/Models/Search/PopularKeywordResponseModel.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 @@ | ||
// | ||
// PopularKeywordResponseModel.swift | ||
// Zatch | ||
// | ||
// Created by λ°μμ€ on 2023/05/22. | ||
// | ||
|
||
import Foundation | ||
|
||
struct PopularKeywordsResponseModel: Decodable{ | ||
let popularItem: [PopularKeywords] | ||
} | ||
|
||
struct PopularKeywords: Decodable{ | ||
|
||
let keyword: String | ||
let likeCount: Int | ||
|
||
enum CodingKeys: String, CodingKey{ | ||
case keyword = "md_name" | ||
case likeCount = "like_count" | ||
} | ||
} |
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,36 @@ | ||
// | ||
// SearchRouter.swift | ||
// Zatch | ||
// | ||
// Created by λ°μμ€ on 2023/05/22. | ||
// | ||
|
||
import Foundation | ||
import Moya | ||
|
||
enum SearchRouter: BaseRouter{ | ||
case getPopularKeywords | ||
} | ||
|
||
extension SearchRouter{ | ||
|
||
var path: String { | ||
switch self { | ||
case .getPopularKeywords: return HTTPMethodURL.GET.popularKeywords | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .getPopularKeywords: return .get | ||
} | ||
} | ||
|
||
var task: Task { | ||
switch self{ | ||
case .getPopularKeywords: return .requestPlain | ||
} | ||
} | ||
} | ||
|
||
|
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,22 @@ | ||
// | ||
// SearchService.swift | ||
// Zatch | ||
// | ||
// Created by λ°μμ€ on 2023/05/22. | ||
// | ||
|
||
import Foundation | ||
|
||
public class SearchService { | ||
|
||
static let shared = SearchService() | ||
let provider = BaseService(plugins: [MoyaLoggerPlugin()]) | ||
|
||
private init() { } | ||
|
||
func getPopularKeywords(completion: @escaping (Result<PopularKeywordsResponseModel, Error>) -> Void){ | ||
provider.requestDecoded(SearchRouter.getPopularKeywords){ response in | ||
completion(response) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.