mattermost-java-sdk.1.2.source-code.Testing Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mattermost-java-sdk Show documentation
Show all versions of mattermost-java-sdk Show documentation
Connects java to a Mattermost API
import com.jrodmanu.mattermostjavasdk.MattermostClient;
import com.jrodmanu.mattermostjavasdk.models.common.Channel;
import com.jrodmanu.mattermostjavasdk.models.exceptions.MattermostException;
import com.jrodmanu.mattermostjavasdk.models.parameters.CreateChannelParams;
import com.jrodmanu.mattermostjavasdk.models.parameters.CreatePostParams;
import com.jrodmanu.mattermostjavasdk.models.common.Post;
public class Testing {
public static void main(String[] args) {
try {
MattermostClient client = new MattermostClient.Builder("https://mattermost.winwholesale.com/api/v4")
.setAccessToken("ntwtzcioptn79c3hga3hkq4e6r")
.setDefaultTeam("winsupply")
.build();
Channel channel = client.channels.createChannel(
new CreateChannelParams.Builder("jaredss-party", "jared's party", "O").build()
);
Post post = client.posts.createPost(
new CreatePostParams.Builder("There is no need to be afraid")
.setChannelId(channel.id)
.build()
);
} catch (MattermostException e) {
e.printStackTrace();
}
}
}