Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class PaymentsModuleRouter: ModuleRouter {
lazy var interactor = PaymentInteractor()
internal var route: String
required init(route: String) {
self.route = route
func route(parameters: ModuleParameters?,
path: String?,
callback: ModuleCallback?) {
switch path {
case "/pay": parameters) { (urlResponse, error) in
callback?(nil, nil, urlResponse, error)
class PaymentInteractor {
func pay(parameters: ModuleParameters?,
completion: @escaping (HTTPURLResponse?, Error?) -> Void) {
let service = MockPaymentsNetworkService()
guard let parameters = parameters,
let token = parameters[PaymentsModuleParameters.token.rawValue],
let amount = parameters[PaymentsModuleParameters.amount.rawValue] else {
let payParameters = [PaymentsModuleParameters.token.rawValue: token,
PaymentsModuleParameters.amount.rawValue: amount] "payments",
path: "/pay",
parameters: payParameters) { (response, urlResponse, error) in
// We are not going to check errors and URL response status codes, just a shortest path.
var networkError: ResponseError? = nil
if let error = error {
networkError = ResponseError(error: error, response: urlResponse)
completion(urlResponse, networkError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.