Skip to content

Commit

Permalink
Merge pull request #56 from Student-Center/feature/WEAV-138
Browse files Browse the repository at this point in the history
[WEAV-138] Profile Image 업로드 기능 구현
  • Loading branch information
jisu15-kim authored Dec 7, 2024
2 parents 82c64aa + a95f5ae commit 5933517
Show file tree
Hide file tree
Showing 17 changed files with 1,104 additions and 11 deletions.
246 changes: 246 additions & 0 deletions OpenApiGenerator/Sources/OpenapiGenerated/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,252 @@ public struct Client: APIProtocol {
}
)
}
/// 프로필 이미지 업로드 URL 생성
///
/// 프로필 이미지 업로드를 위한 URL을 생성합니다.
///
/// - Remark: HTTP `GET /users/my/profile-images/upload-url`.
/// - Remark: Generated from `#/paths//users/my/profile-images/upload-url/get(getProfileImageUploadUrl)`.
public func getProfileImageUploadUrl(_ input: Operations.getProfileImageUploadUrl.Input) async throws -> Operations.getProfileImageUploadUrl.Output {
try await client.send(
input: input,
forOperation: Operations.getProfileImageUploadUrl.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/users/my/profile-images/upload-url",
parameters: []
)
var request: HTTPTypes.HTTPRequest = .init(
soar_path: path,
method: .get
)
suppressMutabilityWarning(&request)
try converter.setQueryItemAsURI(
in: &request,
style: .form,
explode: true,
name: "extension",
value: input.query._extension
)
converter.setAcceptHeader(
in: &request.headerFields,
contentTypes: input.headers.accept
)
return (request, nil)
},
deserializer: { response, responseBody in
switch response.status.code {
case 200:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Operations.getProfileImageUploadUrl.Output.Ok.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.GetProfileImageUploadUrlResponse.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .ok(.init(body: body))
case 400:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.BadRequest.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ErrorResponse.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .badRequest(.init(body: body))
case 401:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.Unauthorized.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ErrorResponse.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .unauthorized(.init(body: body))
case 500:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.InternalServerError.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ErrorResponse.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .internalServerError(.init(body: body))
default:
return .undocumented(
statusCode: response.status.code,
.init()
)
}
}
)
}
/// 프로필 이미지 업로드 완료 콜백
///
/// 프로필 이미지 업로드 완료 후 콜백을 받아 이미지를 등록합니다. 업로드 완료후 일정시간 이내에 콜백이 호출되지 않을경우 이미지는 삭제됩니다.
///
/// - Remark: HTTP `POST /users/my/profile-images/upload-complete`.
/// - Remark: Generated from `#/paths//users/my/profile-images/upload-complete/post(completeProfileImageUpload)`.
public func completeProfileImageUpload(_ input: Operations.completeProfileImageUpload.Input) async throws -> Operations.completeProfileImageUpload.Output {
try await client.send(
input: input,
forOperation: Operations.completeProfileImageUpload.id,
serializer: { input in
let path = try converter.renderedPath(
template: "/users/my/profile-images/upload-complete",
parameters: []
)
var request: HTTPTypes.HTTPRequest = .init(
soar_path: path,
method: .post
)
suppressMutabilityWarning(&request)
converter.setAcceptHeader(
in: &request.headerFields,
contentTypes: input.headers.accept
)
let body: OpenAPIRuntime.HTTPBody?
switch input.body {
case let .json(value):
body = try converter.setRequiredRequestBodyAsJSON(
value,
headerFields: &request.headerFields,
contentType: "application/json; charset=utf-8"
)
}
return (request, body)
},
deserializer: { response, responseBody in
switch response.status.code {
case 200:
return .ok(.init())
case 400:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.BadRequest.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ErrorResponse.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .badRequest(.init(body: body))
case 401:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.Unauthorized.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ErrorResponse.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .unauthorized(.init(body: body))
case 500:
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
let body: Components.Responses.InternalServerError.Body
let chosenContentType = try converter.bestContentType(
received: contentType,
options: [
"application/json"
]
)
switch chosenContentType {
case "application/json":
body = try await converter.getResponseBodyAsJSON(
Components.Schemas.ErrorResponse.self,
from: responseBody,
transforming: { value in
.json(value)
}
)
default:
preconditionFailure("bestContentType chose an invalid content type.")
}
return .internalServerError(.init(body: body))
default:
return .undocumented(
statusCode: response.status.code,
.init()
)
}
}
)
}
/// 내 원하는 파트너 수정
///
/// 현재 로그인한 사용자의 원하는 파트너 정보를 수정합니다.
Expand Down
Loading

0 comments on commit 5933517

Please sign in to comment.