From 291b58a19dbbdbcfbf3b43e66c04fcd627feec92 Mon Sep 17 00:00:00 2001 From: pmmlo Date: Tue, 20 Jul 2021 22:33:31 -0700 Subject: [PATCH] Add delete overload func and protocol to allow file delete - API current returns a content/file and commit objects. --- Sources/GitHubKit/GitHub.swift | 5 +++++ Sources/GitHubKit/GitHubClient.swift | 1 + 2 files changed, 6 insertions(+) diff --git a/Sources/GitHubKit/GitHub.swift b/Sources/GitHubKit/GitHub.swift index ade26a5..aa85173 100644 --- a/Sources/GitHubKit/GitHub.swift +++ b/Sources/GitHubKit/GitHub.swift @@ -156,6 +156,11 @@ extension GitHub { return self.eventLoop.makeSucceededFuture(Void()) } } + + /// Delete a file + public func delete(path: String, post: E) throws -> EventLoopFuture where C: Decodable, E: Encodable { + return try send(method: .DELETE, path: path, post: post) + } /// Retrieve a file public func get(file path: String) throws -> EventLoopFuture { diff --git a/Sources/GitHubKit/GitHubClient.swift b/Sources/GitHubKit/GitHubClient.swift index c80ef92..47e0266 100644 --- a/Sources/GitHubKit/GitHubClient.swift +++ b/Sources/GitHubKit/GitHubClient.swift @@ -10,6 +10,7 @@ public protocol GitHubClient { func put(path: String, post: E) throws -> EventLoopFuture where C: Decodable, E: Encodable func patch(path: String, post: E) throws -> EventLoopFuture where C: Decodable, E: Encodable func delete(path: String) throws -> EventLoopFuture + func delete(path: String, post: E) throws -> EventLoopFuture where C: Decodable, E: Encodable func get(file path: String) throws -> EventLoopFuture func redirect(file path: String, status: HTTPResponseStatus) throws -> EventLoopFuture func download(org: String, repo: String, ref: String, format: GitHub.Format) throws -> EventLoopFuture