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
import Foundation | |
protocol ApiClient { | |
var rootUrl: String { get } | |
} |
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
import UIKit | |
class AppBaseApi { | |
// Properties, Initialization and helpers omited | |
public func get<Type, TransformerType>( | |
_ endpointUrl: String, | |
targetUrl: String, | |
responseTransformer: TransformerType, |
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
import Foundation | |
public protocol Transformer { | |
associatedtype T | |
associatedtype U | |
func transform(_ input: T) -> U | |
} |
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
import UIKit | |
class AnyObjectToRateTransformer: Transformer { | |
func transform(_ input: AnyObject?) -> Rates? { | |
guard let dict = input as? [String : AnyObject] else { return nil } | |
let base = dict["base"] as? String ?? "" | |
let date = dict["date"] as? String ?? "" |
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
import Foundation | |
import Quick | |
import Nimble | |
import OHHTTPStubs | |
@testable import SimpleNetworkLayer | |
class FixerApiSpec: QuickSpec { | |
override func spec() { | |
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
import Foundation | |
import Quick | |
import Nimble | |
@testable import SimpleNetworkLayer | |
class AnyObjectToRateTransformerSpec: QuickSpec { | |
override func spec() { | |
describe("Rates Transformer") { |
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
{ | |
"base": "EUR", | |
"date": "2017-06-23", | |
"rates": { | |
"AUD": 1.4764, | |
"BGN": 1.9558, | |
"BRL": 3.7293, | |
"CAD": 1.4783, | |
"CHF": 1.0851, | |
"CNY": 7.6413, |