Search in sources :

Example 1 with Pwinty

use of uk.co.mattburns.pwinty.v2_6.Pwinty in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method updateDestinationCountryCode.

public int updateDestinationCountryCode(int orderIdToUpdate, CountryCode destinationCountryCode, Order.QualityLevel qualityLevel, boolean useTrackedShipping) {
    Pwinty pwinty = getPwinty(environment);
    System.out.println(pwinty.getOrder(orderIdToUpdate));
    Order order = pwinty.getOrder(orderIdToUpdate);
    order = order.createCloneWithDestinationCountryCode(destinationCountryCode, qualityLevel, useTrackedShipping);
    System.out.println(order);
    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();
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Example 2 with Pwinty

use of uk.co.mattburns.pwinty.v2_6.Pwinty in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method display.

public void display(int orderId) {
    Pwinty pwinty = getPwinty(environment);
    Order order = pwinty.getOrder(orderId);
    System.out.println(order);
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Example 3 with Pwinty

use of uk.co.mattburns.pwinty.v2_6.Pwinty in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method addPhotoToOrder.

public void addPhotoToOrder(int orderIdToUpdate, URL newUrl, Photo.Type type, int copies, Photo.Sizing sizing) {
    Pwinty pwinty = getPwinty(environment);
    System.out.println(pwinty.getOrder(orderIdToUpdate));
    Order order = pwinty.getOrder(orderIdToUpdate);
    order.addPhoto(newUrl, type, copies, sizing);
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Example 4 with Pwinty

use of uk.co.mattburns.pwinty.v2_6.Pwinty in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method updateImageUrl.

public void updateImageUrl(int orderIdToUpdate, int photoIdToUpdate, URL newUrl) {
    Pwinty pwinty = getPwinty(environment);
    System.out.println(pwinty.getOrder(orderIdToUpdate));
    Order order = pwinty.getOrder(orderIdToUpdate);
    List<Photo> photos = order.getPhotos();
    Photo.Type type = null;
    Photo.Sizing sizing = null;
    int copies = 0;
    for (Photo photo : photos) {
        if (photo.getId() == photoIdToUpdate) {
            type = photo.getType();
            sizing = photo.getSizing();
            copies = photo.getCopies();
            order.deletePhoto(photo);
        }
    }
    order.addPhoto(newUrl, type, copies, sizing);
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty) Photo(uk.co.mattburns.pwinty.v2_3.Photo)

Example 5 with Pwinty

use of uk.co.mattburns.pwinty.v2_6.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;
}
Also used : QualityLevel(uk.co.mattburns.pwinty.v2_6.Order.QualityLevel)

Aggregations

Order (uk.co.mattburns.pwinty.v2_3.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_3.Pwinty)7 Order (uk.co.mattburns.pwinty.v2_6.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_6.Pwinty)7 QualityLevel (uk.co.mattburns.pwinty.v2_6.Order.QualityLevel)2 Photo (uk.co.mattburns.pwinty.v2_3.Photo)1 Photo (uk.co.mattburns.pwinty.v2_6.Photo)1