-
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.
feat(ImageData): Create Image repository
- Loading branch information
Showing
23 changed files
with
239 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// This file is used to generate the TuistBundle file. |
17 changes: 17 additions & 0 deletions
17
Projects/Data/ImageDataModule/ImageData/Sources/Error/ImageError.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,17 @@ | ||
// | ||
// ImageError.swift | ||
// ImageData | ||
// | ||
// Created by DOYEON LEE on 8/25/24. | ||
// | ||
|
||
import Foundation | ||
|
||
/// An error type that announcement related errors. | ||
public enum ImageError: LocalizedError { | ||
/// The response from the server is not match client scheme. | ||
case invalidResponse | ||
|
||
/// Wraps another error that caused this error. | ||
case underlying(_ error: Error) | ||
} |
72 changes: 72 additions & 0 deletions
72
Projects/Data/ImageDataModule/ImageData/Sources/Repository/ImageRepository.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,72 @@ | ||
// | ||
// ImageRepository.swift | ||
// ImageData | ||
// | ||
// Created by DOYEON LEE on 8/25/24. | ||
// | ||
|
||
import OpenapiGenerated | ||
import ImageDataInterface | ||
import CommonData | ||
|
||
import OpenAPIURLSession | ||
import RxSwift | ||
|
||
public struct ImageRepository: ImageRepositoryInterface { | ||
private let client: APIProtocol | ||
|
||
public init() { | ||
self.client = Client( | ||
serverURL: UrlConfig.baseUrl.url, | ||
configuration: .init(dateTranscoder: .custom), | ||
transport: URLSessionTransport(), | ||
middlewares: [AuthenticationMiddleware()] | ||
) | ||
} | ||
|
||
func getImageUploadPath( | ||
_ request: GetImageUploadPathRequest | ||
) -> Observable<GetImageUploadPathResponse> { | ||
return Observable.create { observer in | ||
Task { | ||
do { | ||
let response = try await client.getContentImage( | ||
.init(query: request) | ||
) | ||
|
||
let data = try response.ok.body.json | ||
|
||
observer.onNext(data) | ||
observer.onCompleted() | ||
} catch { | ||
observer.onError(ImageError.underlying(error)) | ||
} | ||
} | ||
|
||
return Disposables.create() | ||
} | ||
} | ||
|
||
func notifyImageUploadComplete( | ||
_ request: NotifyImageUploadCompleteRequest | ||
) -> Observable<NotifyImageUploadCompleteResponse> { | ||
return Observable.create { observer in | ||
Task { | ||
do { | ||
let response = try await client.notifyContentImageSaveSuccess( | ||
body: request | ||
) | ||
|
||
let data = try response.ok | ||
|
||
observer.onNext(()) | ||
observer.onCompleted() | ||
} catch { | ||
observer.onError(ImageError.underlying(error)) | ||
} | ||
} | ||
|
||
return Disposables.create() | ||
} | ||
} | ||
} |
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,9 @@ | ||
import ProjectDescription | ||
import ProjectDescriptionHelpers | ||
|
||
let project = Project.makeDataModule( | ||
.image, | ||
dependencies: [ | ||
.dataInterface(.image) | ||
] | ||
) |
1 change: 1 addition & 0 deletions
1
Projects/DataInterface/ImageDataInterfaceModule/ImageDataInterface/Resources/Empty.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 @@ | ||
// This file is used to generate the TuistBundle file. |
18 changes: 18 additions & 0 deletions
18
...erface/ImageDataInterfaceModule/ImageDataInterface/Sources/ImageRepositoryInterface.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,18 @@ | ||
// | ||
// ImageRepositoryInterface.swift | ||
// ImageDataInterface | ||
// | ||
// Created by DOYEON LEE on 8/25/24. | ||
// | ||
|
||
import RxSwift | ||
|
||
public protocol ImageRepositoryInterface { | ||
func getImageUploadPath( | ||
_ request: GetImageUploadPathRequest | ||
) -> Observable<GetImageUploadPathResponse> | ||
|
||
func notifyImageUploadComplete( | ||
_ request: NotifyImageUploadCompleteRequest | ||
) -> Observable<NotifyImageUploadCompleteResponse> | ||
} |
14 changes: 14 additions & 0 deletions
14
...dule/ImageDataInterface/Sources/Request&Response/GetImageUploadPathRequest&Response.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,14 @@ | ||
// | ||
// GetImageUploadPathRequest&Response.swift | ||
// ImageDataInterface | ||
// | ||
// Created by DOYEON LEE on 8/25/24. | ||
// | ||
|
||
import OpenapiGenerated | ||
|
||
// MARK: Request | ||
public typealias GetImageUploadPathRequest = Operations.getContentImage.Input.Query | ||
|
||
// MARK: Response | ||
public typealias GetImageUploadPathResponse = Components.Schemas.ContentImagePresignedUrlVO |
14 changes: 14 additions & 0 deletions
14
...ageDataInterface/Sources/Request&Response/NotifyImageUploadCompleteRequest&Response.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,14 @@ | ||
// | ||
// NotifyImageUploadCompleteRequest&Response.swift | ||
// ImageDataInterface | ||
// | ||
// Created by DOYEON LEE on 8/25/24. | ||
// | ||
|
||
import OpenapiGenerated | ||
|
||
// MARK: Request | ||
public typealias NotifyImageUploadCompleteRequest = Operations.notifyContentImageSaveSuccess.Input.Body | ||
|
||
// MARK: Response | ||
public typealias NotifyImageUploadCompleteResponse = Void |
4 changes: 4 additions & 0 deletions
4
Projects/DataInterface/ImageDataInterfaceModule/Project.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,4 @@ | ||
import ProjectDescription | ||
import ProjectDescriptionHelpers | ||
|
||
let project = Project.makeDataInterfaceModule(.image) |
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
28 changes: 28 additions & 0 deletions
28
Projects/Domain/CommonDomainModule/CommonUsecase/Sources/UploadImageUsecase.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,28 @@ | ||
// | ||
// UploadImageUsecase.swift | ||
// CommonUsecase | ||
// | ||
// Created by DOYEON LEE on 8/25/24. | ||
// | ||
|
||
import RxSwift | ||
|
||
public struct UploadImageUsecase { | ||
// MARK: DTO | ||
public struct Input { | ||
public init() { } | ||
} | ||
|
||
public struct Output { } | ||
|
||
// MARK: Dependency | ||
|
||
// MARK: Initializer | ||
public init() { } | ||
|
||
// MARK: Execute method | ||
public func execute(_ input: Input) -> Observable<Output> { | ||
let outputObservable = Observable.just(Output()) | ||
return outputObservable | ||
} | ||
} |
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
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
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
Oops, something went wrong.