Example #1
0
        public async Task <TaskResult> SendCreditsAsync(decimal amount, string to, string description)
        {
            string response = "";

            try
            {
                response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/eco/SendTransactionByIDS?from={Id}&to={to}&amount={amount}&auth={Auth_Key}&detail={description}");
            }
#pragma warning disable 0168
            catch (VooperException e)
            {
                // Ignore HTTP error codes, TaskResult handles it
            }
#pragma warning restore 0168

            TaskResult result = null;

            try
            {
                result = JsonConvert.DeserializeObject <TaskResult>(response);
            }
#pragma warning disable 0168
            catch (Exception e)
            {
                result = new TaskResult(false, response);
            }
#pragma warning restore 0168

            return(result);
        }
Example #2
0
        public async Task <int> GetDaysSinceLastMoveAsync()
        {
            string response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/user/GetDaysSinceLastMove?svid={Id}");

            int result = int.MaxValue;

            int.TryParse(response, out result);

            return(result);
        }
Example #3
0
        public async Task <bool> HasDiscordRoleAsync(string role)
        {
            string response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/user/HasDiscordRole?userid={Id}&role={role}");

            try
            {
                return(bool.Parse(response));
            }
#pragma warning disable 0168
            catch (System.Exception e)
            {
                throw new VooperException($"Malformed response: {response}");
            }
#pragma warning restore 0168
        }
Example #4
0
        /// <summary>
        /// Returns all available data about this user at the moment the snapshot is called (async)
        /// </summary>
        public async Task <UserSnapshot> GetSnapshotAsync()
        {
            string json = await SpookVooperAPI.GetData($"https://api.spookvooper.com/user/GetUser?svid={Id}");

            UserSnapshot snapshot = null;

            try {
                snapshot = JsonConvert.DeserializeObject <UserSnapshot>(json);
            }
#pragma warning disable 0168
            catch (System.Exception e)
            {
                throw new VooperException($"Malformed response: {json}");
            }
#pragma warning restore 0168

            return(snapshot);
        }
Example #5
0
        public async Task <decimal> GetBalanceAsync()
        {
            string response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/eco/GetBalance?svid={Id}");

            decimal result = 0m;

            try
            {
                result = decimal.Parse(response, USCulture);
            }
#pragma warning disable 0168
            catch (System.Exception e)
            {
                throw new VooperException($"Malformed response: {response}");
            }
#pragma warning restore 0168

            return(result);
        }
Example #6
0
        public async Task <bool> HasGroupPermissionAsync(string userSVID, string permission)
        {
            string response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/group/HasGroupPermission?svid={Id}&usersvid={userSVID}&permission={permission}");

            bool result = false;

            try
            {
                result = bool.Parse(response);
            }
#pragma warning disable 0168
            catch (System.Exception e)
            {
                throw new VooperException($"Malformed response: {response}");
            }
#pragma warning restore 0168

            return(result);
        }
Example #7
0
        public async Task <List <string> > GetGroupMemberIDsAsync()
        {
            string response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/group/GetGroupMembers?svid={Id}");

            List <string> results = null;

            try
            {
                results = JsonConvert.DeserializeObject <List <string> >(response);
            }
#pragma warning disable 0168
            catch (System.Exception e)
            {
                throw new VooperException($"Malformed response: {response}");
            }
#pragma warning restore 0168

            return(results);
        }
Example #8
0
        public static async Task <bool> DoesGroupExistAsync(string svid)
        {
            string response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/group/DoesGroupExist?svid={svid}");

            bool result = false;

            try
            {
                result = bool.Parse(response);
            }
#pragma warning disable 0168
            catch (System.Exception e)
            {
                throw new VooperException($"Malformed response: {response}");
            }
#pragma warning restore 0168

            return(result);
        }
Example #9
0
 public async Task <string> GetNameAsync()
 {
     return(await SpookVooperAPI.GetData($"https://api.spookvooper.com/Entity/GetName?svid={Id}"));
 }
Example #10
0
        public async Task <List <DiscordRoleData> > GetDiscordRolesAsync()
        {
            string response = await SpookVooperAPI.GetData($"https://api.spookvooper.com/user/GetDiscordRoles?svid={Id}");

            return(JsonConvert.DeserializeObject <List <DiscordRoleData> >(response));
        }
Example #11
0
 public static async Task <string> GetSVIDFromMinecraftAsync(string minecraftid)
 {
     return(await SpookVooperAPI.GetData($"https://api.spookvooper.com/user/GetSVIDFromMinecraft?minecraftid={minecraftid}"));
 }
Example #12
0
 public static async Task <string> GetUsernameFromDiscordAsync(ulong discordid)
 {
     return(await SpookVooperAPI.GetData($"https://api.spookvooper.com/user/GetUsernameFromDiscord?discordid={discordid}"));
 }
Example #13
0
 public static async Task <string> GetSVIDFromUsernameAsync(string username)
 {
     return(await SpookVooperAPI.GetData($"https://api.spookvooper.com/user/GetSVIDFromUsername?username={username}"));
 }
Example #14
0
 public static async Task <string> GetSVIDFromNameAsync(string name)
 {
     return(await SpookVooperAPI.GetData($"https://api.spookvooper.com/group/GetSVIDFromName?name={name}"));
 }