diff --git a/TrashCanKit/Repositories.swift b/TrashCanKit/Repositories.swift index bde9dc2..bf1d139 100644 --- a/TrashCanKit/Repositories.swift +++ b/TrashCanKit/Repositories.swift @@ -95,11 +95,4 @@ public enum RepositoryRouter: Router { return "/repositories/\(userName)" } } - - public var URLRequest: NSURLRequest? { - switch self { - case .ReadRepositories(_, _): - return request() - } - } } diff --git a/TrashCanKit/TrashCanKit.swift b/TrashCanKit/TrashCanKit.swift index 63bedfe..5c49720 100644 --- a/TrashCanKit/TrashCanKit.swift +++ b/TrashCanKit/TrashCanKit.swift @@ -12,3 +12,9 @@ public struct TrashCanKit { configuration = config } } + +internal extension Router { + internal var URLRequest: NSURLRequest? { + return request() + } +} diff --git a/TrashCanKit/User.swift b/TrashCanKit/User.swift index 93c4184..e8b25b1 100644 --- a/TrashCanKit/User.swift +++ b/TrashCanKit/User.swift @@ -71,13 +71,11 @@ public extension TrashCanKit { public enum UserRouter: Router { case ReadAuthenticatedUser(Configuration) - case ReadUser(String, Configuration) case ReadEmails(Configuration) public var configuration: Configuration { switch self { case .ReadAuthenticatedUser(let config): return config - case .ReadUser(_, let config): return config case .ReadEmails(let config): return config } } @@ -94,8 +92,6 @@ public enum UserRouter: Router { switch self { case .ReadAuthenticatedUser: return "user" - case .ReadUser(let username, _): - return "users/\(username)" case .ReadEmails: return "user/emails" } @@ -104,8 +100,4 @@ public enum UserRouter: Router { public var params: [String: String] { return [:] } - - public var URLRequest: NSURLRequest? { - return request() - } } diff --git a/TrashCanKitTests/UserTests.swift b/TrashCanKitTests/UserTests.swift index 2b1c662..1ef4eff 100644 --- a/TrashCanKitTests/UserTests.swift +++ b/TrashCanKitTests/UserTests.swift @@ -29,6 +29,14 @@ class UserTests: XCTestCase { XCTAssertEqual(subject.type, "email") } + func testConstructEmailFromEmptyJSON() { + let subject = Email(json: [:]) + XCTAssertEqual(subject.isPrimary, false) + XCTAssertEqual(subject.isConfirmed, false) + XCTAssertEqual(subject.email, nil) + XCTAssertEqual(subject.type, nil) + } + func testMe() { let tokenConfig = TokenConfiguration("123456", refreshToken: "7890") stubRequest("GET", "https://bitbucket.org/api/2.0/user?access_token=123456").andReturn(200).withBody(TestHelper.loadJSONString("Me"))