Skip to content

Commit

Permalink
feat #144: AuthAPI 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
minsangKang committed Apr 27, 2024
1 parent f3fb50e commit cbcf064
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 48 deletions.
60 changes: 32 additions & 28 deletions Project_Timer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions Project_Timer/Data/API/AuthAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// AuthAPI.swift
// Project_Timer
//
// Created by Kang Minsang on 2024/04/17.
// Copyright © 2024 FDEE. All rights reserved.
//

import Foundation
import Moya

enum AuthAPI {
case postSignup
case postSignin
case getCheckUsername
case getCheckEmail
case postUpdatePassword
}

extension AuthAPI: TargetType {
var baseURL: URL {
return URL(string: NetworkURL.shared.serverURL ?? "nil")!
}

var path: String {
switch self {
case .postSignup:
return "/auth/signup"
case .postSignin:
return "/auth/login"
case .getCheckUsername, .getCheckEmail:
return "/auth/users"
case .postUpdatePassword:
return "/auth/users/password"
}
}

var method: Moya.Method {
switch self {
case .postSignup, .postSignin, .postUpdatePassword:
return .post
case .getCheckUsername, .getCheckEmail:
return .get
}
}

var task: Moya.Task {
return .requestPlain
}

var headers: [String : String]? {
return nil
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AppVersionAPI.swift
// AppVersionNetwork.swift
// Project_Timer
//
// Created by Kang Minsang on 2023/12/03.
Expand All @@ -8,7 +8,7 @@

import Foundation

final class AppVersionAPI {
final class AppVersionNetwork {
private let network = Network()
private var latestVersionURL: String {
let base = Infos.FirestoreURL.value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//
// AuthAPI.swift
// AuthNetwork.swift
// Project_Timer
//
// Created by Kang Minsang on 2023/12/15.
// Copyright © 2023 FDEE. All rights reserved.
//

import Foundation
import Moya

final class AuthAPI {
final class AuthNetwork {
private let network = Network()
private var signupURL: String {
let base = NetworkURL.shared.serverURL ?? "nil"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// DailysAPI.swift
// DailysNetwork.swift
// Project_Timer
//
// Created by Kang Minsang on 2023/12/16.
Expand All @@ -8,7 +8,7 @@

import Foundation

final class DailysAPI {
final class DailysNetwork {
private let network = Network()
private var uploadDailysURL: String {
let base = NetworkURL.shared.serverURL ?? "nil"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// NotificationAPI.swift
// NotificationNetwork.swift
// Project_Timer
//
// Created by Kang Minsang on 2023/12/17.
Expand All @@ -8,7 +8,7 @@

import Foundation

final class NotificationAPI {
final class NotificationNetwork {
private let network = Network()
private var url: String {
let base = Infos.FirestoreURL.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

final class RecordTimesAPI {
final class RecordTimesNetwork {
private let network = Network()
private var url: String {
let base = NetworkURL.shared.serverURL ?? "nil"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ServerURLAPI.swift
// ServerURLNetwork.swift
// Project_Timer
//
// Created by Kang Minsang on 2023/12/15.
Expand All @@ -8,7 +8,7 @@

import Foundation

final class ServerURLAPI {
final class ServerURLNetwork {
private let network = Network()
private var url: String {
let base = Infos.FirestoreURL.value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// SyncLogAPI.swift
// SyncLogNetwork.swift
// Project_Timer
//
// Created by Kang Minsang on 2023/12/16.
Expand All @@ -8,7 +8,7 @@

import Foundation

final class SyncLogAPI {
final class SyncLogNetwork {
private let network = Network()
private var url: String {
let base = NetworkURL.shared.serverURL ?? "nil"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

final class AppLatestVersionRepository: AppLatestVersionRepositoryInterface {
private let api = AppVersionAPI()
private let api = AppVersionNetwork()

func get(completion: @escaping (Result<AppLatestVersionInfo, NetworkError>) -> Void) {
api.get { result in
Expand Down
2 changes: 1 addition & 1 deletion Project_Timer/Data/Repository/AuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

final class AuthRepository: AuthRepositoryInterface {
private let api = AuthAPI()
private let api = AuthNetwork()

func signup(signupInfo: TestUserSignupInfo, completion: @escaping (Result<AuthInfo, NetworkError>) -> Void) {
api.signup(signupInfo: signupInfo) { result in
Expand Down
2 changes: 1 addition & 1 deletion Project_Timer/Data/Repository/DailysRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

final class DailysRepository: DailysRepositoryInterface {
private let api = DailysAPI()
private let api = DailysNetwork()

func upload(dailys: [Daily], completion: @escaping (Result<Bool, NetworkError>) -> Void) {
api.upload(dailys: dailys) { result in
Expand Down
2 changes: 1 addition & 1 deletion Project_Timer/Data/Repository/NotificationRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

final class NotificationRepository: NotificationRepositoryInterface {
private let api = NotificationAPI()
private let api = NotificationNetwork()

func get(completion: @escaping (Result<NotificationInfo?, NetworkError>) -> Void) {
api.get { result in
Expand Down
2 changes: 1 addition & 1 deletion Project_Timer/Data/Repository/RecordTimesRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

final class RecordTimesRepository: RecordTimesRepositoryInterface {
private let api = RecordTimesAPI()
private let api = RecordTimesNetwork()

func upload(recordTimes: RecordTimes, completion: @escaping (Result<Bool, NetworkError>) -> Void) {
api.upload(recordTimes: recordTimes) { result in
Expand Down
2 changes: 1 addition & 1 deletion Project_Timer/Data/Repository/ServerURLRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

final class ServerURLRepository: ServerURLRepositoryInterface {
private let api = ServerURLAPI()
private let api = ServerURLNetwork()

func get(completion: @escaping (Result<String, NetworkError>) -> Void) {
api.get { result in
Expand Down
2 changes: 1 addition & 1 deletion Project_Timer/Data/Repository/SyncLogRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

final class SyncLogRepository: SyncLogRepositoryInterface {
private let api = SyncLogAPI()
private let api = SyncLogNetwork()

func get(completion: @escaping (Result<SyncLog?, NetworkError>) -> Void) {
api.get { result in
Expand Down

0 comments on commit cbcf064

Please sign in to comment.