Пример #1
0
        public void GetTemplate()
        {
            //加载配置
            AppSecretConfigSection configSection = ConfigHelper.GetConfigSection <AppSecretConfigSection>(AppSecretConfigSection.SectionName);

            string appkey    = configSection.CaiNiao.AppKey;
            string appSecret = configSection.CaiNiao.AppSecret;
            string url       = configSection.CaiNiao.PacUrl;
            string token     = "";

            //测试
            //  token = "TmpFU1ZOUGoyRnoybDZmT3lyaW9hWGR4VFNad0xNYTBUek9QZk9kamt2Z1hJMytsVkVHK0FjVW55T25wcUR1Qw==";
            //正式
            token = "WkFhU2ZYdnA2dkFPd2MvVlR2OTF6K2FuQ1NKejdrV0V1ZDE3VS8zTW9uQjhLOGx5VHBuUkgyMzgrc3Q1RnRZNw==";
            //List<TemplateCompanyModel> lst = new TemplateCompanyService().GetTemplateCompanyElementsByCondition(d => d.ExCode != "OTHER");

            //foreach (TemplateCompanyModel m in lst)
            // {
            //    var client = new PacClient(appkey, appSecret, url);
            //    string jsonParas = "{\"cpCode\":\""+m.ExCode+"\"}";
            //    TmsWaybillSubscriptionQueryRequest parasModel = jsonParas.FromJsonToObject<TmsWaybillSubscriptionQueryRequest>();
            //    parasModel.SoapFormat = PacSupportFormat.XML;

            //    var resp = client.Send(parasModel, token);
            //    if (resp.Success && resp.WaybillApplySubscriptionCols[0].BranchAccountCols.Count > 0)
            //    {
            //        Assert.IsNotNull(resp);
            //    }
            // }

            var    client    = new PacClient(appkey, appSecret, url);
            string jsonParas = "{\"cpCode\":\"ZTO\"}";
            CloudprintStandardTemplatesRequest parasModel = jsonParas.FromJsonToObject <CloudprintStandardTemplatesRequest>();

            parasModel.SoapFormat = PacSupportFormat.JSON;

            var resp = client.Send(parasModel, token);

            if (resp.Success)
            {
                Assert.IsNotNull(resp);
            }
        }
Пример #2
0
        public void GetDianZiDanHaoTest()
        {
            //加载配置
            AppSecretConfigSection configSection = ConfigHelper.GetConfigSection <AppSecretConfigSection>(AppSecretConfigSection.SectionName);

            string appkey    = configSection.CaiNiao.AppKey;
            string appSecret = configSection.CaiNiao.AppSecret;
            string url       = configSection.CaiNiao.PacUrl;
            string token     = "TmpFU1ZOUGoyRnoybDZmT3lyaW9hWGR4VFNad0xNYTBUek9QZk9kamt2Z1hJMytsVkVHK0FjVW55T25wcUR1Qw==";

            //正式     WkFhU2ZYdnA2dkFPd2MvVlR2OTF6K2FuQ1NKejdrV0V1ZDE3VS8zTW9uQjhLOGx5VHBuUkgyMzgrc3Q1RnRZNw==
            token = "WkFhU2ZYdnA2dkFPd2MvVlR2OTF6K2FuQ1NKejdrV0V1ZDE3VS8zTW9uQjhLOGx5VHBuUkgyMzgrc3Q1RnRZNw==";
            var    client    = new PacClient(appkey, appSecret, url);
            string jsonParas = "{\"cpCode\":\"ZTO\"}";
            TmsWaybillSubscriptionQueryRequest parasModel = jsonParas.FromJsonToObject <TmsWaybillSubscriptionQueryRequest>();

            parasModel.SoapFormat = PacSupportFormat.JSON;

            var resp = client.Send(parasModel, token);

            Assert.IsNotNull(resp);
        }
Пример #3
0
        public CaiNiaoPacService(IOptions <CaiNiaoPacOptions> options)
        {
            _options = options;

            client = new PacClient(_options.Value.AppKey, _options.Value.AppSecret, _options.Value.PacUrl);
        }