Beispiel #1
0
        private static void AddAPIOptions(GetMultiAPIArguments APIArgs, RestRequest request)
        {
            foreach (string uid in APIArgs.uids)
            {
                request.AddParameter("uid[]", uid);
            }

            request.AddParameter("apikey", APIArgs.apikey);
            request.AddParameter("pretty_print", APIArgs.pretty_print);
            request.AddParameter("suppress_status_codes", APIArgs.suppress_status_codes);

            if (APIArgs.datasheets == true)
            {
                request.AddParameter("include[]", "datasheets");
            }
            if (APIArgs.compliance_documents == true)
            {
                request.AddParameter("include[]", "compliance_documents");
            }
            if (APIArgs.descriptions == true)
            {
                request.AddParameter("include[]", "descriptions");
            }
            if (APIArgs.specs == true)
            {
                request.AddParameter("include[]", "specs");
            }
            if (APIArgs.imagesets == true)
            {
                request.AddParameter("include[]", "imagesets");
            }
            if (APIArgs.category_uids == true)
            {
                request.AddParameter("include[]", "category_uids");
            }
            if (APIArgs.external_links == true)
            {
                request.AddParameter("include[]", "external_links");
            }

            foreach (string Show in APIArgs.ShowDirectives)
            {
                request.AddParameter("show[]", Show);
            }
            foreach (string Hide in APIArgs.HideDirectives)
            {
                request.AddParameter("hide[]", Hide);
            }
        }
Beispiel #2
0
        public Dictionary <string, Endpoint> GetMultiObject <T>(GetMultiAPIArguments options) where T : class, new()
        {
            var type = typeof(T);

            if (!urls.ContainsKey(type))
            {
                return(null);
            }

            var request = new RestRequest(Method.GET);

            request.Resource = urls[type] + "/get_multi";
            AddAPIOptions(options, request);

            IRestResponse response = Execute(request);

            var serializerSettings = new JsonSerializerSettings();

            serializerSettings.Converters.Add(new EndPointSerializer());

            return(Deserialize <Dictionary <string, Endpoint> >(response, serializerSettings));
        }