/**
 * Get Service Status Action Sample
 * Returns the service status of a particular MWS API section. The operation
 * takes no input. All API sections within the API are required to implement this operation.
 *   
 * @param MarketplaceWebServiceSellers_Interface $service instance of MarketplaceWebServiceSellers_Interface
 * @param mixed $request MarketplaceWebServiceSellers_Model_GetServiceStatus or array of parameters
 */
function invokeGetServiceStatus(MarketplaceWebServiceSellers_Interface $service, $request)
{
    try {
        $response = $service->getServiceStatus($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        GetServiceStatusResponse\n";
        if ($response->isSetGetServiceStatusResult()) {
            echo "            GetServiceStatusResult\n";
            $getServiceStatusResult = $response->getGetServiceStatusResult();
            if ($getServiceStatusResult->isSetStatus()) {
                echo "                Status\n";
                echo "                    " . $getServiceStatusResult->getStatus() . "\n";
            }
            if ($getServiceStatusResult->isSetTimestamp()) {
                echo "                Timestamp\n";
                echo "                    " . $getServiceStatusResult->getTimestamp() . "\n";
            }
            if ($getServiceStatusResult->isSetMessageId()) {
                echo "                MessageId\n";
                echo "                    " . $getServiceStatusResult->getMessageId() . "\n";
            }
            if ($getServiceStatusResult->isSetMessages()) {
                echo "                Messages\n";
                $messages = $getServiceStatusResult->getMessages();
                $messageList = $messages->getMessage();
                foreach ($messageList as $message) {
                    echo "                    Message\n";
                    if ($message->isSetLocale()) {
                        echo "                        Locale\n";
                        echo "                            " . $message->getLocale() . "\n";
                    }
                    if ($message->isSetText()) {
                        echo "                        Text\n";
                        echo "                            " . $message->getText() . "\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 (MarketplaceWebServiceSellers_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";
    }
}
/**
 * Get Get Service Status Action Sample
 * Gets competitive pricing and related information for a product identified by
 * the MarketplaceId and ASIN.
 *
 * @param MarketplaceWebServiceSellers_Interface $service instance of MarketplaceWebServiceSellers_Interface
 * @param mixed $request MarketplaceWebServiceSellers_Model_GetServiceStatus or array of parameters
 */
function invokeGetServiceStatus(MarketplaceWebServiceSellers_Interface $service, $request)
{
    try {
        $response = $service->GetServiceStatus($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        $dom = new DOMDocument();
        $dom->loadXML($response->toXML());
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;
        echo $dom->saveXML();
        echo "ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n";
    } catch (MarketplaceWebServiceSellers_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 Marketplace Participations By Next Token Action Sample
 * If ListMarketplaces cannot return all the marketplaces in one go, it will
 * provide a nextToken.  That nextToken can be used with this operation to
 * retrieve the next batch of Marketplaces for that SellerId.
 *   
 * @param MarketplaceWebServiceSellers_Interface $service instance of MarketplaceWebServiceSellers_Interface
 * @param mixed $request MarketplaceWebServiceSellers_Model_ListMarketplaceParticipationsByNextToken or array of parameters
 */
function invokeListMarketplaceParticipationsByNextToken(MarketplaceWebServiceSellers_Interface $service, $request)
{
    try {
        $response = $service->listMarketplaceParticipationsByNextToken($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        ListMarketplaceParticipationsByNextTokenResponse\n";
        if ($response->isSetListMarketplaceParticipationsByNextTokenResult()) {
            echo "            ListMarketplaceParticipationsByNextTokenResult\n";
            $listMarketplaceParticipationsByNextTokenResult = $response->getListMarketplaceParticipationsByNextTokenResult();
            if ($listMarketplaceParticipationsByNextTokenResult->isSetNextToken()) {
                echo "                NextToken\n";
                echo "                    " . $listMarketplaceParticipationsByNextTokenResult->getNextToken() . "\n";
            }
            if ($listMarketplaceParticipationsByNextTokenResult->isSetListParticipations()) {
                echo "                ListParticipations\n";
                $listParticipations = $listMarketplaceParticipationsByNextTokenResult->getListParticipations();
                $participationList = $listParticipations->getParticipation();
                foreach ($participationList as $participation) {
                    echo "                    Participation\n";
                    if ($participation->isSetMarketplaceId()) {
                        echo "                        MarketplaceId\n";
                        echo "                            " . $participation->getMarketplaceId() . "\n";
                    }
                    if ($participation->isSetSellerId()) {
                        echo "                        SellerId\n";
                        echo "                            " . $participation->getSellerId() . "\n";
                    }
                    if ($participation->isSetHasSellerSuspendedListings()) {
                        echo "                        HasSellerSuspendedListings\n";
                        echo "                            " . $participation->getHasSellerSuspendedListings() . "\n";
                    }
                }
            }
            if ($listMarketplaceParticipationsByNextTokenResult->isSetListMarketplaces()) {
                echo "                ListMarketplaces\n";
                $listMarketplaces = $listMarketplaceParticipationsByNextTokenResult->getListMarketplaces();
                $marketplaceList = $listMarketplaces->getMarketplace();
                foreach ($marketplaceList as $marketplace) {
                    echo "                    Marketplace\n";
                    if ($marketplace->isSetMarketplaceId()) {
                        echo "                        MarketplaceId\n";
                        echo "                            " . $marketplace->getMarketplaceId() . "\n";
                    }
                    if ($marketplace->isSetName()) {
                        echo "                        Name\n";
                        echo "                            " . $marketplace->getName() . "\n";
                    }
                    if ($marketplace->isSetDefaultLanguageCode()) {
                        echo "                        DefaultLanguageCode\n";
                        echo "                            " . $marketplace->getDefaultLanguageCode() . "\n";
                    }
                    if ($marketplace->isSetDefaultCountryCode()) {
                        echo "                        DefaultCountryCode\n";
                        echo "                            " . $marketplace->getDefaultCountryCode() . "\n";
                    }
                    if ($marketplace->isSetDefaultCurrencyCode()) {
                        echo "                        DefaultCurrencyCode\n";
                        echo "                            " . $marketplace->getDefaultCurrencyCode() . "\n";
                    }
                    if ($marketplace->isSetDomainName()) {
                        echo "                        DomainName\n";
                        echo "                            " . $marketplace->getDomainName() . "\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 (MarketplaceWebServiceSellers_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";
    }
}