Пример #1
0
        /// <summary>
        /// Get the experiment having the specified id in background.
        /// </summary>
        /// <remarks>
        /// NOTE: This api access to server. Should not be executed in UI/Main thread.
        /// </remarks>
        /// <returns>Experiment which has the specified id.</returns>
        /// <param name="experimentID">Experiment id.</param>
        /// <param name="callback">Called on completion of get experiment.</param>
        public static void GetByID(String experimentID, KiiExperimentCallback callback)
        {
            if (!IsValidExperimentID(experimentID))
            {
                callback(null, new ArgumentException("Experiment id is invalid"));
                return;
            }
            Utils.CheckInitialize(false);
            string        getUrl = Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "buckets", "_experiments", "objects", experimentID);
            KiiHttpClient client = Kii.AsyncHttpClientFactory.Create(getUrl, Kii.AppId, Kii.AppKey, KiiHttpMethod.GET);

            KiiCloudEngine.SetAuthBearer(client);
            client.SendRequest((ApiResponse response, Exception e) =>
            {
                if (e != null)
                {
                    callback(null, e);
                    return;
                }
                else
                {
                    try
                    {
                        KiiExperiment kiiExperiment = CreateFromResponse(response);
                        callback(kiiExperiment, null);
                    }
                    catch (Exception ex)
                    {
                        callback(null, ex);
                    }
                }
            });
        }
Пример #2
0
        /// <summary>
        /// Get the experiment which has the specified id.
        /// </summary>
        /// <remarks>
        /// NOTE: This api access to server. Should not be executed in UI/Main thread.
        /// </remarks>
        /// <returns>Experiment which has the specified id.</returns>
        /// <param name="experimentID">Experiment id.</param>
        public static KiiExperiment GetByID(String experimentID)
        {
            if (!IsValidExperimentID(experimentID))
            {
                throw new ArgumentException("Experiment id is invalid");
            }
            Utils.CheckInitialize(false);
            string        getUrl = Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "buckets", "_experiments", "objects", experimentID);
            KiiHttpClient client = Kii.HttpClientFactory.Create(getUrl, Kii.AppId, Kii.AppKey, KiiHttpMethod.GET);

            KiiCloudEngine.SetAuthBearer(client);
            ApiResponse response = client.SendRequest();

            return(CreateFromResponse(response));
        }