Search in sources :

Example 1 with Order

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

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

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

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

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

the class OrderTest method can_serialize_json_order_photo_type.

@Test
public void can_serialize_json_order_photo_type() {
    String json = "{\"id\":1,\"address1\":\"1 street,\",\"address2\":\"blah,\",\"postalOrZipCode\":\"peecode\",\"country\":\"GB\",\"addressTownOrCity\":\"bristol.\",\"recipientName\":\"matt burns\",\"textOnReverse\":null,\"stateOrCounty\":\"Bristol.\",\"status\":\"NotYetSubmitted\",\"payment\":null,\"paymentUrl\":null,\"photos\":[{\"id\":123,\"type\":\"4x18\",\"url\":\"http://www.g.com\",\"status\":\"Ok\",\"copies\":1,\"sizing\":\"Crop\",\"orderId\":1,\"price\":null}],\"documents\":[],\"stickers\":[{\"id\":456,\"orderId\":1,\"fileName\":\"sticker.jpg\"}]}";
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(Type.class, new TypeDeserializer());
    Gson gson = gsonBuilder.create();
    Order order = gson.fromJson(json, Order.class);
    assertEquals(Type._4x18, order.getPhotos().get(0).getType());
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) TypeDeserializer(uk.co.mattburns.pwinty.v2_3.gson.TypeDeserializer)

Aggregations

Order (uk.co.mattburns.pwinty.v2_3.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_3.Pwinty)7 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Photo (uk.co.mattburns.pwinty.v2_3.Photo)1 TypeDeserializer (uk.co.mattburns.pwinty.v2_3.gson.TypeDeserializer)1