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

com.heroku.api.request.app.AppList Maven / Gradle / Ivy

package com.heroku.api.request.app;

import com.heroku.api.App;
import com.heroku.api.Heroku;
import com.heroku.api.exception.RequestFailedException;
import com.heroku.api.http.Http;
import com.heroku.api.http.HttpUtil;
import com.heroku.api.parser.Json;
import com.heroku.api.request.Request;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * TODO: Javadoc
 *
 * @author Naaman Newbold
 */
public class AppList implements Request> {

    @Override
    public Http.Method getHttpMethod() {
        return Http.Method.GET;
    }

    @Override
    public String getEndpoint() {
        return Heroku.Resource.Apps.value;
    }

    @Override
    public boolean hasBody() {
        return false;
    }

    @Override
    public String getBody() {
        throw HttpUtil.noBody();
    }

    @Override
    public Http.Accept getResponseType() {
        return Http.Accept.JSON;
    }

    @Override
    public Map getHeaders() {
        return Collections.emptyMap();
    }

    @Override
    public List getResponse(byte[] in, int code) {
        if (code == 200)
            return Json.parse(in, AppList.class);
        else
            throw new RequestFailedException("AppList Failed", code, in);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy