Demo entry 6356524

test

   

Submitted by anonymous on Apr 19, 2017 at 03:30
Language: Swift. Code size: 710 Bytes.

protocol APIRequestProtocol {
    var baseUrl: String { get }
    var query: String { get }
 
    func request() -> Any
}
 
class UsersAPIRequest: APIRequestProtocol {
 
    var baseUrl: String {
        return "my_baseUrl"
    }
 
    var query: String {
        return "?get=users"
    }
 
    func request() -> Any {
        let url = baseUrl + query
        // send api request to url
    }
}
 
class GroupsAPIRequest: APIRequestProtocol {
 
    var baseUrl: String {
        return "my_baseUrl"
    }
 
    var query: String {
        return "?get=groups"
    }
 
    func request() -> Any {
        let url = baseUrl + query
        // send api request to url
    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).