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

com.heroku.api.request.addon.AddonList Maven / Gradle / Ivy

There is a newer version: 0.46
Show newest version
package com.heroku.api.request.addon;

import com.heroku.api.Addon;
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.request.Request;

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

import static com.heroku.api.parser.Json.parse;

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

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

    @Override
    public String getEndpoint() {
        return Heroku.Resource.Addons.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 new HashMap();
    }

    @Override
    public List getResponse(byte[] bytes, int status) {
        if (status == Http.Status.OK.statusCode) {
            return parse(bytes, getClass());
        } else {
            throw new RequestFailedException("Unable to list addons.", status, bytes);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy