Created
March 2, 2019 14:52
-
-
Save Kmohamed/f0dfbd32cf60a99063ba2cbc4787c9f4 to your computer and use it in GitHub Desktop.
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
class NetworkLayerMock: Network { | |
private let mockedData: [[String:String]] | |
init(mockedData:[[String:String]]) { | |
self.mockedData = mockedData | |
} | |
override func executeGETRequest(api:String, completionBlock:@escaping (Data?) -> Void) { | |
let data = toJSONString(mockedData: self.mockedData) | |
completionBlock(data) | |
} | |
func toJSONString(mockedData:[[String:String]]?) -> Data? { | |
if let arr = mockedData { | |
let dat = try? JSONSerialization.data(withJSONObject: arr, options: .prettyPrinted) | |
return dat | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment