package cn.pluss.platform.util;


import com.google.common.collect.Sets;
import mob.push.api.client.push.PushV3Client;
import mob.push.api.config.MobPushConfig;
import mob.push.api.http.Result;
import mob.push.api.model.IosNotify;
import mob.push.api.model.Push;
import mob.push.api.model.PushNotify;
import mob.push.api.model.PushTarget;
import mob.push.api.res.PushV3Res;
import org.apache.commons.collections.SetUtils;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * mob 推送工具类
 */
public class MobPushClient {

    private static final String APP_KEY = "30db41bafd252";

    private static final String APP_SECRET = "5fc6143d7c4462c8d67650e94698554f";


    public static boolean pushMsg(){
        MobPushConfig.appkey = APP_KEY;
        MobPushConfig.appSecret = APP_SECRET;
        PushNotify notify = new PushNotify();
        notify.setIosProduction(0);
        notify.setPlats(Sets.newHashSet(2));
        notify.setContent("收银呗到账100022.00元");
        notify.setType(1);
        Push push = new Push();
        push.setPushNotify(notify);
        PushTarget pushTarget = new PushTarget();
//        Set<String> rids = new HashSet<String>();
//        rids.add("65kyb6mmvuxvaio");
        pushTarget.setAlias(Sets.newHashSet("1791"));

        notify.setIosNotify(new IosNotify() {{
            setMutableContent(1);
        }});

        pushTarget.setTarget(2);
        push.setPushTarget(pushTarget);
        Result<PushV3Res> pushV3ResResult = PushV3Client.pushTaskV3(push);
        System.out.println(DateUtils.formatDateDefault(new Date(), "yyyy-MM-dd HH:mm:ss"));
        //Result<PushV3Res> result = PushV3Client.pushByRids(null,"收银呗到账","收银呗到账1000.00元","65kyb6mmvuxvaio");
        System.out.println(pushV3ResResult);
        return true;
    }

    public static void main(String[] args) {
        pushMsg();
    }
}
