
br.com.moip.models.Orders Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-java Show documentation
Show all versions of sdk-java Show documentation
Java SDK for Moip APIs integration
The newest version!
package br.com.moip.models;
import br.com.moip.api.request.RequestMaker;
import br.com.moip.api.request.RequestProperties;
import br.com.moip.api.request.RequestPropertiesBuilder;
import org.apache.http.entity.ContentType;
import java.util.Map;
public class Orders {
private static final String ENDPOINT = "/v2/orders";
private static final ContentType CONTENT_TYPE = ContentType.APPLICATION_JSON;
private RequestMaker requestMaker;
/**
* This method is used to create a new order.
*
* @param body
* {@code Map} the request body.
*
* @param setup
* {@code Setup} the setup object.
*
* @return {@code Map}
*/
public Map create(Map body, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("POST")
.endpoint(ENDPOINT)
.body(body)
.type(Orders.class)
.contentType(CONTENT_TYPE)
.build();
return requestMaker.doRequest(props);
}
/**
* This method is used to get the data of a created order by Moip order external ID.
*
* @param orderId
* {@code String} the Moip order external ID. Ex: ORD-XXXXXXXXXXXX
*
* @param setup
* {@code Setup} the setup object.
*
* @return {@code Map}
*/
public Map get(String orderId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(String.format("%s/%s", ENDPOINT, orderId))
.type(Orders.class)
.contentType(CONTENT_TYPE)
.build();
return requestMaker.doRequest(props);
}
/**
* This method is used to get all created orders.
*
* @param setup
* {@code Setup} the setup object.
*
* @return {@code Map}
*/
public Map list(Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(ENDPOINT)
.type(Orders.class)
.contentType(CONTENT_TYPE)
.build();
return requestMaker.doRequest(props);
}
/**
* This method is used to get all payments of an order by its Moip order external ID.
*
* @param orderId
* {@code String} the Moip order external ID.
*
* @param setup
* {@code Setup} the setup object.
*
* @return {@code Map}
*/
public Map listOrderPayments(String orderId, Setup setup) {
this.requestMaker = new RequestMaker(setup);
RequestProperties props = new RequestPropertiesBuilder()
.method("GET")
.endpoint(String.format("%s/%s/payments", ENDPOINT, orderId))
.type(Orders.class)
.contentType(CONTENT_TYPE)
.build();
return requestMaker.doRequest(props);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy