package com.adx.tracking.storage.mapper;

import com.adx.tracking.storage.model.MediaCallbackRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface MediaCallbackMapper {

    void insert(@Param("dedupeKey") String dedupeKey,
                @Param("media") String media,
                @Param("qk") String qk,
                @Param("callbackUrl") String callbackUrl,
                @Param("eventType") int eventType,
                @Param("eventTimeMs") long eventTimeMs,
                @Param("purchase") double purchase,
                @Param("status") int status,
                @Param("ok") int ok,
                @Param("attempt") int attempt,
                @Param("responseBody") String responseBody,
                @Param("errorMessage") String errorMessage,
                @Param("createdAt") java.sql.Timestamp createdAt);

    int countSuccessfulByDedupeKey(@Param("dedupeKey") String dedupeKey);

    int countSuccessfulForEvent(@Param("dedupeKey") String dedupeKey,
                                @Param("legacyDedupeKey") String legacyDedupeKey,
                                @Param("eventType") int eventType);

    List<MediaCallbackRecord> selectPendingCallbacks(@Param("media") String media,
                                                     @Param("limit") int limit);
}
