com.gocardless.http.ApiResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gocardless-pro Show documentation
Show all versions of gocardless-pro Show documentation
Client library for accessing the GoCardless Pro API
package com.gocardless.http;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import java.util.List;
import java.util.Map;
/**
* Base class for API responses.
*
* @param the type of the resource within this response.
*/
public class ApiResponse {
private final T resource;
private final int statusCode;
private final Multimap headers;
public ApiResponse(T resource, int statusCode, Map> headers) {
this.resource = resource;
this.statusCode = statusCode;
this.headers = buildHeaderMap(headers);
}
public T getResource() {
return resource;
}
public int getStatusCode() {
return statusCode;
}
public Multimap getHeaders() {
return headers;
}
private static Multimap buildHeaderMap(Map> headers) {
ImmutableListMultimap.Builder builder = ImmutableListMultimap.builder();
for (Map.Entry> entry : headers.entrySet()) {
builder.putAll(entry.getKey(), entry.getValue());
}
return builder.build();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy