Motive : I am trying to create an order from existing order with all the line items and its modifiers. I have tried the following methods but still I get an error.
Method #1:
The below ones copy only the main line items and not the modifiers of the line items.
Order existingOrder = mOrderConnector.getOrder(currentOrderId); Order newOrder = mOrderConnector.createOrder(new Order()); for (LineItem i : existingOrder.getLineItems()) { if (i.getId() != null) { mOrderConnector.addFixedPriceLineItem(newOrder.getId(), i.getItem().getId(), null, null); } }
The below snippet to copy the modifier from individual line items from existing order and put to new order. This created a 400 error, even though i gave my application full access for all the provided ones in clover dashboard. Also I made sure that the modifier has all the values set and the id is valid.
mOrderConnector.addLineItemModification(newOrder.getId(),"MODIFIER_ID", newMod);
W/System.err: com.clover.sdk.v1.ClientException: status code: 400 Order{json='ORDER JSON', bundle=null, changeLog=null} at com.clover.sdk.v1.ServiceConnector.throwOnFailure(ServiceConnector.java:318) at com.clover.sdk.v1.ServiceConnector.execute(ServiceConnector.java:251) at com.clover.sdk.v3.order.OrderV31Connector.addLineItemModification(OrderV31Connector.java:385)
Method #2:
The below method also gave me the same 400 error which is mentioned above.
mOrderConnector.updateLineItems(newOrder.getId(), lineItemList);
Method #3:
The below method also gave me the same 400 error which was mentioned on the #1 method.
mOrderConnector.createLineItemsFrom(newOrder.getId(), existingOrder.getId(), lineItemList);
Method #4:
Also tried the below method and got the following error.
Order existingOrder = mOrderConnector.getOrder(currentOrderId); Log.d(TAG, "Current order id : " + currentOrderId); Log.d(TAG, "Current order JSON : " + existingOrder); Order newOrder = new Order(existingOrder); newOrder.setId("AZQWERTY05231"); Log.d(TAG, "New order id : " + newOrder.getId()); Log.d(TAG, "New order JSON : " + newOrder); mOrderConnector.updateOrder(newOrder);
This is the response for the above snippet.
Current order id : 05V2YDCDFSH50 Current order JSON : Order{json='ORDER_JSON_1', bundle=null, changeLog=null} New order id : AZQWERTY05231 New order JSON : Order{json='ORDER_JSON_1', bundle=null, changeLog=Bundle[{id=null}]} W/System.err: com.clover.sdk.v1.ClientException: status code: 400 cannot update one or more of these fields: Order{json='{"id":"AZQWERTY05231"}', bundle=null, changeLog=null} W/System.err: at com.clover.sdk.v1.ServiceConnector.throwOnFailure(ServiceConnector.java:318) W/System.err: at com.clover.sdk.v1.ServiceConnector.execute(ServiceConnector.java:251) W/System.err: at com.clover.sdk.v3.order.OrderV31Connector.updateOrder(OrderV31Connector.java:240)
Is there any other way to do this ? Thanks for your time.