Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support of channel_shared event #217

Merged
merged 2 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.hubspot.slack.client.models.events.channel.SlackChannelCreatedEvent;
import com.hubspot.slack.client.models.events.channel.SlackChannelDeletedEvent;
import com.hubspot.slack.client.models.events.channel.SlackChannelRenameEvent;
import com.hubspot.slack.client.models.events.channel.SlackChannelSharedEvent;
import com.hubspot.slack.client.models.events.channel.SlackChannelUnarchiveEvent;
import com.hubspot.slack.client.models.events.group.SlackGroupArchiveEvent;
import com.hubspot.slack.client.models.events.group.SlackGroupDeletedEvent;
Expand All @@ -32,6 +33,7 @@ public enum SlackEventType {
CHANNEL_HISTORY_CHANGED,
CHANNEL_RENAME(SlackChannelRenameEvent.class),
CHANNEL_UNARCHIVE(SlackChannelUnarchiveEvent.class),
CHANNEL_SHARED(SlackChannelSharedEvent.class),
DND_UPDATED,
DND_UPDATED_USER,
EMAIL_DOMAIN_CHANGED,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.hubspot.slack.client.models.events.channel;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.hubspot.immutables.style.HubSpotStyle;
import com.hubspot.slack.client.models.events.conversation.SlackConversationEventCore;
import org.immutables.value.Value;

@Value.Immutable
@HubSpotStyle
@JsonNaming(SnakeCaseStrategy.class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct me if I'm wrong, but I think we don't need @JsonNaming(SnakeCaseStrategy.class) if we have @JsonProperty("connected_team_id") set for the field.

@JsonDeserialize(as = SlackChannelSharedEvent.class)
public interface SlackChannelSharedEventIF extends SlackConversationEventCore {
@JsonProperty("connected_team_id")
String getConnectedTeamId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ public void itCanDeserChannelArchivedEvent() throws IOException {
assertThat(event.getType()).isEqualTo(SlackEventType.CHANNEL_ARCHIVE);
}

@Test
public void itCanDeserChannelSharedEvent() throws IOException {
SlackEvent event = fetchAndDeserializeSlackEvent("channel_shared_event.json");
assertThat(event.getType()).isEqualTo(SlackEventType.CHANNEL_SHARED);

System.out.println(event);
}

@Test
public void itCanDeserChannelUnarchivedEvent() throws IOException {
SlackEvent event = fetchAndDeserializeSlackEvent("channel_unarchived_event.json");
Expand Down
17 changes: 17 additions & 0 deletions slack-base/src/test/resources/channel_shared_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"token": "uWopedqK86MJfjUeq8v9pUAD",
"team_id": "redacted",
"api_app_id": "redacted",
"event": {
"type": "channel_shared",
"connected_team_id": "E163Q94DX",
"channel": "C06EQBRR6",
"event_ts": "1561064063.001100"
},
"type": "event_callback",
"event_id": "EvCYA72LVA",
"event_time": 1537542788,
"authed_users": [
"UBRFHDFGA"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line, please.