Add parsing of the URL to view the pull request.

master
Tom Alexander 2 years ago
parent f46a5f8a9c
commit 51bbe22bdf
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -4,6 +4,7 @@ use crate::json_util::get_json_string;
pub struct PullRequestEvent<'a> {
original_event: &'a serde_json::Value,
pub action: &'a String,
pub html_url: &'a String,
}
impl<'a> PullRequestEvent<'a> {
@ -12,14 +13,23 @@ impl<'a> PullRequestEvent<'a> {
.get("payload")
.map(get_json_object)
.expect("Ran into a PullRequestEvent without a payload.");
let action = payload
let payload_action = payload
.get("action")
.map(get_json_string)
.expect("Ran into a PullRequestEvent without a payload.action.");
let payload_pull_request = payload
.get("pull_request")
.map(get_json_object)
.expect("Ran into a PullRequestEvent without a payload.pull_request.");
let payload_pull_request_html_url = payload_pull_request
.get("html_url")
.map(get_json_string)
.expect("Ran into a PullRequestEvent without a payload.pull_request.html_url.");
Ok(PullRequestEvent {
original_event,
action,
action: payload_action,
html_url: payload_pull_request_html_url,
})
}

Loading…
Cancel
Save