Search in sources :

Example 1 with QualityLevel

use of uk.co.mattburns.pwinty.v2_3.Order.QualityLevel in project pwinty-java-sdk by OddPrints.

the class Pwinty method getUnrecognisedItemNames.

/**
 * Test if Pwinty have started offering new print sizes currently not hard-coded in the enum
 * Photo.Type
 *
 * @param countryCodes countries to check (just an optimisation).
 * @return set of item names we don't handle
 */
protected Set<String> getUnrecognisedItemNames(CountryCode... countryCodes) {
    Set<String> unrecognisedItemNames = new TreeSet<String>();
    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 : getUnrecognisedItems(catalogue)) {
                unrecognisedItemNames.add(item.getName());
            }
        }
    }
    return unrecognisedItemNames;
}
Also used : QualityLevel(uk.co.mattburns.pwinty.v2_3.Order.QualityLevel)

Example 2 with QualityLevel

use of uk.co.mattburns.pwinty.v2_3.Order.QualityLevel 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 3 with QualityLevel

use of uk.co.mattburns.pwinty.v2_3.Order.QualityLevel 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_3.Order.QualityLevel)

Aggregations

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