Example #1
0
        public override bool InternalSendTip(string user, decimal tip)
        {
            MPTipSend Tip = new MPTipSend
            {
                uname  = user,
                amount = tip * 100000000
            };

            HttpContent cont = new StringContent(json.JsonSerializer <MPTipSend>(Tip));

            cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            string Resp = "";

            using (var response = Client.PostAsync("tip?access_token=" + token, cont))
            {
                while (!response.IsCompleted)
                {
                    Thread.Sleep(100);
                }
                Resp = response.Result.Content.ReadAsStringAsync().Result;
            }

            MPTip tmp = json.JsonDeserialize <MPTip>(Resp);

            if (tmp.error != null)
            {
                if (tmp.error.ToLower().Contains("invalid amount"))
                {
                    MessageBox.Show("Invalid Tip Amount");
                    return(false);
                }
                else
                {
                    Parent.updateStatus(tmp.error);
                }
                return(false);
            }
            else
            {
                this.balance = this.balance - (tmp.amount / 100000000);
                Parent.updateBalance(balance);
                Parent.updateStatus("Sent " + (tmp.amount / 100000000).ToString("F8") + " to " + tmp.to);
                return(true);
            }
            return(false);
        }
Example #2
0
        public override void SendTip(string user, double tip)
        {
            MPTipSend Tip = new MPTipSend
            {
                uname = user,
                amount = tip * 100000000
            };

            HttpContent cont = new StringContent(json.JsonSerializer<MPTipSend>(Tip));
            cont.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            string Resp = "";
            using (var response = Client.PostAsync("tip?access_token=" + token, cont))
            {
                Resp = response.Result.Content.ReadAsStringAsync().Result;
            }

            MPTip tmp = json.JsonDeserialize<MPTip>(Resp);
            if (tmp.error != null)
            {
                if (tmp.error.ToLower().Contains("invalid amount"))
                {
                    MessageBox.Show("Invalid Tip Amount");
                    return;
                }
                else
                {
                    Parent.updateStatus(tmp.error);
                }
                return;
            }
            else
            {
                this.balance = this.balance - (tmp.amount / 100000000);
                Parent.updateBalance(balance);
                Parent.updateStatus("Sent " + (tmp.amount / 100000000).ToString("F8") + " to " + tmp.to);
            }
        }