-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull Request service and issue comment webhook
- Loading branch information
1 parent
7975653
commit 9964081
Showing
6 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Sources/Swoctokit/Repository/PullRequests/RepositoryPullRequestService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swoctokit open source project | ||
// | ||
// Copyright (c) 2018 e-Sixt | ||
// Licensed under MIT | ||
// | ||
// See LICENSE.txt for license information | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Vapor | ||
|
||
public class RepositoryPullRequestService { | ||
|
||
private let token: String | ||
private let client: Client | ||
|
||
init(token: String, client: Client) { | ||
self.token = token | ||
self.client = client | ||
} | ||
|
||
public func getPullRequest(owner: String, repository: String, number: Int) -> Future<PullRequest> { | ||
let url = "\(Constants.GitHubBaseURL)/repos/\(owner)/\(repository)/pulls/\(number)" | ||
|
||
return client.get(url, headers: HTTPHeaders([("Authorization", "token \(token)")])).flatMap { response in | ||
if let error = try? response.content.syncDecode(GitHubAPIErrorResponse.self) { | ||
throw error | ||
} | ||
|
||
return try response.content.decode(PullRequest.self) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// IssueCommentEvent.swift | ||
// Swoctokit | ||
// | ||
// Created by Franz Busch on 14.11.18. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct IssueCommentEvent: Decodable, WebhookEvent { | ||
|
||
public let action: String | ||
public let issue: Issue | ||
|
||
} | ||
|
||
public struct Issue: Decodable { | ||
|
||
let number: Int | ||
|
||
} | ||
|
||
public struct IssueComment: Decodable { | ||
|
||
public let id: Int | ||
public let url: String | ||
public let body: String | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters