     }
 }
 
+//: Step 4: Define requet type in API class
+extension GitHubAPI {
+    enum Errors: ErrorType {
+        case UnexpectedJSONStructure
+    }
+
+    // https://developer.github.com/v3/rate_limit/
+    struct GetRateLimit: GitHubRequest {
+        typealias Response = RateLimit
+
+        var method: HTTPMethod {
+            return .GET
+        }
+
+        var path: String {
+            return "/rate_limit"
+        }
+
+        func responseFromObject(object: AnyObject, URLResponse: NSHTTPURLResponse) throws -> Response {
+            guard let dictionary = object as? [String: AnyObject] else {
+                throw Errors.UnexpectedJSONStructure
+            }
+
+            guard let rateLimit = RateLimit(dictionary: dictionary) else {
+                throw Errors.UnexpectedJSONStructure
+            }
+
+            return rateLimit
+        }
+    }
+}
+
+//: Step 5: Send request
+let request = GitHubAPI.GetRateLimit()
+
+GitHubAPI.sendRequest(request) { result in
+    switch result {
+    case .Success(let rateLimit):
+        "count: \(rateLimit.count)"
+        "reset: \(rateLimit.resetDate)"
+
+    case .Failure(let error):
+        "error: \(error)"
+    }
+}
+

    }
}

/// Defining API class
class GitHubAPI: API {
    enum Errors: ErrorType {
        case Some
    }

    // https://developer.github.com/v3/rate_limit/
    struct GetRateLimit: GitHubRequest {
        typealias Response = RateLimit

        var method: HTTPMethod {
            return .GET
        }

        var path: String {
            return "/rate_limit"
        }

        func responseFromObject(object: AnyObject, URLResponse: NSHTTPURLResponse) throws -> Response {
            guard let dictionary = object as? [String: AnyObject] else {
                throw Errors.Some
            }

            guard let rateLimit = RateLimit(dictionary: dictionary) else {
                throw Errors.Some
            }

            return rateLimit
        }
    }
}

/// Model object
struct RateLimit {
    let count: Int
    let resetDate: NSDate


XCPSetExecutionShouldContinueIndefinitely()

//: Step 1: Define request protocol
protocol GitHubRequest: Request {

}
