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.
 
 
 
 

52 lines
1.2 KiB

//
// HotLineInteractor.swift
// GME Remit
//
// Created by InKwon Devik Kim on 23/05/2019.
//Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import Foundation
class HotLineInteractor {
// MARK: Properties
weak var output: HotLineInteractorOutput?
private let service: HotLineServiceType
// MARK: Initialization
init(service: HotLineServiceType) {
self.service = service
}
}
// MARK: HotLine interactor input interface
extension HotLineInteractor: HotLineInteractorInput {
func fetchHotLines() {
service.fetchHotLines(
success: {
// Base selected Language
// Base Native Country as lowercased
let userCountry = GMEDB.shared.user.string(.countryCode)?.lowercased()
guard
let userHotLine = $0?.filter({ $0.countryCode == userCountry }),
let anotherHotLines = $0?.filter ({ $0.countryCode != userCountry })
else {
self.output?.setHotLine(with: $0)
return
}
let restoredHotLines = userHotLine + anotherHotLines
self.output?.setHotLine(with: restoredHotLines)
},
failure: {
self.output?.setError(with: $0)
}
)
}
}