Skip to content

Commit fdadb18

Browse files
authored
Add headers to WebhookResponse class (#1043)
1 parent 7905c24 commit fdadb18

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

slack-api-client/src/main/java/com/slack/api/Slack.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public WebhookResponse send(String url, Payload payload) throws IOException {
128128
return WebhookResponse.builder()
129129
.code(httpResponse.code())
130130
.message(httpResponse.message())
131+
.headers(httpResponse.headers().toMultimap())
131132
.body(body)
132133
.build();
133134
}
@@ -144,6 +145,7 @@ public WebhookResponse send(String url, String payload) throws IOException {
144145
return WebhookResponse.builder()
145146
.code(httpResponse.code())
146147
.message(httpResponse.message())
148+
.headers(httpResponse.headers().toMultimap())
147149
.body(body)
148150
.build();
149151
}

slack-api-client/src/test/java/test_with_remote_apis/IncomingWebhooksTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static org.hamcrest.CoreMatchers.is;
2727
import static org.hamcrest.CoreMatchers.nullValue;
2828
import static org.hamcrest.MatcherAssert.assertThat;
29+
import static org.hamcrest.Matchers.greaterThan;
2930

3031
@Slf4j
3132
public class IncomingWebhooksTest {
@@ -291,4 +292,12 @@ public void testInvalidBlocksError() throws Exception {
291292
assertThat(response.getBody(), is("invalid_blocks"));
292293
assertThat(response.getCode(), is(400));
293294
}
295+
296+
@Test
297+
public void headers() throws IOException {
298+
WebhookResponse response = slack.send(url, Payload.builder().text("Hello world!").build());
299+
assertThat(response.getBody(), is("ok"));
300+
assertThat(response.getCode(), is(200));
301+
assertThat(response.getHeaders().size(),is(greaterThan(0)));
302+
}
294303
}

slack-api-model/src/main/java/com/slack/api/webhook/WebhookResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
import lombok.Builder;
44
import lombok.Data;
55

6+
import java.util.List;
7+
import java.util.Map;
8+
69
@Data
710
@Builder
811
public class WebhookResponse {
912
private Integer code;
1013
private String message;
14+
private Map<String, List<String>> headers;
1115
private String body;
1216
}

0 commit comments

Comments
 (0)