示例#1
0
        //POST https://api.jpush.cn/v3/schedules
        //创建一个新的定时任务。
        public ScheduleResult sendSchedule(SchedulePayload schedulepayload)
        {
            Preconditions.checkArgument(schedulepayload != null, "schedulepayload should not be empty");
            schedulepayload.Check();
            String schedulepayloadJson = schedulepayload.ToJson();

            Console.WriteLine(schedulepayloadJson);
            return(sendSchedule(schedulepayloadJson));
        }
示例#2
0
        //获取指定的定时任务
        //GET https://api.jpush.cn/v3/schedules/{schedule_id}

        public SchedulePayload getScheduleById(String id)
        {
            Preconditions.checkArgument(!String.IsNullOrEmpty(id), "id should be set.");
            jSetting = new JsonSerializerSettings();
            jSetting.NullValueHandling    = NullValueHandling.Ignore;
            jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
            String url = HOST_NAME_SSL;

            url += PUSH_PATH;
            url += "/";
            url += id;
            ResponseWrapper result = sendGet(url, Authorization(), id);

            String          schedule        = result.responseContent;
            SchedulePayload schedulepayload = JsonConvert.DeserializeObject <SchedulePayload>(schedule, jSetting);

            return(schedulepayload);
        }
示例#3
0
        //PUT  https://api.jpush.cn/v3/schedules/{schedule_id}
        //修改指定的Schedule
        public ScheduleResult putSchedule(SchedulePayload schedulepayload, String schedule_id)
        {
            Preconditions.checkArgument(schedulepayload != null, "schedulepayload should not be empty");
            Preconditions.checkArgument(schedule_id != null, "schedule_id should not be empty");

            if (schedulepayload.push.audience == null || schedulepayload.push.platform == null)
            {
                schedulepayload.push = null;
            }

            if (schedulepayload.trigger.getTime() == null && schedulepayload.trigger.getSingleTime() == null)
            {
                schedulepayload.trigger = null;
            }

            String schedulepayloadJson = schedulepayload.ToJson();

            Console.WriteLine(schedulepayloadJson);
            return(putSchedule(schedulepayloadJson, schedule_id));
        }