/** * This code was auto-generated by a tool. * * Changes to this file may cause incorrect behavior and will be lost if * the code is regenerated. */ package com.mozu.test.framework.datafactory; import java.util.List; import java.util.HashMap; import java.util.ArrayList; import org.apache.http.HttpStatus; import org.joda.time.DateTime; import com.mozu.api.ApiException; import com.mozu.api.ApiContext; import com.mozu.test.framework.core.TestFailException; import com.mozu.api.resources.commerce.ReturnResource; /** <summary> * Use the Returns resource to manage returned items that were previously fufilled. Returns can include any number of items associated with an original Mozu order. Each return must either be associated with an original order or a product definition to represent each returned item. * </summary> */ public class ReturnFactory { public static com.mozu.api.contracts.commerceruntime.returns.ReturnCollection getReturns(ApiContext apiContext, int expectedCode) throws Exception { return getReturns(apiContext, null, null, null, null, null, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.ReturnCollection getReturns(ApiContext apiContext, Integer startIndex, Integer pageSize, String sortBy, String filter, String q, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.ReturnCollection returnObj = new com.mozu.api.contracts.commerceruntime.returns.ReturnCollection(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getReturns( startIndex, pageSize, sortBy, filter, q, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static List<String> getAvailableReturnActions(ApiContext apiContext, String returnId, int expectedCode) throws Exception { List<String> returnObj = new ArrayList<String>(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getAvailableReturnActions( returnId); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.ReturnItem getReturnItem(ApiContext apiContext, String returnId, String returnItemId, int expectedCode) throws Exception { return getReturnItem(apiContext, returnId, returnItemId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.ReturnItem getReturnItem(ApiContext apiContext, String returnId, String returnItemId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.ReturnItem returnObj = new com.mozu.api.contracts.commerceruntime.returns.ReturnItem(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getReturnItem( returnId, returnItemId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.ReturnItemCollection getReturnItems(ApiContext apiContext, String returnId, int expectedCode) throws Exception { return getReturnItems(apiContext, returnId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.ReturnItemCollection getReturnItems(ApiContext apiContext, String returnId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.ReturnItemCollection returnObj = new com.mozu.api.contracts.commerceruntime.returns.ReturnItemCollection(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getReturnItems( returnId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static List<String> getAvailablePaymentActionsForReturn(ApiContext apiContext, String returnId, String paymentId, int expectedCode) throws Exception { List<String> returnObj = new ArrayList<String>(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getAvailablePaymentActionsForReturn( returnId, paymentId); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.payments.Payment getPayment(ApiContext apiContext, String returnId, String paymentId, int expectedCode) throws Exception { return getPayment(apiContext, returnId, paymentId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.payments.Payment getPayment(ApiContext apiContext, String returnId, String paymentId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.payments.Payment returnObj = new com.mozu.api.contracts.commerceruntime.payments.Payment(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getPayment( returnId, paymentId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.payments.PaymentCollection getPayments(ApiContext apiContext, String returnId, int expectedCode) throws Exception { return getPayments(apiContext, returnId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.payments.PaymentCollection getPayments(ApiContext apiContext, String returnId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.payments.PaymentCollection returnObj = new com.mozu.api.contracts.commerceruntime.payments.PaymentCollection(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getPayments( returnId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.Return getReturn(ApiContext apiContext, String returnId, int expectedCode) throws Exception { return getReturn(apiContext, returnId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.Return getReturn(ApiContext apiContext, String returnId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.Return returnObj = new com.mozu.api.contracts.commerceruntime.returns.Return(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getReturn( returnId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.ReasonCollection getReasons(ApiContext apiContext, int expectedCode) throws Exception { return getReasons(apiContext, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.ReasonCollection getReasons(ApiContext apiContext, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.ReasonCollection returnObj = new com.mozu.api.contracts.commerceruntime.returns.ReasonCollection(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.getReasons( responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.Return createReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.Return ret, int expectedCode) throws Exception { return createReturn(apiContext, ret, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.Return createReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.Return ret, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.Return returnObj = new com.mozu.api.contracts.commerceruntime.returns.Return(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.createReturn( ret, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.Return createReturnItem(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.ReturnItem returnItem, String returnId, int expectedCode) throws Exception { return createReturnItem(apiContext, returnItem, returnId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.Return createReturnItem(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.ReturnItem returnItem, String returnId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.Return returnObj = new com.mozu.api.contracts.commerceruntime.returns.Return(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.createReturnItem( returnItem, returnId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.Return performPaymentActionForReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.payments.PaymentAction action, String returnId, String paymentId, int expectedCode) throws Exception { return performPaymentActionForReturn(apiContext, action, returnId, paymentId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.Return performPaymentActionForReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.payments.PaymentAction action, String returnId, String paymentId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.Return returnObj = new com.mozu.api.contracts.commerceruntime.returns.Return(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.performPaymentActionForReturn( action, returnId, paymentId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.Return createPaymentActionForReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.payments.PaymentAction action, String returnId, int expectedCode) throws Exception { return createPaymentActionForReturn(apiContext, action, returnId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.Return createPaymentActionForReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.payments.PaymentAction action, String returnId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.Return returnObj = new com.mozu.api.contracts.commerceruntime.returns.Return(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.createPaymentActionForReturn( action, returnId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.orders.Order createReturnShippingOrder(ApiContext apiContext, String returnId, int expectedCode) throws Exception { return createReturnShippingOrder(apiContext, returnId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.orders.Order createReturnShippingOrder(ApiContext apiContext, String returnId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.orders.Order returnObj = new com.mozu.api.contracts.commerceruntime.orders.Order(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.createReturnShippingOrder( returnId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.ReturnCollection performReturnActions(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.ReturnAction action, int expectedCode) throws Exception { return performReturnActions(apiContext, action, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.ReturnCollection performReturnActions(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.ReturnAction action, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.ReturnCollection returnObj = new com.mozu.api.contracts.commerceruntime.returns.ReturnCollection(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.performReturnActions( action, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static com.mozu.api.contracts.commerceruntime.returns.Return updateReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.Return ret, String returnId, int expectedCode) throws Exception { return updateReturn(apiContext, ret, returnId, null, expectedCode); } public static com.mozu.api.contracts.commerceruntime.returns.Return updateReturn(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.Return ret, String returnId, String responseFields, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.Return returnObj = new com.mozu.api.contracts.commerceruntime.returns.Return(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.updateReturn( ret, returnId, responseFields); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static void resendReturnEmail(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.returns.ReturnAction action, int expectedCode) throws Exception { ReturnResource resource = new ReturnResource(apiContext); try { resource.resendReturnEmail( action); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); } public static com.mozu.api.contracts.commerceruntime.returns.Return deleteOrderItem(ApiContext apiContext, String returnId, String returnItemId, int expectedCode) throws Exception { com.mozu.api.contracts.commerceruntime.returns.Return returnObj = new com.mozu.api.contracts.commerceruntime.returns.Return(); ReturnResource resource = new ReturnResource(apiContext); try { returnObj = resource.deleteOrderItem( returnId, returnItemId); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return null; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); return returnObj; } public static void deleteReturn(ApiContext apiContext, String returnId, int expectedCode) throws Exception { ReturnResource resource = new ReturnResource(apiContext); try { resource.deleteReturn( returnId); } catch (ApiException e) { if(e.getHttpStatusCode() != expectedCode) throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); else return; } if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300)) throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, ""); } }