use of uk.co.mattburns.pwinty.v2_3.Pwinty in project pwinty-java-sdk by OddPrints.
the class Pwinty method getAllItemNames.
/**
* Helper for test code. Just get a Set of all the Catalogue names
*
* @param countryCodes countries to check (just an optimisation).
* @return set of item names
*/
protected Set<String> getAllItemNames(CountryCode... countryCodes) {
Set<String> allItemNames = new TreeSet<>();
for (QualityLevel quality : QualityLevel.values()) {
for (CountryCode countryCode : countryCodes) {
String catalogueJSON = webResource.path("Catalogue/" + countryCode + "/" + quality.toString()).accept(MediaType.APPLICATION_JSON_TYPE).header("X-Pwinty-MerchantId", merchantId).header("X-Pwinty-REST-API-Key", apiKey).get(String.class);
Catalogue catalogue = createGson().fromJson(catalogueJSON, Catalogue.class);
for (CatalogueItem item : catalogue.getItems()) {
allItemNames.add(item.getName());
}
}
}
return allItemNames;
}
use of uk.co.mattburns.pwinty.v2_3.Pwinty in project pwinty-java-sdk by OddPrints.
the class OrderUpdater method updateAddress.
public void updateAddress(int orderIdToUpdate) {
Pwinty pwinty = getPwinty(environment);
System.out.println(pwinty.getOrder(orderIdToUpdate));
Order order = pwinty.getOrder(orderIdToUpdate);
order.setRecipientName("");
order.setAddress1("");
order.setAddress2("");
order.setAddressTownOrCity("");
order.setStateOrCounty("");
order.setPostalOrZipCode("");
}
use of uk.co.mattburns.pwinty.v2_3.Pwinty in project pwinty-java-sdk by OddPrints.
the class OrderUpdater method decodeAddress.
public void decodeAddress(int orderIdToUpdate) {
Pwinty pwinty = getPwinty(environment);
System.out.println(pwinty.getOrder(orderIdToUpdate));
Order order = pwinty.getOrder(orderIdToUpdate);
order.setRecipientName(decode(order.getRecipientName()));
order.setAddress1(decode(order.getAddress1()));
order.setAddress2(decode(order.getAddress2()));
order.setAddressTownOrCity(decode(order.getAddressTownOrCity()));
order.setStateOrCounty(decode(order.getStateOrCounty()));
order.setPostalOrZipCode(decode(order.getPostalOrZipCode()));
}
use of uk.co.mattburns.pwinty.v2_3.Pwinty in project pwinty-java-sdk by OddPrints.
the class OrderUpdater method updateUseTrackedShipping.
public int updateUseTrackedShipping(int orderIdToUpdate, boolean useTrackedShipping) {
Pwinty pwinty = getPwinty(environment);
System.out.println(pwinty.getOrder(orderIdToUpdate));
Order order = pwinty.getOrder(orderIdToUpdate);
order = order.createCloneWithTrackedShipping(useTrackedShipping);
System.out.println(order);
if (order.getShippingInfo().getShipments().get(0).isTracked() != useTrackedShipping) {
throw new RuntimeException("Couldn't set useTrackedShipping to " + useTrackedShipping + ". Is it available with current quality / country settings?");
}
System.out.println(pwinty.getOrder(order.getId()));
System.out.println("**** NOTE: ORDER NUMBER HAS NOW CHANGED !! ****");
System.out.println("New order number is : " + order.getId());
return order.getId();
}
Aggregations