-
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/#149 ios bookmarks api
- Loading branch information
Showing
26 changed files
with
451 additions
and
218 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
12 changes: 12 additions & 0 deletions
12
iOS/RollTheDice/RollTheDice/Source/Domain/ScoopAPI/ScoopAPIBookmarks.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,12 @@ | ||
// | ||
// ScoopAPIBookmark.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 6/14/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum ScoopAPIBookmarks { | ||
public static let bookmarks = String("/bookmarks") | ||
} |
12 changes: 12 additions & 0 deletions
12
iOS/RollTheDice/RollTheDice/Source/Domain/ScoopAPI/ScoopAPILogin.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,12 @@ | ||
// | ||
// ScoopAPILogin.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 6/18/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum ScoopAPILogin { | ||
public static let login = String("/login") | ||
} |
81 changes: 81 additions & 0 deletions
81
iOS/RollTheDice/RollTheDice/Source/Domain/Service/BookmarksService.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,81 @@ | ||
// | ||
// BookmarksService.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 6/14/24. | ||
// | ||
|
||
import Foundation | ||
import Moya | ||
|
||
enum BookmarksService { | ||
case bookmarksIsChecked(newsId: Int, accessToken: String) ///뉴스 북마크 여부 조회 | ||
case saveBookmarks(newsId: Int, accessToken: String) ///북마크 저장 | ||
case deleteBookmarks(newsId: Int, accessToken: String) ///북마크 삭제 | ||
case allBookmarks(page: Int, size: Int, accessToken: String) ///북마크 전체 조회/ | ||
} | ||
|
||
extension BookmarksService: BaseTargetType { | ||
|
||
var baseURL: URL { | ||
return URL(string: ScoopAPI.baseURL)! | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case .bookmarksIsChecked(let newsId, _), | ||
.saveBookmarks(let newsId, _), | ||
.deleteBookmarks(let newsId, _) | ||
: | ||
return "\(ScoopAPIBookmarks.bookmarks)/\(newsId)" | ||
|
||
case .allBookmarks: | ||
return ScoopAPIBookmarks.bookmarks | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .bookmarksIsChecked: | ||
return .get | ||
case .saveBookmarks: | ||
return .post | ||
case .deleteBookmarks: | ||
return .delete | ||
case .allBookmarks: | ||
return .get | ||
} | ||
} | ||
|
||
var task: Moya.Task { | ||
switch self { | ||
case .bookmarksIsChecked(let newsId, _), | ||
.saveBookmarks(let newsId, _), | ||
.deleteBookmarks(let newsId, _): | ||
let parameters : [String : Any] = [:] | ||
return .requestParameters(parameters: parameters, encoding: URLEncoding.default) | ||
|
||
case .allBookmarks(let page, let size, _): | ||
let parameters : [String : Any] = [ | ||
"page" : page, | ||
"size" : size, | ||
] | ||
return .requestParameters(parameters: parameters, | ||
encoding: URLEncoding.queryString) | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
let accessToken: String | ||
switch self { | ||
case .bookmarksIsChecked(_, let accessToken), | ||
.saveBookmarks(_, let accessToken), | ||
.deleteBookmarks(_, let accessToken), | ||
.allBookmarks(_, _, let accessToken): | ||
return [ | ||
"Authorization": "Bearer \(accessToken)", | ||
"X-Content-Type_Options" : "nosniff" | ||
] | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
iOS/RollTheDice/RollTheDice/Source/Domain/Service/LoginService.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,56 @@ | ||
// | ||
// AuthAPI.swift | ||
// RollTheDice | ||
// | ||
// Created by 신예진 on 5/31/24. | ||
// | ||
|
||
import Foundation | ||
import Moya | ||
|
||
enum LoginService { | ||
case login(request: AuthRequestModel) | ||
} | ||
|
||
//struct LoginService { | ||
// static let provider = MoyaProvider<AuthTarget>() | ||
//} | ||
|
||
extension LoginService: BaseTargetType { | ||
|
||
var baseURL: URL { | ||
return URL(string: ScoopAPI.baseURL)! | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case .login: | ||
return ScoopAPILogin.login | ||
} | ||
} | ||
|
||
var method: Moya.Method { | ||
switch self { | ||
case .login: | ||
return .post | ||
} | ||
} | ||
|
||
var task: Moya.Task { | ||
switch self { | ||
case .login(let request): | ||
// let parameters : [String : Any] = [ | ||
// "token" : token, | ||
// "socialType" : socialType, | ||
// ] | ||
// return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString) | ||
return .requestJSONEncodable(request) | ||
} | ||
} | ||
|
||
var headers: [String: String]? { | ||
return [ | ||
"X-Content-Type_Options" : "nosniff" | ||
] | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
iOS/RollTheDice/RollTheDice/Source/View/Authentication/Auth.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 @@ | ||
// | ||
// Auth.swift | ||
// RollTheDice | ||
// | ||
// Created by Subeen on 6/18/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct AuthModel: Codable { | ||
let accessToken: String? | ||
let refreshToken: String? | ||
|
||
// enum CodingKeys: String, CodingKey { | ||
// case Authorization | ||
// case AuthorizationRefresh = "Authorization-refresh" | ||
// } | ||
} | ||
|
||
struct AuthRequestModel: Codable { | ||
let token: String? | ||
let socialType: String? | ||
} |
54 changes: 0 additions & 54 deletions
54
iOS/RollTheDice/RollTheDice/Source/View/Authentication/AuthAPI.swift
This file was deleted.
Oops, something went wrong.
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.