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

weiboclient4j.CommonService Maven / Gradle / Ivy

There is a newer version: 0.4.16
Show newest version
package weiboclient4j;

import weiboclient4j.params.AddressCode;
import weiboclient4j.params.CapitalLetter;
import weiboclient4j.params.Country;
import weiboclient4j.params.Language;
import weiboclient4j.params.Province;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Hover Ruan
 */
public class CommonService extends AbstractService {
    public CommonService(WeiboClient client) {
        super(client);
    }

    public Map getTimezoneMap() throws WeiboClientException {
        return getTimezoneMap(null);
    }

    @SuppressWarnings("unchecked")
    public Map getTimezoneMap(Language language) throws WeiboClientException {
        return doGet("common/get_timezone",
                withParams(language), HashMap.class);
    }

    public Map getCountryMap() throws WeiboClientException {
        return getCountryMap(null, null);
    }

    public Map getCountryMap(Language language, CapitalLetter capitalLetter)
            throws WeiboClientException {
        List> response = doGet("common/get_country",
                withParams(language, capitalLetter), LIST_MAP_S_S_TYPE_REFERENCE);

        return mergeSingleItemMap(response);
    }

    public Map getProvinceMap(Country country) throws WeiboClientException {
        return getProvinceMap(country, null, null);
    }

    public Map getProvinceMap(Country country, Language language, CapitalLetter capitalLetter)
            throws WeiboClientException {
        List> response = doGet("common/get_province",
                withParams(country, language, capitalLetter), LIST_MAP_S_S_TYPE_REFERENCE);

        return mergeSingleItemMap(response);
    }

    public Map getCityMap(Province province) throws WeiboClientException {
        return getCityMap(province, null, null);
    }

    public Map getCityMap(Province province, Language language, CapitalLetter capitalLetter)
            throws WeiboClientException {
        List> response = doGet("common/get_city",
                withParams(province, language, capitalLetter), LIST_MAP_S_S_TYPE_REFERENCE);

        return mergeSingleItemMap(response);
    }

    public Map codeToLocation(Collection codes) throws WeiboClientException {
        List> response = doGet("common/code_to_location",
                withParams(AddressCode.codesParam(codes)), LIST_MAP_S_S_TYPE_REFERENCE);

        return mergeSingleItemMap(response);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy