-
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.
[refactor] #12 SendProfileUseCase 구현
Co-Authored-By: YOON JI SEONG <[email protected]>
- Loading branch information
1 parent
ec0bfc7
commit 7ec5950
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
SniffMeet/SniffMeet/Source/UseCase/LocalNetworkUseCase/SendProfileUseCase.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,47 @@ | ||
// | ||
// SendProfileUseCase.swift | ||
// SniffMeet | ||
// | ||
// Created by Kelly Chui on 1/14/25. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol SendProfileUseCase { | ||
func execute() | ||
} | ||
|
||
struct SendProfileUseCaseImpl: SendProfileUseCase { | ||
let dataManager: DataLoadable | ||
let niManager: NIManager | ||
let encoder: JSONEncoder | ||
|
||
init( | ||
dataManager: DataLoadable, | ||
niManager: NIManager | ||
) { | ||
self.dataManager = dataManager | ||
self.niManager = niManager | ||
self.encoder = JSONEncoder() | ||
} | ||
|
||
func execute() { | ||
do { | ||
let dog = try dataManager.loadData(forKey: "dogInfo", type: UserInfo.self) | ||
guard let userID = SessionManager.shared.session?.user?.userID else { return } | ||
let dogProfileDTO = DogProfileDTO( | ||
id: userID, | ||
name: dog.name, | ||
keywords: dog.keywords, | ||
profileImage: dog.profileImage | ||
) | ||
let dataToSend = MPCProfileDropDTO(token: nil, profile: dogProfileDTO, transitionMessage: nil) | ||
let encodedData = try encoder.encode(dataToSend) | ||
niManager.mpcManager.sendData(data: encodedData) | ||
|
||
|
||
} catch { | ||
SNMLogger.error("loadData error : \(error)") | ||
} | ||
} | ||
} |