package cn.axzo.msg.center.service.pending.card;

import cn.axzo.msg.center.service.pending.request.CardPresetButtonPressedRequest;
import cn.axzo.msg.center.service.pending.request.CardSendRequest;
import cn.axzo.msg.center.service.pending.request.CardUpdateStateRequest;
import cn.axzo.msg.center.service.pending.request.SetActionPerformedRequest;
import cn.axzo.msg.center.service.pending.response.CardSendResponse;
import cn.azxo.framework.common.model.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;

/**
 * @author yanglin
 */
@Component
@FeignClient(value = "msg-center", url = "${server.serviceUrl:http://msg-center:8080}")
public interface CardClient {

    /**
     * 发送卡片
     */
    @PostMapping(value = "/api/card/send",
            produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<CardSendResponse> send(
            @RequestBody @Valid CardSendRequest request);

    /**
     * 更新卡片状态
     */
    @PostMapping(value = "/api/card/updateState",
            produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> updateState(
            @RequestBody @Valid CardUpdateStateRequest request);

    /**
     * 设置按钮失效, 且卡片状态设置为已经完成
     */
    @PostMapping(value = "/api/card/setActionPerformed",
            produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> setActionPerformed(
            @RequestBody @Valid SetActionPerformedRequest request);

    /**
     * 点击预设按钮
     */
    @PostMapping(value = "/api/card/firePresetButtonPressed",
            produces = {MediaType.APPLICATION_JSON_VALUE})
    CommonResponse<Void> firePresetButtonPressed(
            @RequestBody @Valid CardPresetButtonPressedRequest request);

}