Пример #1
0
        public virtual string MmsJsonGetDownloadLinkv2(string eMail, int productId, int part, string callbackUrl, out MmsJsonGetDownloadLinkv2 mmsJsonDownloadLinkv2)
        {
            mmsJsonDownloadLinkv2 = null;
            string    return_val  = null;
            WebClient myWebClient = new WebClient();

            NameValueCollection myNameValueCollection = new NameValueCollection();

            // Add necessary parameter/value pairs to the name/value container.
            myNameValueCollection.Add("APIKey", "e252d955a8df2c516fbc74cfbc37bc97");
            myNameValueCollection.Add("Email", eMail);
            myNameValueCollection.Add("ProductID", productId.ToString());
            myNameValueCollection.Add("Part", part.ToString());
            myNameValueCollection.Add("CallbackURL", null);

            var    responseArray = myWebClient.UploadValues("https://downloads.murphysmagic.com/api/GetDownloadLinkv2/", myNameValueCollection);
            string rawJson       = Encoding.ASCII.GetString(responseArray);

            if (rawJson.Substring(2, 5) == "error")
            {
                MmsJsonError authTest = JsonConvert.DeserializeObject <MmsJsonError>(rawJson);
                return_val = authTest.error;
            }
            else
            {
                mmsJsonDownloadLinkv2 = JsonConvert.DeserializeObject <MmsJsonGetDownloadLinkv2>(rawJson);
                return_val            = "success";
            }

            return(return_val);
        }
Пример #2
0
        public virtual string MmsJsonGetDownloadFiles(int downloadId, out List <MmsJsonGetDownloadFiles> mmsJsonDownloadFiles)
        {
            mmsJsonDownloadFiles = null;
            string    return_val  = null;
            WebClient myWebClient = new WebClient();

            // Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
            NameValueCollection myNameValueCollection = new NameValueCollection();

            // Add necessary parameter/value pairs to the name/value container.
            myNameValueCollection.Add("APIKey", "e252d955a8df2c516fbc74cfbc37bc97");
            myNameValueCollection.Add("DownloadID", downloadId.ToString());
            //myNameValueCollection.Add("Age", age);

            // 'The Upload(String,NameValueCollection)' implicitly method sets HTTP POST as the request method.
            var    responseArray = myWebClient.UploadValues("https://downloads.murphysmagic.com/api/GetDownloadFiles/", myNameValueCollection);
            string rawJson       = Encoding.ASCII.GetString(responseArray);

            if (rawJson.Substring(2, 5) == "error")
            {
                MmsJsonError authTest = JsonConvert.DeserializeObject <MmsJsonError>(rawJson);
                return_val = authTest.error;
            }
            else
            {
                mmsJsonDownloadFiles = JsonConvert.DeserializeObject <List <MmsJsonGetDownloadFiles> >(rawJson);
                return_val           = "success";
            }

            return(return_val);
        }
Пример #3
0
        public virtual string MmsJsonAddOrder(string firstName, string lastName, string eMail, List <int> productIdList)
        {
            var    prodIdListString = new List <string>();
            string return_val       = null;

            foreach (var pId in productIdList)
            {
                prodIdListString.Add(pId.ToString());
            }
            string prodIdList = string.Join(",", prodIdListString.ToArray());

            WebClient myWebClient = new WebClient();

            NameValueCollection myNameValueCollection = new NameValueCollection();

            myNameValueCollection.Add("APIKey", "e252d955a8df2c516fbc74cfbc37bc97");
            myNameValueCollection.Add("FirstName", firstName);
            myNameValueCollection.Add("LastName", lastName);
            myNameValueCollection.Add("Email", eMail);
            myNameValueCollection.Add("ProductIDs", prodIdList);

            var    responseArray = myWebClient.UploadValues("https://downloads.murphysmagic.com/api/AddOrder/", myNameValueCollection);
            string rawJson       = Encoding.ASCII.GetString(responseArray);

            if (rawJson.Substring(2, 5) == "error")
            {
                MmsJsonError authTest = JsonConvert.DeserializeObject <MmsJsonError>(rawJson);
                return_val = authTest.error;
            }
            else
            {
                return_val = "success";
            }

            return(return_val);
        }