예제 #1
0
        /**
         * <h1>取模板</h1>
         *
         * <p>
         * 参数名 类型 是否必须 描述 示例
         * </p>
         * <p>
         * apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
         * </p>
         * <p>
         * tpl_id Long 否 模板id,64位长整形。指定id时返回id对应的 模板。未指定时返回所有模板 1
         * </p>
         *
         * @param param
         *            tpl_id
         * @return
         */
        public Result <List <Template> > Get(Dictionary <string, string> param)
        {
            var r = new Result <List <Template> >();

            r = CheckParam(ref param, r, Const.Apikey);

            if (!r.IsSucc())
            {
                return(r);
            }
            var data = UrlEncode(ref param);

            var h = new ListMapResultHandler <Template>(Version, rsp =>
            {
                if (rsp != null)
                {
                    switch (Version)
                    {
                    case Const.VersionV1:
                        {
                            if (rsp is JObject)
                            {
                                var tpl = rsp[Const.Template];
                                return(tpl.GetType().IsArray
                                    ? tpl.ToObject <List <Template> >()
                                    : new List <Template> {
                                    tpl.ToObject <Template>()
                                });
                            }

                            break;
                        }

                    case Const.VersionV2:
                        {
                            var list = new List <Template> {
                                rsp.ToObject <Template>()
                            };
                            return(list);
                        }
                    }
                }

                return(new List <Template>());
            });

            try
            {
                Path = "get.json";
                return(Post(ref data, h, r));
            }
            catch (Exception e)
            {
                return(h.CatchExceptoin(e, r));
            }
        }
예제 #2
0
        /**
         * <h1>获取状态报告</h1>
         *
         * <p>
         * 参数名 是否必须 描述 示例
         * </p>
         * <p>
         * apikey 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
         * </p>
         * <p>
         * page_size 否 每页个数,最大100个,默认20个 20
         * </p>
         * <p>
         * type Integer 否 拉取类型,1-语音验证码 2-语音通知,默认type=1 1
         * </p>
         *
         * @param param
         * @return
         */
        public Result <List <VoiceStatus> > PullStatus(Dictionary <string, string> param)
        {
            var r = new Result <List <VoiceStatus> >();

            r = CheckParam(ref param, r, Const.Apikey);

            if (!r.IsSucc())
            {
                return(r);
            }
            var data = UrlEncode(ref param);

            var h = new ListMapResultHandler <VoiceStatus>(Version, rsp =>
            {
                switch (Version)
                {
                case Const.VersionV1:
                    {
                        return(rsp is JObject
                            ? rsp[Const.VoiceStatus].ToObject <List <VoiceStatus> >()
                            : new List <VoiceStatus>());
                    }

                case Const.VersionV2:
                    {
                        return(rsp.ToObject <List <VoiceStatus> >());
                    }

                default: return(new List <VoiceStatus>());
                }
            });

            try
            {
                Path = "pull_status.json";
                return(Post(ref data, h, r));
            }
            catch (Exception e)
            {
                return(h.CatchExceptoin(e, r));
            }
        }
예제 #3
0
        /**
         * <h1>查短信发送记录</h1>
         *
         * <p>
         * 参数名 类型 是否必须 描述 示例
         * </p>
         * <p>
         * apikey String 是 用户唯一标识 9b11127a9701975c734b8aee81ee3526
         * </p>
         * <p>
         * mobile String 否 需要查询的手机号 15205201314
         * </p>
         * <p>
         * start_time String 是 短信发送开始时间 2013-08-11 00:00:00
         * </p>
         * <p>
         * end_time String 是 短信发送结束时间 2013-08-12 00:00:00
         * </p>
         * <p>
         * page_num Integer 否 页码,默认值为1 1
         * </p>
         * <p>
         * page_size Integer 否 每页个数,最大100个 20
         * </p>
         *
         * @param param
         * @return
         */
        public Result <List <SmsRecord> > GetRecord(Dictionary <string, string> param)
        {
            var r = new Result <List <SmsRecord> >();

            r = CheckParam(ref param, r, Const.Apikey, Const.StartTime, Const.EndTime);

            if (!r.IsSucc())
            {
                return(r);
            }
            var data = UrlEncode(ref param);

            var h = new ListMapResultHandler <SmsRecord>(Version, rsp =>
            {
                switch (Version)
                {
                case Const.VersionV1:
                    {
                        return(rsp is JObject
                            ? rsp[Const.Sms].ToObject <List <SmsRecord> >()
                            : new List <SmsRecord>());
                    }

                case Const.VersionV2:
                    {
                        return(rsp.ToObject <List <SmsRecord> >());
                    }

                default: return(new List <SmsRecord>());
                }
            });

            try
            {
                Path = "get_record.json";
                return(Post(ref data, h, r));
            }
            catch (Exception e)
            {
                return(h.CatchExceptoin(e, r));
            }
        }