Search in sources :

Example 1 with HttpRequestBuilder

use of de.foryasee.httprequest.HttpRequestBuilder in project Rubicon by Rubicon-Bot.

the class MemberLeaveRequestImpl method build.

@Override
public HttpRequestBuilder build() {
    HttpRequestBuilder request = new HttpRequestBuilder(WebpanelData.BASE_URL, RequestType.GET);
    request.addParameter("type", WebpanelData.MEMBER_LEAVE.getKey());
    request.addParameter("guildid", guild.getId());
    request.addParameter("guildname", guild.getName());
    return request;
}
Also used : HttpRequestBuilder(de.foryasee.httprequest.HttpRequestBuilder)

Example 2 with HttpRequestBuilder

use of de.foryasee.httprequest.HttpRequestBuilder in project Rubicon by Rubicon-Bot.

the class MessageStatisticsRequestImpl method build.

@Override
public HttpRequestBuilder build() {
    HttpRequestBuilder request = new HttpRequestBuilder(WebpanelData.BASE_URL, RequestType.GET);
    request.addParameter("type", WebpanelData.MESSAGE_COUNT.getKey());
    request.addParameter("guildid", guild.getId());
    request.addParameter("guildname", guild.getName());
    request.addParameter("count", String.valueOf(size));
    return request;
}
Also used : HttpRequestBuilder(de.foryasee.httprequest.HttpRequestBuilder)

Example 3 with HttpRequestBuilder

use of de.foryasee.httprequest.HttpRequestBuilder in project Rubicon by Rubicon-Bot.

the class CoinhiveManager method getCoinhiveUser.

public static CoinhiveUser getCoinhiveUser(User user) {
    try {
        HttpRequestBuilder balanceRequest = new HttpRequestBuilder(BASE_URL + "/user/balance", RequestType.GET);
        balanceRequest.addParameter("name", user.getId());
        RequestResponse balanceResponse = balanceRequest.sendRequest();
        JSONObject balanceObj = (JSONObject) new JSONParser().parse(balanceResponse.getResponseMessage());
        if (balanceObj.get("success").equals("false") || balanceObj.get("balance") == null) {
            return new CoinhiveUser() {

                @Override
                public String getName() {
                    return "Invalid user.";
                }

                @Override
                public int getTotal() {
                    return 0;
                }

                @Override
                public int getWithdrawn() {
                    return 0;
                }

                @Override
                public long getBalance() {
                    return 0;
                }
            };
        }
        return new CoinhiveUser() {

            @Override
            public String getName() {
                return (String) balanceObj.get("name");
            }

            @Override
            public int getTotal() {
                return (int) balanceObj.get("total");
            }

            @Override
            public int getWithdrawn() {
                return (int) balanceObj.get("withdrawn");
            }

            @Override
            public long getBalance() {
                return ((long) balanceObj.get("balance"));
            }
        };
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : JSONObject(org.json.simple.JSONObject) JSONParser(org.json.simple.parser.JSONParser) HttpRequestBuilder(de.foryasee.httprequest.HttpRequestBuilder) RequestResponse(de.foryasee.httprequest.RequestResponse)

Example 4 with HttpRequestBuilder

use of de.foryasee.httprequest.HttpRequestBuilder in project Rubicon by Rubicon-Bot.

the class CoinhiveManager method withdrawUser.

public static void withdrawUser(CoinhiveUser coinhiveUser, int amount) {
    try {
        HttpRequestBuilder balanceRequest = new HttpRequestBuilder(BASE_URL + "/user/withdraw", RequestType.POST);
        balanceRequest.addParameter("name", coinhiveUser.getName());
        balanceRequest.addParameter("amount", String.valueOf(amount));
        RequestResponse balanceResponse = balanceRequest.sendRequest();
        JSONObject balanceObj = (JSONObject) new JSONParser().parse(balanceResponse.getResponseMessage());
        if (balanceObj.get("success").equals("false")) {
            Logger.error((String) balanceObj.get("error"));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.simple.JSONObject) JSONParser(org.json.simple.parser.JSONParser) HttpRequestBuilder(de.foryasee.httprequest.HttpRequestBuilder) RequestResponse(de.foryasee.httprequest.RequestResponse)

Example 5 with HttpRequestBuilder

use of de.foryasee.httprequest.HttpRequestBuilder in project Rubicon by Rubicon-Bot.

the class GuildNameUpdateRequestImpl method build.

@Override
public HttpRequestBuilder build() {
    HttpRequestBuilder request = new HttpRequestBuilder(WebpanelData.BASE_URL, RequestType.GET);
    request.addParameter("type", "guild_name_update");
    request.addParameter("guildid", guild.getId());
    request.addParameter("guildname", guild.getName());
    return request;
}
Also used : HttpRequestBuilder(de.foryasee.httprequest.HttpRequestBuilder)

Aggregations

HttpRequestBuilder (de.foryasee.httprequest.HttpRequestBuilder)15 RequestResponse (de.foryasee.httprequest.RequestResponse)10 JSONObject (org.json.simple.JSONObject)7 JSONParser (org.json.simple.parser.JSONParser)5 ParseException (org.json.simple.parser.ParseException)4 JSONArray (org.json.simple.JSONArray)3 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)2 RequestHeader (de.foryasee.httprequest.RequestHeader)1 Date (java.util.Date)1 HTTPException (javax.xml.ws.http.HTTPException)1 JSONObject (org.json.JSONObject)1