/**
 * List Order Items By Next Token Action Sample
 * If ListOrderItems cannot return all the order items in one go, it will
 * provide a nextToken. That nextToken can be used with this operation to
 * retrive the next batch of items for that order.
 *   
 * @param MarketplaceWebServiceOrders_Interface $service instance of MarketplaceWebServiceOrders_Interface
 * @param mixed $request MarketplaceWebServiceOrders_Model_ListOrderItemsByNextToken or array of parameters
 */
function invokeListOrderItemsByNextToken(MarketplaceWebServiceOrders_Interface $service, $request)
{
    try {
        $response = $service->listOrderItemsByNextToken($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        ListOrderItemsByNextTokenResponse\n";
        if ($response->isSetListOrderItemsByNextTokenResult()) {
            echo "            ListOrderItemsByNextTokenResult\n";
            $listOrderItemsByNextTokenResult = $response->getListOrderItemsByNextTokenResult();
            if ($listOrderItemsByNextTokenResult->isSetNextToken()) {
                echo "                NextToken\n";
                echo "                    " . $listOrderItemsByNextTokenResult->getNextToken() . "\n";
            }
            if ($listOrderItemsByNextTokenResult->isSetAmazonOrderId()) {
                echo "                AmazonOrderId\n";
                echo "                    " . $listOrderItemsByNextTokenResult->getAmazonOrderId() . "\n";
            }
            if ($listOrderItemsByNextTokenResult->isSetOrderItems()) {
                echo "                OrderItems\n";
                $orderItems = $listOrderItemsByNextTokenResult->getOrderItems();
                $orderItemList = $orderItems->getOrderItem();
                foreach ($orderItemList as $orderItem) {
                    echo "                    OrderItem\n";
                    if ($orderItem->isSetASIN()) {
                        echo "                        ASIN\n";
                        echo "                            " . $orderItem->getASIN() . "\n";
                    }
                    if ($orderItem->isSetSellerSKU()) {
                        echo "                        SellerSKU\n";
                        echo "                            " . $orderItem->getSellerSKU() . "\n";
                    }
                    if ($orderItem->isSetOrderItemId()) {
                        echo "                        OrderItemId\n";
                        echo "                            " . $orderItem->getOrderItemId() . "\n";
                    }
                    if ($orderItem->isSetTitle()) {
                        echo "                        Title\n";
                        echo "                            " . $orderItem->getTitle() . "\n";
                    }
                    if ($orderItem->isSetQuantityOrdered()) {
                        echo "                        QuantityOrdered\n";
                        echo "                            " . $orderItem->getQuantityOrdered() . "\n";
                    }
                    if ($orderItem->isSetQuantityShipped()) {
                        echo "                        QuantityShipped\n";
                        echo "                            " . $orderItem->getQuantityShipped() . "\n";
                    }
                    if ($orderItem->isSetItemPrice()) {
                        echo "                        ItemPrice\n";
                        $itemPrice = $orderItem->getItemPrice();
                        if ($itemPrice->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $itemPrice->getCurrencyCode() . "\n";
                        }
                        if ($itemPrice->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $itemPrice->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetShippingPrice()) {
                        echo "                        ShippingPrice\n";
                        $shippingPrice = $orderItem->getShippingPrice();
                        if ($shippingPrice->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $shippingPrice->getCurrencyCode() . "\n";
                        }
                        if ($shippingPrice->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $shippingPrice->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetGiftWrapPrice()) {
                        echo "                        GiftWrapPrice\n";
                        $giftWrapPrice = $orderItem->getGiftWrapPrice();
                        if ($giftWrapPrice->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $giftWrapPrice->getCurrencyCode() . "\n";
                        }
                        if ($giftWrapPrice->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $giftWrapPrice->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetItemTax()) {
                        echo "                        ItemTax\n";
                        $itemTax = $orderItem->getItemTax();
                        if ($itemTax->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $itemTax->getCurrencyCode() . "\n";
                        }
                        if ($itemTax->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $itemTax->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetShippingTax()) {
                        echo "                        ShippingTax\n";
                        $shippingTax = $orderItem->getShippingTax();
                        if ($shippingTax->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $shippingTax->getCurrencyCode() . "\n";
                        }
                        if ($shippingTax->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $shippingTax->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetGiftWrapTax()) {
                        echo "                        GiftWrapTax\n";
                        $giftWrapTax = $orderItem->getGiftWrapTax();
                        if ($giftWrapTax->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $giftWrapTax->getCurrencyCode() . "\n";
                        }
                        if ($giftWrapTax->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $giftWrapTax->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetShippingDiscount()) {
                        echo "                        ShippingDiscount\n";
                        $shippingDiscount = $orderItem->getShippingDiscount();
                        if ($shippingDiscount->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $shippingDiscount->getCurrencyCode() . "\n";
                        }
                        if ($shippingDiscount->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $shippingDiscount->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetPromotionDiscount()) {
                        echo "                        PromotionDiscount\n";
                        $promotionDiscount = $orderItem->getPromotionDiscount();
                        if ($promotionDiscount->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $promotionDiscount->getCurrencyCode() . "\n";
                        }
                        if ($promotionDiscount->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $promotionDiscount->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetPromotionIds()) {
                        echo "                        PromotionIds\n";
                        $promotionIds = $orderItem->getPromotionIds();
                        $promotionIdList = $promotionIds->getPromotionId();
                        foreach ($promotionIdList as $promotionId) {
                            echo "                            PromotionId\n";
                            echo "                                " . $promotionId;
                        }
                    }
                    if ($orderItem->isSetCODFee()) {
                        echo "                        CODFee\n";
                        $CODFee = $orderItem->getCODFee();
                        if ($CODFee->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $CODFee->getCurrencyCode() . "\n";
                        }
                        if ($CODFee->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $CODFee->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetCODFeeDiscount()) {
                        echo "                        CODFeeDiscount\n";
                        $CODFeeDiscount = $orderItem->getCODFeeDiscount();
                        if ($CODFeeDiscount->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $CODFeeDiscount->getCurrencyCode() . "\n";
                        }
                        if ($CODFeeDiscount->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $CODFeeDiscount->getAmount() . "\n";
                        }
                    }
                    if ($orderItem->isSetGiftMessageText()) {
                        echo "                        GiftMessageText\n";
                        echo "                            " . $orderItem->getGiftMessageText() . "\n";
                    }
                    if ($orderItem->isSetGiftWrapLevel()) {
                        echo "                        GiftWrapLevel\n";
                        echo "                            " . $orderItem->getGiftWrapLevel() . "\n";
                    }
                    if ($orderItem->isSetInvoiceData()) {
                        echo "                        InvoiceData\n";
                        $invoiceData = $orderItem->getInvoiceData();
                        if ($invoiceData->isSetInvoiceRequirement()) {
                            echo "                            InvoiceRequirement\n";
                            echo "                                " . $invoiceData->getInvoiceRequirement() . "\n";
                        }
                        if ($invoiceData->isSetBuyerSelectedInvoiceCategory()) {
                            echo "                            BuyerSelectedInvoiceCategory\n";
                            echo "                                " . $invoiceData->getBuyerSelectedInvoiceCategory() . "\n";
                        }
                        if ($invoiceData->isSetInvoiceTitle()) {
                            echo "                            InvoiceTitle\n";
                            echo "                                " . $invoiceData->getInvoiceTitle() . "\n";
                        }
                        if ($invoiceData->isSetInvoiceInformation()) {
                            echo "                            InvoiceInformation\n";
                            echo "                                " . $invoiceData->getInvoiceInformation() . "\n";
                        }
                    }
                }
            }
        }
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
        echo "            ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n";
    } catch (MarketplaceWebServiceOrders_Exception $ex) {
        echo "Caught Exception: " . $ex->getMessage() . "\n";
        echo "Response Status Code: " . $ex->getStatusCode() . "\n";
        echo "Error Code: " . $ex->getErrorCode() . "\n";
        echo "Error Type: " . $ex->getErrorType() . "\n";
        echo "Request ID: " . $ex->getRequestId() . "\n";
        echo "XML: " . $ex->getXML() . "\n";
        echo "ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n";
    }
}
/**
 * List Order Items By Next Token Action Sample
 * If ListOrderItems cannot return all the order items in one go, it will
 * provide a nextToken.  That nextToken can be used with this operation to
 * retrive the next batch of items for that order.
 *   
 * @param MarketplaceWebServiceOrders_Interface $service instance of MarketplaceWebServiceOrders_Interface
 * @param mixed $request MarketplaceWebServiceOrders_Model_ListOrderItemsByNextToken or array of parameters
 */
function invokeListOrderItemsByNextToken(MarketplaceWebServiceOrders_Interface $service, $request)
{
    try {
        $response = $service->listOrderItemsByNextToken($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        ListOrderItemsByNextTokenResponse\n";
        if ($response->isSetListOrderItemsByNextTokenResult()) {
            echo "            ListOrderItemsByNextTokenResult\n";
            $listOrderItemsByNextTokenResult = $response->getListOrderItemsByNextTokenResult();
            if ($listOrderItemsByNextTokenResult->isSetNextToken()) {
                echo "                NextToken\n";
                echo "                    " . $listOrderItemsByNextTokenResult->getNextToken() . "\n";
            }
            if ($listOrderItemsByNextTokenResult->isSetAmazonOrderId()) {
                echo "                AmazonOrderId\n";
                echo "                    " . $listOrderItemsByNextTokenResult->getAmazonOrderId() . "\n";
            }
            if ($listOrderItemsByNextTokenResult->isSetOrderItems()) {
                echo "                OrderItems\n";
                $orderItems = $listOrderItemsByNextTokenResult->getOrderItems();
                $memberList = $orderItems->getOrderItem();
                foreach ($memberList as $member) {
                    echo "                    member\n";
                    if ($member->isSetASIN()) {
                        echo "                        ASIN\n";
                        echo "                            " . $member->getASIN() . "\n";
                    }
                    if ($member->isSetSellerSKU()) {
                        echo "                        SellerSKU\n";
                        echo "                            " . $member->getSellerSKU() . "\n";
                    }
                    if ($member->isSetTitle()) {
                        echo "                        Title\n";
                        echo "                            " . $member->getTitle() . "\n";
                    }
                    if ($member->isSetQuantityOrdered()) {
                        echo "                        QuantityOrdered\n";
                        echo "                            " . $member->getQuantityOrdered() . "\n";
                    }
                    if ($member->isSetQuantityShipped()) {
                        echo "                        QuantityShipped\n";
                        echo "                            " . $member->getQuantityShipped() . "\n";
                    }
                    if ($member->isSetGiftMessageText()) {
                        echo "                        GiftMessageText\n";
                        echo "                            " . $member->getGiftMessageText() . "\n";
                    }
                    if ($member->isSetItemPrice()) {
                        echo "                        ItemPrice\n";
                        $itemPrice = $member->getItemPrice();
                        if ($itemPrice->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $itemPrice->getCurrencyCode() . "\n";
                        }
                        if ($itemPrice->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $itemPrice->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetShippingPrice()) {
                        echo "                        ShippingPrice\n";
                        $shippingPrice = $member->getShippingPrice();
                        if ($shippingPrice->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $shippingPrice->getCurrencyCode() . "\n";
                        }
                        if ($shippingPrice->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $shippingPrice->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetGiftWrapPrice()) {
                        echo "                        GiftWrapPrice\n";
                        $giftWrapPrice = $member->getGiftWrapPrice();
                        if ($giftWrapPrice->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $giftWrapPrice->getCurrencyCode() . "\n";
                        }
                        if ($giftWrapPrice->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $giftWrapPrice->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetItemTax()) {
                        echo "                        ItemTax\n";
                        $itemTax = $member->getItemTax();
                        if ($itemTax->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $itemTax->getCurrencyCode() . "\n";
                        }
                        if ($itemTax->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $itemTax->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetShippingTax()) {
                        echo "                        ShippingTax\n";
                        $shippingTax = $member->getShippingTax();
                        if ($shippingTax->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $shippingTax->getCurrencyCode() . "\n";
                        }
                        if ($shippingTax->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $shippingTax->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetGiftWrapTax()) {
                        echo "                        GiftWrapTax\n";
                        $giftWrapTax = $member->getGiftWrapTax();
                        if ($giftWrapTax->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $giftWrapTax->getCurrencyCode() . "\n";
                        }
                        if ($giftWrapTax->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $giftWrapTax->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetShippingDiscount()) {
                        echo "                        ShippingDiscount\n";
                        $shippingDiscount = $member->getShippingDiscount();
                        if ($shippingDiscount->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $shippingDiscount->getCurrencyCode() . "\n";
                        }
                        if ($shippingDiscount->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $shippingDiscount->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetPromotionDiscount()) {
                        echo "                        PromotionDiscount\n";
                        $promotionDiscount = $member->getPromotionDiscount();
                        if ($promotionDiscount->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $promotionDiscount->getCurrencyCode() . "\n";
                        }
                        if ($promotionDiscount->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $promotionDiscount->getAmount() . "\n";
                        }
                    }
                    if ($member->isSetPromotionIds()) {
                        echo "                        PromotionIds\n";
                        $promotionIds = $member->getPromotionIds();
                        $member1List = $promotionIds->getPromotionId();
                        foreach ($member1List as $member1) {
                            echo "                            member\n";
                            echo "                                " . $member1;
                        }
                    }
                }
            }
        }
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
    } catch (MarketplaceWebServiceOrders_Exception $ex) {
        echo "Caught Exception: " . $ex->getMessage() . "\n";
        echo "Response Status Code: " . $ex->getStatusCode() . "\n";
        echo "Error Code: " . $ex->getErrorCode() . "\n";
        echo "Error Type: " . $ex->getErrorType() . "\n";
        echo "Request ID: " . $ex->getRequestId() . "\n";
        echo "XML: " . $ex->getXML() . "\n";
    }
}