All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibasco.agql.protocols.supercell.coc.webapi.interfaces.CocClans Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
/*
 * Copyright (c) 2022 Asynchronous Game Query Library
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ibasco.agql.protocols.supercell.coc.webapi.interfaces;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.ibasco.agql.protocols.supercell.coc.webapi.CocSearchCriteria;
import com.ibasco.agql.protocols.supercell.coc.webapi.CocWebApiClient;
import com.ibasco.agql.protocols.supercell.coc.webapi.CocWebApiInterface;
import com.ibasco.agql.protocols.supercell.coc.webapi.interfaces.clans.GetClanInfo;
import com.ibasco.agql.protocols.supercell.coc.webapi.interfaces.clans.GetClanMembers;
import com.ibasco.agql.protocols.supercell.coc.webapi.interfaces.clans.GetClanWarLog;
import com.ibasco.agql.protocols.supercell.coc.webapi.interfaces.clans.SearchClan;
import com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocClanDetailedInfo;
import com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocPlayerBasicInfo;
import com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocWarLogEntry;
import org.jetbrains.annotations.ApiStatus;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

/**
 * 

A Web API Implementation of the Clan interface. Contains methods for clan-related inquiries.

* * @author Rafael Luis Ibasco * @see Clash of Clans API - Clans */ @Deprecated @ApiStatus.ScheduledForRemoval public class CocClans extends CocWebApiInterface { /** *

Default Constructor

* * @param client * A {@link com.ibasco.agql.protocols.supercell.coc.webapi.CocWebApiClient} instance */ public CocClans(CocWebApiClient client) { super(client); } /** *

* Search all clans by name and/or filtering the results using various criteria. At least one filtering criteria * must be defined and if name is used as part of search, it is required to be at least three characters long. * It is not possible to specify ordering for results so clients should not rely on any specific * ordering as that may change in the future releases of the API. *

* * @param criteria * A {@link com.ibasco.agql.protocols.supercell.coc.webapi.CocSearchCriteria} to help your life much easier * * @return A {@link java.util.concurrent.CompletableFuture} containing a {@link java.util.List} of clans matching the criteria. Empty if no match * found. */ public CompletableFuture> searchClans(CocSearchCriteria criteria) { CompletableFuture json = sendRequest(new SearchClan(VERSION_1, criteria)); return json.thenApply(new Function>() { @Override public List apply(JsonObject root) { JsonArray items = root.getAsJsonArray("items"); Type type = new TypeToken>() { }.getType(); return builder().fromJson(items, type); } }); } /** *

* Get information about a single clan by clan tag. Clan tags can be found using clan search operation. * Note that clan tags start with hash character '#' and that needs to be URL-encoded properly to work in URL, * so for example clan tag '#2ABC' would become '%232ABC' in the URL. *

* * @param clanTag * A {@link java.lang.String} preceded by a hash tag '#' character * * @return A {@link java.util.concurrent.CompletableFuture} returning an instance of {@link com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocClanDetailedInfo} */ public CompletableFuture getClanInfo(String clanTag) { CompletableFuture json = sendRequest(new GetClanInfo(VERSION_1, clanTag)); return json.thenApply(root -> builder().fromJson(root, CocClanDetailedInfo.class)); } /** *

List clan members

* * @param clanTag * A {@link java.lang.String} representing the clan tag * * @return A {@link java.util.concurrent.CompletableFuture} returning an instance of {@link java.util.List} of type {@link com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocPlayerBasicInfo} */ public CompletableFuture> getClanMembers(String clanTag) { return getClanMembers(clanTag, -1, -1, -1); } /** *

List clan members

* * @param clanTag * A {@link java.lang.String} representing the clan tag * @param limit * An {@link java.lang.Integer} limiting the number of records returned * @param after * (optional) An {@link java.lang.Integer} that indicates to return only items that occur after this marker. * After * marker can be found from the response, inside the 'paging' property. Note that only after * or before can be specified for a request, not both. Otherwise use -1 to disregard. * @param before * (optional) An {@link java.lang.Integer} that indicates to return only items that occur before this marker. * Before marker can be found from the response, * inside the 'paging' property. Note that only after or before can be specified for a request, not * both. Otherwise use -1 to disregard. * * @return A {@link java.util.concurrent.CompletableFuture} returning an instance of {@link java.util.List} of type {@link com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocPlayerBasicInfo} */ public CompletableFuture> getClanMembers(String clanTag, int limit, int after, int before) { CompletableFuture json = sendRequest(new GetClanMembers(VERSION_1, clanTag, limit, after, before)); return json.thenApply(new Function>() { @Override public List apply(JsonObject root) { JsonArray items = root.getAsJsonArray("items"); Type type = new TypeToken>() { }.getType(); return builder().fromJson(items, type); } }); } /** *

List clan members

* * @param clanTag * A {@link java.lang.String} representing the clan tag * @param limit * An {@link java.lang.Integer} limiting the number of records returned * * @return A {@link java.util.concurrent.CompletableFuture} returning an instance of {@link java.util.List} of type {@link com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocPlayerBasicInfo} */ public CompletableFuture> getClanMembers(String clanTag, int limit) { return getClanMembers(clanTag, limit, -1, -1); } /** *

Retrieve clan's clan war log

* * @param clanTag * A {@link java.lang.String} preceded by a hash tag '#' character * * @return A {@link java.util.concurrent.CompletableFuture} which contains a future result for a {@link java.util.List} of {@link com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocWarLogEntry} */ public CompletableFuture> getClanWarLog(String clanTag) { return getClanWarLog(clanTag, -1, -1, -1); } /** *

Retrieve clan's clan war log

* * @param clanTag * A {@link java.lang.String} preceded by a hash tag '#' character * @param limit * An {@link java.lang.Integer} limiting the number of records returned * @param after * (optional) An {@link java.lang.Integer} that indicates to return only items that occur after this marker. * After marker can be found from the response, inside the 'paging' property. Note * that only after or before can be specified for a request, not both. Otherwise use * -1 to disregard. * @param before * (optional) An {@link java.lang.Integer} that indicates to return only items that occur before this marker. * Before marker can be found from the response, inside the 'paging' property. Note that only after * or before can be specified for a request, not both. * Otherwise use -1 to disregard. * * @return A {@link java.util.concurrent.CompletableFuture} which contains a future result for a {@link java.util.List} of {@link com.ibasco.agql.protocols.supercell.coc.webapi.pojos.CocWarLogEntry} */ public CompletableFuture> getClanWarLog(String clanTag, int limit, int after, int before) { CompletableFuture json = sendRequest(new GetClanWarLog(VERSION_1, clanTag, limit, after, before)); return json.thenApply(new Function>() { @Override public List apply(JsonObject root) { JsonArray items = root.getAsJsonArray("items"); Type type = new TypeToken>() { }.getType(); return builder().fromJson(items, type); } }); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy