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

import cn.axzo.msg.center.service.pending.card.CardClient;
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.response.CardSendResponse;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yanglin
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class CardController implements CardClient {

    private final CardManager cardManager;

    @Override
    public CommonResponse<CardSendResponse> send(CardSendRequest request) {
        log.info("CardController.send req={}", request);
        return CommonResponse.success(cardManager.send(request));
    }

    @Override
    public CommonResponse<Void> updateState(CardUpdateStateRequest request) {
        log.info("CardController.updateState req={}", request);
        cardManager.updateState(request);
        return CommonResponse.success();
    }

    @Override
    public CommonResponse<Void>
    firePresetButtonPressed(CardPresetButtonPressedRequest request) {
        log.info("CardController.firePresetButtonPressed req={}", request);
        cardManager.firePresetButtonPressed(request);
        return CommonResponse.success();
    }

}