Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.facebook.ads.sdk.CommerceOrder Maven / Gradle / Ivy
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.ads.sdk;
import java.io.File;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import com.google.gson.JsonObject;
import com.google.gson.JsonArray;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.facebook.ads.sdk.APIException.MalformedResponseException;
/**
* This class is auto-generated.
*
* For any issues or feature requests related to this class, please let us know
* on github and we'll fix in our codegen framework. We'll not be able to accept
* pull request for this class.
*
*/
public class CommerceOrder extends APINode {
@SerializedName("buyer_details")
private Object mBuyerDetails = null;
@SerializedName("channel")
private String mChannel = null;
@SerializedName("created")
private String mCreated = null;
@SerializedName("estimated_payment_details")
private Object mEstimatedPaymentDetails = null;
@SerializedName("id")
private String mId = null;
@SerializedName("is_group_buy")
private Boolean mIsGroupBuy = null;
@SerializedName("is_test_order")
private Boolean mIsTestOrder = null;
@SerializedName("last_updated")
private String mLastUpdated = null;
@SerializedName("merchant_order_id")
private String mMerchantOrderId = null;
@SerializedName("order_status")
private Object mOrderStatus = null;
@SerializedName("selected_shipping_option")
private Object mSelectedShippingOption = null;
@SerializedName("ship_by_date")
private String mShipByDate = null;
@SerializedName("shipping_address")
private Object mShippingAddress = null;
protected static Gson gson = null;
CommerceOrder() {
}
public CommerceOrder(Long id, APIContext context) {
this(id.toString(), context);
}
public CommerceOrder(String id, APIContext context) {
this.mId = id;
this.context = context;
}
public CommerceOrder fetch() throws APIException{
CommerceOrder newInstance = fetchById(this.getPrefixedId().toString(), this.context);
this.copyFrom(newInstance);
return this;
}
public static CommerceOrder fetchById(Long id, APIContext context) throws APIException {
return fetchById(id.toString(), context);
}
public static ListenableFuture fetchByIdAsync(Long id, APIContext context) throws APIException {
return fetchByIdAsync(id.toString(), context);
}
public static CommerceOrder fetchById(String id, APIContext context) throws APIException {
return
new APIRequestGet(id, context)
.requestAllFields()
.execute();
}
public static ListenableFuture fetchByIdAsync(String id, APIContext context) throws APIException {
return
new APIRequestGet(id, context)
.requestAllFields()
.executeAsync();
}
public static APINodeList fetchByIds(List ids, List fields, APIContext context) throws APIException {
return (APINodeList)(
new APIRequest(context, "", "/", "GET", CommerceOrder.getParser())
.setParam("ids", APIRequest.joinStringList(ids))
.requestFields(fields)
.execute()
);
}
public static ListenableFuture> fetchByIdsAsync(List ids, List fields, APIContext context) throws APIException {
return
new APIRequest(context, "", "/", "GET", CommerceOrder.getParser())
.setParam("ids", APIRequest.joinStringList(ids))
.requestFields(fields)
.executeAsyncBase();
}
private String getPrefixedId() {
return getId();
}
public String getId() {
return getFieldId().toString();
}
public static CommerceOrder loadJSON(String json, APIContext context, String header) {
CommerceOrder commerceOrder = getGson().fromJson(json, CommerceOrder.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(commerceOrder.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
if (!o1.equals(o2)) {
context.log("[Warning] When parsing response, object is not consistent with JSON:");
context.log("[JSON]" + o1);
context.log("[Object]" + o2);
}
}
commerceOrder.context = context;
commerceOrder.rawValue = json;
commerceOrder.header = header;
return commerceOrder;
}
public static APINodeList parseResponse(String json, APIContext context, APIRequest request, String header) throws MalformedResponseException {
APINodeList commerceOrders = new APINodeList(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
for (int i = 0; i < arr.size(); i++) {
commerceOrders.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
};
return commerceOrders;
} else if (result.isJsonObject()) {
obj = result.getAsJsonObject();
if (obj.has("data")) {
if (obj.has("paging")) {
JsonObject paging = obj.get("paging").getAsJsonObject();
if (paging.has("cursors")) {
JsonObject cursors = paging.get("cursors").getAsJsonObject();
String before = cursors.has("before") ? cursors.get("before").getAsString() : null;
String after = cursors.has("after") ? cursors.get("after").getAsString() : null;
commerceOrders.setCursors(before, after);
}
String previous = paging.has("previous") ? paging.get("previous").getAsString() : null;
String next = paging.has("next") ? paging.get("next").getAsString() : null;
commerceOrders.setPaging(previous, next);
if (context.hasAppSecret()) {
commerceOrders.setAppSecret(context.getAppSecretProof());
}
}
if (obj.get("data").isJsonArray()) {
// Second, check if it's a JSON array with "data"
arr = obj.get("data").getAsJsonArray();
for (int i = 0; i < arr.size(); i++) {
commerceOrders.add(loadJSON(arr.get(i).getAsJsonObject().toString(), context, header));
};
} else if (obj.get("data").isJsonObject()) {
// Third, check if it's a JSON object with "data"
obj = obj.get("data").getAsJsonObject();
boolean isRedownload = false;
for (String s : new String[]{"campaigns", "adsets", "ads"}) {
if (obj.has(s)) {
isRedownload = true;
obj = obj.getAsJsonObject(s);
for (Map.Entry entry : obj.entrySet()) {
commerceOrders.add(loadJSON(entry.getValue().toString(), context, header));
}
break;
}
}
if (!isRedownload) {
commerceOrders.add(loadJSON(obj.toString(), context, header));
}
}
return commerceOrders;
} else if (obj.has("images")) {
// Fourth, check if it's a map of image objects
obj = obj.get("images").getAsJsonObject();
for (Map.Entry entry : obj.entrySet()) {
commerceOrders.add(loadJSON(entry.getValue().toString(), context, header));
}
return commerceOrders;
} else {
// Fifth, check if it's an array of objects indexed by id
boolean isIdIndexedArray = true;
for (Map.Entry entry : obj.entrySet()) {
String key = (String) entry.getKey();
if (key.equals("__fb_trace_id__")) {
continue;
}
JsonElement value = (JsonElement) entry.getValue();
if (
value != null &&
value.isJsonObject() &&
value.getAsJsonObject().has("id") &&
value.getAsJsonObject().get("id") != null &&
value.getAsJsonObject().get("id").getAsString().equals(key)
) {
commerceOrders.add(loadJSON(value.toString(), context, header));
} else {
isIdIndexedArray = false;
break;
}
}
if (isIdIndexedArray) {
return commerceOrders;
}
// Sixth, check if it's pure JsonObject
commerceOrders.clear();
commerceOrders.add(loadJSON(json, context, header));
return commerceOrders;
}
}
} catch (Exception e) {
exception = e;
}
throw new MalformedResponseException(
"Invalid response string: " + json,
exception
);
}
@Override
public APIContext getContext() {
return context;
}
@Override
public void setContext(APIContext context) {
this.context = context;
}
@Override
public String toString() {
return getGson().toJson(this);
}
public APIRequestCreateAcknowledgeOrder createAcknowledgeOrder() {
return new APIRequestCreateAcknowledgeOrder(this.getPrefixedId().toString(), context);
}
public APIRequestGetCancellations getCancellations() {
return new APIRequestGetCancellations(this.getPrefixedId().toString(), context);
}
public APIRequestCreateCancellation createCancellation() {
return new APIRequestCreateCancellation(this.getPrefixedId().toString(), context);
}
public APIRequestCreateFulfillOrder createFulfillOrder() {
return new APIRequestCreateFulfillOrder(this.getPrefixedId().toString(), context);
}
public APIRequestGetItems getItems() {
return new APIRequestGetItems(this.getPrefixedId().toString(), context);
}
public APIRequestGetPayments getPayments() {
return new APIRequestGetPayments(this.getPrefixedId().toString(), context);
}
public APIRequestGetPromotionDetails getPromotionDetails() {
return new APIRequestGetPromotionDetails(this.getPrefixedId().toString(), context);
}
public APIRequestGetPromotions getPromotions() {
return new APIRequestGetPromotions(this.getPrefixedId().toString(), context);
}
public APIRequestGetRefunds getRefunds() {
return new APIRequestGetRefunds(this.getPrefixedId().toString(), context);
}
public APIRequestCreateRefund createRefund() {
return new APIRequestCreateRefund(this.getPrefixedId().toString(), context);
}
public APIRequestGetReturns getReturns() {
return new APIRequestGetReturns(this.getPrefixedId().toString(), context);
}
public APIRequestCreateReturn createReturn() {
return new APIRequestCreateReturn(this.getPrefixedId().toString(), context);
}
public APIRequestGetShipments getShipments() {
return new APIRequestGetShipments(this.getPrefixedId().toString(), context);
}
public APIRequestCreateShipment createShipment() {
return new APIRequestCreateShipment(this.getPrefixedId().toString(), context);
}
public APIRequestCreateUpdateShipment createUpdateShipment() {
return new APIRequestCreateUpdateShipment(this.getPrefixedId().toString(), context);
}
public APIRequestGet get() {
return new APIRequestGet(this.getPrefixedId().toString(), context);
}
public Object getFieldBuyerDetails() {
return mBuyerDetails;
}
public String getFieldChannel() {
return mChannel;
}
public String getFieldCreated() {
return mCreated;
}
public Object getFieldEstimatedPaymentDetails() {
return mEstimatedPaymentDetails;
}
public String getFieldId() {
return mId;
}
public Boolean getFieldIsGroupBuy() {
return mIsGroupBuy;
}
public Boolean getFieldIsTestOrder() {
return mIsTestOrder;
}
public String getFieldLastUpdated() {
return mLastUpdated;
}
public String getFieldMerchantOrderId() {
return mMerchantOrderId;
}
public Object getFieldOrderStatus() {
return mOrderStatus;
}
public Object getFieldSelectedShippingOption() {
return mSelectedShippingOption;
}
public String getFieldShipByDate() {
return mShipByDate;
}
public Object getFieldShippingAddress() {
return mShippingAddress;
}
public static class APIRequestCreateAcknowledgeOrder extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"idempotency_key",
"merchant_order_reference",
"return_error_response",
};
public static final String[] FIELDS = {
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestCreateAcknowledgeOrder.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateAcknowledgeOrder(String nodeId, APIContext context) {
super(context, nodeId, "/acknowledge_order", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateAcknowledgeOrder setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateAcknowledgeOrder setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateAcknowledgeOrder setIdempotencyKey (String idempotencyKey) {
this.setParam("idempotency_key", idempotencyKey);
return this;
}
public APIRequestCreateAcknowledgeOrder setMerchantOrderReference (String merchantOrderReference) {
this.setParam("merchant_order_reference", merchantOrderReference);
return this;
}
public APIRequestCreateAcknowledgeOrder setReturnErrorResponse (Boolean returnErrorResponse) {
this.setParam("return_error_response", returnErrorResponse);
return this;
}
public APIRequestCreateAcknowledgeOrder setReturnErrorResponse (String returnErrorResponse) {
this.setParam("return_error_response", returnErrorResponse);
return this;
}
public APIRequestCreateAcknowledgeOrder requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateAcknowledgeOrder requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateAcknowledgeOrder requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateAcknowledgeOrder requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateAcknowledgeOrder requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateAcknowledgeOrder requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetCancellations extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetCancellations.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetCancellations(String nodeId, APIContext context) {
super(context, nodeId, "/cancellations", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetCancellations setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetCancellations setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetCancellations requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetCancellations requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetCancellations requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetCancellations requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetCancellations requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetCancellations requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestCreateCancellation extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"cancel_reason",
"idempotency_key",
"items",
"restock_items",
};
public static final String[] FIELDS = {
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestCreateCancellation.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateCancellation(String nodeId, APIContext context) {
super(context, nodeId, "/cancellations", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateCancellation setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateCancellation setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateCancellation setCancelReason (Map cancelReason) {
this.setParam("cancel_reason", cancelReason);
return this;
}
public APIRequestCreateCancellation setCancelReason (String cancelReason) {
this.setParam("cancel_reason", cancelReason);
return this;
}
public APIRequestCreateCancellation setIdempotencyKey (String idempotencyKey) {
this.setParam("idempotency_key", idempotencyKey);
return this;
}
public APIRequestCreateCancellation setItems (List> items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateCancellation setItems (String items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateCancellation setRestockItems (Boolean restockItems) {
this.setParam("restock_items", restockItems);
return this;
}
public APIRequestCreateCancellation setRestockItems (String restockItems) {
this.setParam("restock_items", restockItems);
return this;
}
public APIRequestCreateCancellation requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateCancellation requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateCancellation requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateCancellation requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateCancellation requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateCancellation requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestCreateFulfillOrder extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"idempotency_key",
"items",
};
public static final String[] FIELDS = {
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestCreateFulfillOrder.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateFulfillOrder(String nodeId, APIContext context) {
super(context, nodeId, "/fulfill_order", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateFulfillOrder setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateFulfillOrder setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateFulfillOrder setIdempotencyKey (String idempotencyKey) {
this.setParam("idempotency_key", idempotencyKey);
return this;
}
public APIRequestCreateFulfillOrder setItems (List> items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateFulfillOrder setItems (String items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateFulfillOrder requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateFulfillOrder requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateFulfillOrder requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateFulfillOrder requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateFulfillOrder requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateFulfillOrder requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetItems extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetItems.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetItems(String nodeId, APIContext context) {
super(context, nodeId, "/items", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetItems setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetItems setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetItems requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetItems requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetItems requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetItems requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetItems requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetItems requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetPayments extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetPayments.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetPayments(String nodeId, APIContext context) {
super(context, nodeId, "/payments", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetPayments setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetPayments setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetPayments requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetPayments requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetPayments requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetPayments requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetPayments requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetPayments requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetPromotionDetails extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetPromotionDetails.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetPromotionDetails(String nodeId, APIContext context) {
super(context, nodeId, "/promotion_details", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetPromotionDetails setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetPromotionDetails setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetPromotionDetails requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetPromotionDetails requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetPromotionDetails requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetPromotionDetails requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetPromotionDetails requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetPromotionDetails requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetPromotions extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetPromotions.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetPromotions(String nodeId, APIContext context) {
super(context, nodeId, "/promotions", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetPromotions setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetPromotions setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetPromotions requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetPromotions requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetPromotions requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetPromotions requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetPromotions requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetPromotions requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetRefunds extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetRefunds.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetRefunds(String nodeId, APIContext context) {
super(context, nodeId, "/refunds", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetRefunds setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetRefunds setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetRefunds requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetRefunds requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetRefunds requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetRefunds requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetRefunds requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetRefunds requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestCreateRefund extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"deductions",
"idempotency_key",
"items",
"reason_code",
"reason_text",
"return_id",
"shipping",
};
public static final String[] FIELDS = {
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestCreateRefund.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateRefund(String nodeId, APIContext context) {
super(context, nodeId, "/refunds", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateRefund setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateRefund setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateRefund setDeductions (List> deductions) {
this.setParam("deductions", deductions);
return this;
}
public APIRequestCreateRefund setDeductions (String deductions) {
this.setParam("deductions", deductions);
return this;
}
public APIRequestCreateRefund setIdempotencyKey (String idempotencyKey) {
this.setParam("idempotency_key", idempotencyKey);
return this;
}
public APIRequestCreateRefund setItems (List> items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateRefund setItems (String items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateRefund setReasonCode (CommerceOrder.EnumReasonCode reasonCode) {
this.setParam("reason_code", reasonCode);
return this;
}
public APIRequestCreateRefund setReasonCode (String reasonCode) {
this.setParam("reason_code", reasonCode);
return this;
}
public APIRequestCreateRefund setReasonText (String reasonText) {
this.setParam("reason_text", reasonText);
return this;
}
public APIRequestCreateRefund setReturnId (String returnId) {
this.setParam("return_id", returnId);
return this;
}
public APIRequestCreateRefund setShipping (Map shipping) {
this.setParam("shipping", shipping);
return this;
}
public APIRequestCreateRefund setShipping (String shipping) {
this.setParam("shipping", shipping);
return this;
}
public APIRequestCreateRefund requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateRefund requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateRefund requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateRefund requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateRefund requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateRefund requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetReturns extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"merchant_return_id",
"statuses",
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetReturns.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetReturns(String nodeId, APIContext context) {
super(context, nodeId, "/returns", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetReturns setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetReturns setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetReturns setMerchantReturnId (String merchantReturnId) {
this.setParam("merchant_return_id", merchantReturnId);
return this;
}
public APIRequestGetReturns setStatuses (List statuses) {
this.setParam("statuses", statuses);
return this;
}
public APIRequestGetReturns setStatuses (String statuses) {
this.setParam("statuses", statuses);
return this;
}
public APIRequestGetReturns requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetReturns requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetReturns requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetReturns requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetReturns requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetReturns requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestCreateReturn extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"items",
"merchant_return_id",
"return_message",
"update",
};
public static final String[] FIELDS = {
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestCreateReturn.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateReturn(String nodeId, APIContext context) {
super(context, nodeId, "/returns", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateReturn setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateReturn setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateReturn setItems (List> items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateReturn setItems (String items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateReturn setMerchantReturnId (String merchantReturnId) {
this.setParam("merchant_return_id", merchantReturnId);
return this;
}
public APIRequestCreateReturn setReturnMessage (String returnMessage) {
this.setParam("return_message", returnMessage);
return this;
}
public APIRequestCreateReturn setUpdate (Map update) {
this.setParam("update", update);
return this;
}
public APIRequestCreateReturn setUpdate (String update) {
this.setParam("update", update);
return this;
}
public APIRequestCreateReturn requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateReturn requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateReturn requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateReturn requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateReturn requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateReturn requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGetShipments extends APIRequest {
APINodeList lastResponse = null;
@Override
public APINodeList getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
};
@Override
public APINodeList parseResponse(String response, String header) throws APIException {
return APINode.parseResponse(response, getContext(), this, header);
}
@Override
public APINodeList execute() throws APIException {
return execute(new HashMap());
}
@Override
public APINodeList execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(),rw.getHeader());
return lastResponse;
}
public ListenableFuture> executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture> executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function>() {
public APINodeList apply(ResponseWrapper result) {
try {
return APIRequestGetShipments.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGetShipments(String nodeId, APIContext context) {
super(context, nodeId, "/shipments", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGetShipments setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGetShipments setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGetShipments requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGetShipments requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetShipments requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestGetShipments requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGetShipments requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestGetShipments requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestCreateShipment extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"external_redemption_link",
"external_shipment_id",
"fulfillment",
"idempotency_key",
"items",
"merchant_order_reference",
"shipment_origin_postal_code",
"shipping_tax_details",
"should_use_default_fulfillment_location",
"tracking_info",
};
public static final String[] FIELDS = {
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestCreateShipment.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateShipment(String nodeId, APIContext context) {
super(context, nodeId, "/shipments", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateShipment setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateShipment setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateShipment setExternalRedemptionLink (String externalRedemptionLink) {
this.setParam("external_redemption_link", externalRedemptionLink);
return this;
}
public APIRequestCreateShipment setExternalShipmentId (String externalShipmentId) {
this.setParam("external_shipment_id", externalShipmentId);
return this;
}
public APIRequestCreateShipment setFulfillment (Map fulfillment) {
this.setParam("fulfillment", fulfillment);
return this;
}
public APIRequestCreateShipment setFulfillment (String fulfillment) {
this.setParam("fulfillment", fulfillment);
return this;
}
public APIRequestCreateShipment setIdempotencyKey (String idempotencyKey) {
this.setParam("idempotency_key", idempotencyKey);
return this;
}
public APIRequestCreateShipment setItems (List> items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateShipment setItems (String items) {
this.setParam("items", items);
return this;
}
public APIRequestCreateShipment setMerchantOrderReference (String merchantOrderReference) {
this.setParam("merchant_order_reference", merchantOrderReference);
return this;
}
public APIRequestCreateShipment setShipmentOriginPostalCode (String shipmentOriginPostalCode) {
this.setParam("shipment_origin_postal_code", shipmentOriginPostalCode);
return this;
}
public APIRequestCreateShipment setShippingTaxDetails (Map shippingTaxDetails) {
this.setParam("shipping_tax_details", shippingTaxDetails);
return this;
}
public APIRequestCreateShipment setShippingTaxDetails (String shippingTaxDetails) {
this.setParam("shipping_tax_details", shippingTaxDetails);
return this;
}
public APIRequestCreateShipment setShouldUseDefaultFulfillmentLocation (Boolean shouldUseDefaultFulfillmentLocation) {
this.setParam("should_use_default_fulfillment_location", shouldUseDefaultFulfillmentLocation);
return this;
}
public APIRequestCreateShipment setShouldUseDefaultFulfillmentLocation (String shouldUseDefaultFulfillmentLocation) {
this.setParam("should_use_default_fulfillment_location", shouldUseDefaultFulfillmentLocation);
return this;
}
public APIRequestCreateShipment setTrackingInfo (Map trackingInfo) {
this.setParam("tracking_info", trackingInfo);
return this;
}
public APIRequestCreateShipment setTrackingInfo (String trackingInfo) {
this.setParam("tracking_info", trackingInfo);
return this;
}
public APIRequestCreateShipment requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateShipment requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateShipment requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateShipment requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateShipment requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateShipment requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestCreateUpdateShipment extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
"external_shipment_id",
"fulfillment_id",
"idempotency_key",
"shipment_id",
"tracking_info",
};
public static final String[] FIELDS = {
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestCreateUpdateShipment.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestCreateUpdateShipment(String nodeId, APIContext context) {
super(context, nodeId, "/update_shipment", "POST", Arrays.asList(PARAMS));
}
@Override
public APIRequestCreateUpdateShipment setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestCreateUpdateShipment setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestCreateUpdateShipment setExternalShipmentId (String externalShipmentId) {
this.setParam("external_shipment_id", externalShipmentId);
return this;
}
public APIRequestCreateUpdateShipment setFulfillmentId (String fulfillmentId) {
this.setParam("fulfillment_id", fulfillmentId);
return this;
}
public APIRequestCreateUpdateShipment setIdempotencyKey (String idempotencyKey) {
this.setParam("idempotency_key", idempotencyKey);
return this;
}
public APIRequestCreateUpdateShipment setShipmentId (String shipmentId) {
this.setParam("shipment_id", shipmentId);
return this;
}
public APIRequestCreateUpdateShipment setTrackingInfo (Map trackingInfo) {
this.setParam("tracking_info", trackingInfo);
return this;
}
public APIRequestCreateUpdateShipment setTrackingInfo (String trackingInfo) {
this.setParam("tracking_info", trackingInfo);
return this;
}
public APIRequestCreateUpdateShipment requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestCreateUpdateShipment requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateUpdateShipment requestFields (List fields) {
return this.requestFields(fields, true);
}
@Override
public APIRequestCreateUpdateShipment requestFields (List fields, boolean value) {
for (String field : fields) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestCreateUpdateShipment requestField (String field) {
this.requestField(field, true);
return this;
}
@Override
public APIRequestCreateUpdateShipment requestField (String field, boolean value) {
this.requestFieldInternal(field, value);
return this;
}
}
public static class APIRequestGet extends APIRequest {
CommerceOrder lastResponse = null;
@Override
public CommerceOrder getLastResponse() {
return lastResponse;
}
public static final String[] PARAMS = {
};
public static final String[] FIELDS = {
"buyer_details",
"channel",
"created",
"estimated_payment_details",
"id",
"is_group_buy",
"is_test_order",
"last_updated",
"merchant_order_id",
"order_status",
"selected_shipping_option",
"ship_by_date",
"shipping_address",
};
@Override
public CommerceOrder parseResponse(String response, String header) throws APIException {
return CommerceOrder.parseResponse(response, getContext(), this, header).head();
}
@Override
public CommerceOrder execute() throws APIException {
return execute(new HashMap());
}
@Override
public CommerceOrder execute(Map extraParams) throws APIException {
ResponseWrapper rw = executeInternal(extraParams);
lastResponse = parseResponse(rw.getBody(), rw.getHeader());
return lastResponse;
}
public ListenableFuture executeAsync() throws APIException {
return executeAsync(new HashMap());
};
public ListenableFuture executeAsync(Map extraParams) throws APIException {
return Futures.transform(
executeAsyncInternal(extraParams),
new Function() {
public CommerceOrder apply(ResponseWrapper result) {
try {
return APIRequestGet.this.parseResponse(result.getBody(), result.getHeader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
);
};
public APIRequestGet(String nodeId, APIContext context) {
super(context, nodeId, "/", "GET", Arrays.asList(PARAMS));
}
@Override
public APIRequestGet setParam(String param, Object value) {
setParamInternal(param, value);
return this;
}
@Override
public APIRequestGet setParams(Map params) {
setParamsInternal(params);
return this;
}
public APIRequestGet requestAllFields () {
return this.requestAllFields(true);
}
public APIRequestGet requestAllFields (boolean value) {
for (String field : FIELDS) {
this.requestField(field, value);
}
return this;
}
@Override
public APIRequestGet requestFields (List