You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
// // RecipientsInteractor.swift // GME Remit // // Created by InKwon James Kim on 08/08/2019. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. //
import Foundation
class RecipientsInteractor { // MARK: Properties weak var output: RecipientsInteractorOutput? private let service: RecipientsServiceType private var recipients: [Recipient]? // MARK: Initialization init(service: RecipientsServiceType) { self.service = service } }
// MARK: Recipients interactor input interface
extension RecipientsInteractor: RecipientsInteractorInput { func fetchRecipients(isRefresh: Bool) { if isRefresh { fetchRecipients() return } guard let recipients = self.recipients else { fetchRecipients() return } output?.setRecipients(using: recipients) } func deleteRecipient(who recipient: Recipient) { let myUsername = GMEDB.shared.user.string(.userId) ?? "" service.deleteRecipient( username: myUsername, reciepient: recipient, success: { self.fetchRecipients(isRefresh: true) }, failure: {self.output?.setError(with: $0)} ) } private func fetchRecipients() { service.fetchRecipients( success: { self.recipients = $0.recipients self.output?.setRecipients(using: $0.recipients ?? []) }, failure: { self.output?.setError(with:$0) } ) } }
|