Esempio n. 1
0
 public static string GetContainerName(MediaObjectType type)
 {
     return StorageContainerType.ContainsKey(type) ? StorageContainerType[type] : string.Empty;
 }
Esempio n. 2
0
        /// <summary>
        /// Gets the programs list specified by a couple of optional parameters.
        /// </summary>
        /// <param name="onComplete">On complete.</param>
        /// <param name="offset">Offset.</param>
        /// <param name="limit">Limit.</param>
        /// <param name="categoryKey">Category key.</param>
        /// <param name="programType">Program type.</param>
        /// <param name="mediaObjectType">Media object type.</param>
        public static void GetProgramsList(System.Action <IList <ProgramData> > onComplete, int offset = 0, int limit = 10, string categoryKey = null, ProgramType programType = ProgramType.all, MediaObjectType mediaObjectType = MediaObjectType.all)
        {
            if (!Initialized)
            {
                if (onComplete != null)
                {
                    onComplete(null);
                }

                return;
            }

            string formattedURL = RequestBuilder.AddParametersToURL(programsEndpoint, new Dictionary <string, string>()
            {
                { "offset", offset.ToString() },
                { "limit", limit.ToString() }
            });

            string categoryID = GetCategoryCode(categoryKey);

            if (!string.IsNullOrEmpty(categoryID))
            {
                formattedURL = RequestBuilder.AddParameterToURL(formattedURL, "category", System.Uri.EscapeDataString(categoryID));
            }

            if (programType != ProgramType.all)
            {
                formattedURL = RequestBuilder.AddParameterToURL(formattedURL, "type", programType.ToString());
            }

            if (mediaObjectType != MediaObjectType.all)
            {
                formattedURL = RequestBuilder.AddParameterToURL(formattedURL, "mediaobject", mediaObjectType.ToString());
            }

            RequestBuilder.Inst.NewWebRequest(formattedURL, HttpMethod.GET, delegate(WebResponse response) {
                if (!response.Success)
                {
                    Debug.Log("<color=yellow>YleSDKManager.GetProgramsList | Error:" + response.GetResponseMap().GetValue <string>("error") + "</color>");
                }
                else
                {
                    Debug.Log("<color=purple>YleSDKManager.GetProgramsList | Api:" + response.GetResponseMap().GetValue <string>("apiVersion") + "</color>");

                    IList <ProgramData> returnVal = new List <ProgramData>();
                    IDictionary <string, object>[] dataMapCollection = response.GetResponseMap().GetHashCollection("data");

                    if (dataMapCollection != null)
                    {
                        for (int i = 0; i < dataMapCollection.Length; i++)
                        {
                            ProgramData pd = new ProgramData(dataMapCollection[i]);
                            returnVal.Add(pd);
                        }
                    }

                    if (onComplete != null)
                    {
                        onComplete(returnVal);
                    }
                }
            });
        }
Esempio n. 3
0
 public static string GetContainerName(MediaObjectType type)
 {
     return(StorageContainerType.ContainsKey(type) ? StorageContainerType[type] : string.Empty);
 }