generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ :: [#318] TeacherDomain / EndPoint
- Loading branch information
Showing
1 changed file
with
67 additions
and
8 deletions.
There are no files selected for viewing
75 changes: 67 additions & 8 deletions
75
Projects/Domain/TeacherDomain/Sources/Endpoint/TeacherEndPoint.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 |
---|---|---|
@@ -1,9 +1,68 @@ | ||
// | ||
// TeacherEndPoint.swift | ||
// TeacherDomainInterface | ||
// | ||
// Created by 정윤서 on 2/20/24. | ||
// Copyright © 2024 com.msg. All rights reserved. | ||
// | ||
import BaseDomain | ||
import Emdpoint | ||
|
||
import Foundation | ||
enum TeacherEndPoint { | ||
case common | ||
case principal | ||
case deputyPrincipal | ||
case director | ||
case homeroom(grade: Int, classNum: Int) | ||
} | ||
|
||
extension TeacherEndPoint: SMSEndpoint { | ||
typealias ErrorType = TeacherDomainError | ||
|
||
var domain: SMSDomain { | ||
.teacher | ||
} | ||
|
||
var route: Route { | ||
switch self { | ||
case .common: | ||
return .post("/common") | ||
|
||
case .principal: | ||
return .post("/principal") | ||
|
||
case .deputyPrincipal: | ||
return .post("/deputy-principal") | ||
|
||
case .director: | ||
return .post("/director") | ||
|
||
case .homeroom: | ||
return .post("/homeroom") | ||
} | ||
} | ||
|
||
var task: HTTPTask { | ||
switch self { | ||
case .homeroom(let grade, let classNum): | ||
return .requestParameters(body: [ | ||
"grade": grade, | ||
"classNum": classNum | ||
]) | ||
|
||
default: | ||
return .requestPlain | ||
} | ||
} | ||
|
||
var jwtTokenType: JwtTokenType { | ||
switch self { | ||
default: | ||
return .accessToken | ||
} | ||
} | ||
|
||
var errorMap: [Int : ErrorType]? { | ||
switch self { | ||
default: | ||
return [ | ||
400: .invalidRequest, | ||
403: .invalidRequest, | ||
409: .alreadyExistUser | ||
] | ||
} | ||
} | ||
} |