Ejemplo n.º 1
0
        /// <summary>
        /// 上传这个App的相关捆。
        /// </summary>
        /// <param name="model">上传捆模型。</param>
        public void UploadApp(UploadBundleModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            var key   = model.Key;
            var bytes = model.Bytes;
            var url   = model.Url;
            var token = model.Token;

            using (var webClient = WebClientHelper.GetWebClient())
            {
                var createBytes = new CreateBytes();
                var arrayList   = new ArrayList
                {
                    createBytes.CreateFieldData("key", key),
                    createBytes.CreateFieldData("token", token),
                    createBytes.CreateFieldData("file", "App.ipa", "application/octet-stream", bytes)
                };
                webClient.Headers.Add("Content-Type", createBytes.ContentType);
                var data   = createBytes.JoinBytes(arrayList);
                var bytes2 = webClient.UploadData(url, data);
                Console.WriteLine(Encoding.UTF8.GetString(bytes2));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 删除这个App。
 /// </summary>
 public void Delete()
 {
     using (var webClient = WebClientHelper.GetWebClient())
     {
         var address = string.Format("http://fir.im/api/v2/app/{0}?token={1}", _appToken, _userToken);
         var bytes   = webClient.UploadData(address, "DELETE", new byte[0]);
         Console.WriteLine(Encoding.UTF8.GetString(bytes));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 获取所有版本信息。
 /// </summary>
 /// <returns>版本信息数组。</returns>
 public AppVersionModel[] GetAllVersions()
 {
     AppVersionModel[] result;
     using (var webClient = WebClientHelper.GetWebClient())
     {
         var content = Encoding.UTF8.GetString(webClient.DownloadData(string.Format("http://fir.im/api/v2/app/{0}/versions?token={1}", _appToken, _userToken)));
         result = JsonConvert.DeserializeObject <AppVersionModel[]>(content);
     }
     return(result);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 创建或获取一个App象征。
        /// </summary>
        /// <param name="appId">App标识。</param>
        /// <param name="platform">App平台。</param>
        /// <returns>App象征模型。</returns>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="appId" /> 为空。</exception>
        public AppTokenModel CreateOrGetApp(string appId, PlatformType?platform = null)
        {
            if (string.IsNullOrWhiteSpace(appId))
            {
                throw new ArgumentNullException("appId");
            }
            var           arg = (platform.HasValue ? platform.ToString() : PlatformType.Ios.ToString()).ToLower();
            AppTokenModel result;

            using (var webClient = WebClientHelper.GetWebClient())
            {
                var text = webClient.DownloadString(string.Format("http://fir.im/api/v2/app/info/{0}?token={1}&type={2}", appId, _userId, arg));
                result = JsonConvert.DeserializeObject <AppTokenModel>(text);
            }
            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新这个App的信息。
        /// </summary>
        /// <param name="model">更新App模型。</param>
        public void UpdateInfo(UpdateAppModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            var text = model.ToString();

            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }
            using (var webClient = WebClientHelper.GetWebClient())
            {
                webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
                var address = string.Format("http://fir.im/api/v2/app/{0}?token={1}", _appToken, _userToken);
                var bytes   = webClient.UploadData(address, "PUT", Encoding.UTF8.GetBytes(text));
                Console.WriteLine(Encoding.UTF8.GetString(bytes));
            }
        }