sendbird / sendbird-platform-sdk-java

Sendbird Platform SDK for Java
MIT License
8 stars 6 forks source link

Update to 1.0.20 #22

Closed luke-cha closed 10 months ago

luke-cha commented 10 months ago

. Add a target_message_id to /v3/bots/{bot_userid}/send

Tested with

package org;

import org.openapitools.client.model.*;
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.api.BotApi;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

class AppTest {
    public static void main(String[] args) throws ApiException {
        // Default Setup
        String apiToken = ""; //Your Api Token
        String appId = ""; //Your App ID
        String channelUrl = "";
        String botId = "";
        long messageId = -1L;

        ApiClient sbClient = Configuration.getDefaultApiClient().addDefaultHeader("Api-Token", apiToken);
        sbClient.setBasePath("https://api-"+ appId +".sendbird.com");

        BotApi botApi = new BotApi(sbClient);

        SendBotSMessageData request = new SendBotSMessageData();
        request.setChannelUrl(channelUrl);
        request.setMessage("test message");
        request.setTargetMessageId(messageId);

        // Extended Message Payload setup
        SendBotSMessageDataExtendedMessagePayload extendedMessagePayload = new SendBotSMessageDataExtendedMessagePayload();

        List<String> suggestedReplies = new ArrayList<>();
        suggestedReplies.add("Yes");
        suggestedReplies.add("No");

        Map<String, Object> customView = new HashMap<>();
        customView.put("title", "title");
        customView.put("image", "https://link.to/image.jpg");

        extendedMessagePayload.setCustomView(customView);
        extendedMessagePayload.setSuggestedReplies(suggestedReplies);

        request.setExtendedMessagePayload(extendedMessagePayload);

        SendBirdBotsMessageResponse response = botApi.sendBotsMessage(botId)
                .sendBotSMessageData(request)
                .execute();
        System.out.println(response.toString());

    }
}