(&self, event: &str, pl: &T)
| 128 | } |
| 129 | |
| 130 | async fn post_event<T>(&self, event: &str, pl: &T) -> Result<()> |
| 131 | where |
| 132 | T: ?Sized + Serialize, |
| 133 | { |
| 134 | let (integration_url, integration_token) = self.parse_token()?; |
| 135 | let b = serde_json::to_vec(pl)?; |
| 136 | |
| 137 | info!(event = %event, url = %integration_url, "Posting event"); |
| 138 | |
| 139 | let mut headers = HeaderMap::new(); |
| 140 | headers.insert(CONTENT_TYPE, "application/json".parse().unwrap()); |
| 141 | headers.insert( |
| 142 | AUTHORIZATION, |
| 143 | format!("Bearer {}", integration_token).parse().unwrap(), |
| 144 | ); |
| 145 | |
| 146 | get_client() |
| 147 | .post(&integration_url) |
| 148 | .body(b.to_vec()) |
| 149 | .query(&[("event", event)]) |
| 150 | .headers(headers) |
| 151 | .send() |
| 152 | .await? |
| 153 | .error_for_status()?; |
| 154 | |
| 155 | Ok(()) |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | #[async_trait] |
no test coverage detected