use of com.sun.jersey.api.representation.Form in project pwinty-java-sdk by OddPrints.
the class Pwinty method createOrderForm.
private Form createOrderForm(Order newOrder, Boolean useTrackedShipping) {
Form form = new Form();
form.add("recipientName", newOrder.getRecipientName());
form.add("address1", newOrder.getAddress1());
form.add("address2", newOrder.getAddress2());
form.add("addressTownOrCity", newOrder.getAddressTownOrCity());
form.add("stateOrCounty", newOrder.getStateOrCounty());
form.add("postalOrZipCode", newOrder.getPostalOrZipCode());
form.add("countryCode", newOrder.getCountryCode());
form.add("destinationCountryCode", newOrder.getDestinationCountryCode());
if (useTrackedShipping != null) {
form.add("useTrackedShipping", useTrackedShipping);
}
form.add("payment", newOrder.getPayment());
form.add("qualityLevel", newOrder.getQualityLevel());
return form;
}
use of com.sun.jersey.api.representation.Form in project pwinty-java-sdk by OddPrints.
the class Pwinty method createOrder.
Order createOrder(Order newOrder, boolean useTrackedShipping) {
Form form = createOrderForm(newOrder, useTrackedShipping);
ClientResponse response = webResource.path("Orders").type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_JSON_TYPE).header("X-Pwinty-MerchantId", merchantId).header("X-Pwinty-REST-API-Key", apiKey).post(ClientResponse.class, form);
Order createdOrder = createReponse(response, Order.class);
createdOrder.setPwinty(this);
for (Photo photo : newOrder.getPhotos()) {
createdOrder.addPhoto(photo.getUrl(), photo.getType(), photo.getCopies(), photo.getSizing());
}
return createdOrder;
}
use of com.sun.jersey.api.representation.Form in project pwinty-java-sdk by OddPrints.
the class Pwinty method deletePhoto.
void deletePhoto(int orderId, int photoId) {
Form form = new Form();
ClientResponse response = webResource.path("Orders/" + orderId + "/Photos/" + photoId).type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_JSON_TYPE).header("X-Pwinty-MerchantId", merchantId).header("X-Pwinty-REST-API-Key", apiKey).delete(ClientResponse.class, form);
throwIfBad(response);
}
use of com.sun.jersey.api.representation.Form in project pwinty-java-sdk by OddPrints.
the class Pwinty method addIssueToOrder.
Issue addIssueToOrder(int orderId, Issue issue) {
Form form = new Form();
form.add("issue", issue.getIssue().toString());
form.add("action", issue.getAction().toString());
if (issue.getIssueDetail() != null) {
form.add("issueDetail", issue.getIssueDetail());
}
if (issue.getActionDetail() != null) {
form.add("actionDetail", issue.getActionDetail());
}
ClientResponse response = webResource.path("Orders/" + orderId + "/Issues").type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).header("X-Pwinty-MerchantId", merchantId).header("X-Pwinty-REST-API-Key", apiKey).post(ClientResponse.class, form);
throwIfBad(response);
return createReponse(response, Issue.class);
}
Aggregations