model.Action Maven / Gradle / Ivy
The newest version!
package model;
import domain.Result;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.web.util.UriComponentsBuilder;
public class Action extends TagoModel {
public Action(String accountToken) {
super(accountToken);
}
public Result list() {
String url = api_url + "/action";
HttpMethod method = HttpMethod.GET;
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
HttpEntity entity = new HttpEntity(headers);
HttpEntity response = restTemplate
.exchange(builder.build().toUriString(),
method,
entity,
Result.class);
return response.getBody();
}
public Result create(Object data) {
String url = api_url + "/action";
HttpMethod method = HttpMethod.POST;
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
HttpEntity entity = new HttpEntity(data, headers);
HttpEntity response = restTemplate
.exchange(builder.build().toUriString(),
method,
entity,
Result.class);
return response.getBody();
}
public Result edit(String actionId, Object data) {
String url = api_url + "/action/" + actionId;
HttpMethod method = HttpMethod.PUT;
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
HttpEntity entity = new HttpEntity(data, headers);
HttpEntity response = restTemplate
.exchange(builder.build().toUriString(),
method,
entity,
Result.class);
return response.getBody();
}
public Result delete(String actionId) {
String url = api_url + "/action/" + actionId;
HttpMethod method = HttpMethod.DELETE;
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
HttpEntity entity = new HttpEntity(headers);
HttpEntity response = restTemplate
.exchange(builder.build().toUriString(),
method,
entity,
Result.class);
return response.getBody();
}
public Result info(String actionId) {
String url = api_url + "/action/" + actionId;
HttpMethod method = HttpMethod.GET;
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
HttpEntity entity = new HttpEntity(headers);
HttpEntity response = restTemplate
.exchange(builder.build().toUriString(),
method,
entity,
Result.class);
return response.getBody();
}
}