package com.ssj.conch.easemob.impl;

import org.springframework.stereotype.Service;

import com.ssj.conch.easemob.SendMessageAPI;
import com.ssj.conch.easemob.util.EasemobAPI;
import com.ssj.conch.easemob.util.OrgInfo;
import com.ssj.conch.easemob.util.ResponseHandler;
import com.ssj.conch.easemob.util.TokenUtil;

import io.swagger.client.ApiException;
import io.swagger.client.api.MessagesApi;
import io.swagger.client.model.Msg;
@Service
public class EasemobSendMessage implements SendMessageAPI {
    private ResponseHandler responseHandler = new ResponseHandler();
    private MessagesApi api = new MessagesApi();
    @Override
    public Object sendMessage(final Object payload) {
        return responseHandler.handle(new EasemobAPI() {
            @Override
            public Object invokeEasemobAPI() throws ApiException {
                return api.orgNameAppNameMessagesPost(OrgInfo.ORG_NAME,OrgInfo.APP_NAME,TokenUtil.getAccessToken(), (Msg) payload);
            }
        });
    }
}
