-
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.
Browse files
Browse the repository at this point in the history
Feat/#157 ios statistics
- Loading branch information
Showing
19 changed files
with
376 additions
and
216 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
15 changes: 15 additions & 0 deletions
15
iOS/RollTheDice/RollTheDice/Source/Domain/ScoopAPI/ScoopAPIStatistics.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,15 @@ | ||
// | ||
// ScoopAPIStatistics.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 6/20/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum ScoopAPIStatistics { | ||
// public static let statistics = String("/statistics") | ||
public static let statisticsPerDates = String("/statistics/per-dates") | ||
public static let statisticsCategories = String("/statistics/categories") | ||
|
||
} |
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
63 changes: 63 additions & 0 deletions
63
iOS/RollTheDice/RollTheDice/Source/Domain/Service/StatisticsService.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,63 @@ | ||
// | ||
// StatisticsService.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 6/20/24. | ||
// | ||
|
||
import Foundation | ||
import Moya | ||
|
||
enum StatisticsService { | ||
case recentSevenPerDate(accessToken: String) /// 최근 일주일 날짜별 뉴스 조회수 조회 | ||
case statisticsCategory(accessToken: String) /// 카테고리별 조회수 조회 | ||
} | ||
|
||
extension StatisticsService: BaseTargetType { | ||
var baseURL: URL { | ||
return URL(string: ScoopAPI.baseURL)! | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case .recentSevenPerDate(let accessToken): | ||
return ScoopAPIStatistics.statisticsPerDates | ||
|
||
case .statisticsCategory(let accessToken): | ||
return ScoopAPIStatistics.statisticsCategories | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .recentSevenPerDate, | ||
.statisticsCategory: | ||
return .get | ||
|
||
} | ||
} | ||
|
||
var task: Moya.Task { | ||
switch self { | ||
case .recentSevenPerDate(_), | ||
.statisticsCategory(_): | ||
|
||
let parameters : [String : Any] = [ : ] | ||
return .requestPlain | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
let accessToken: String | ||
|
||
switch self { | ||
case .recentSevenPerDate(let accessTokenValue), | ||
.statisticsCategory(let accessTokenValue): | ||
accessToken = accessTokenValue | ||
return [ | ||
"Authorization": "Bearer \(accessToken)", | ||
"X-Content-Type_Options" : "nosniff" | ||
] | ||
} | ||
} | ||
} |
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.