Package is.bokun.client

Source Code of is.bokun.client.LanguageClient

package is.bokun.client;

import is.bokun.dtos.TranslationLanguageDto;

import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.google.inject.Inject;
import com.ning.http.client.Response;

/**
* Client for the Language resource.
*
* @author Olafur Gauti Gudmundsson
*/
public class LanguageClient extends AbstractClient {

    private static final String BASE = "/language.json";

    /**
     * @see AbstractClient#()
     *
     * @param config
     */
    @Inject
    public LanguageClient(ClientConfiguration config) {
        super(config);
    }

    /**
     * Get a list of all the languages the system supports. The "lang" parameter,
     * which many of the client methods accept, must be a valid value from this list.
     *
     * @return a list of all the languages supported
     */
    public List<TranslationLanguageDto> findAll() {
        try {
            String uri = BASE + "/findAll";
            Response r = prepareGet(uri).execute().get();
            validateResponse(r);
            return json.readValue(r.getResponseBody("UTF-8"), new TypeReference<List<TranslationLanguageDto>>(){});
        } catch (Exception e) {
            throw wrapException(e);
        }
    }
}
TOP

Related Classes of is.bokun.client.LanguageClient

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.