davidtsadler / ebay-sdk-examples

Several examples of using the eBay SDK for PHP
http://devbay.net
Apache License 2.0
184 stars 100 forks source link

add abortJob example in large merchant - code given #35

Closed ganganimaulik closed 7 years ago

ganganimaulik commented 7 years ago
<?php
/**
 * Copyright 2016 David T. Sadler
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Include the SDK by using the autoloader from Composer.
 */
require __DIR__.'/../vendor/autoload.php';

/**
 * Include the configuration values.
 *
 * Ensure that you have edited the configuration.php file
 * to include your application keys.
 */
$config = require __DIR__.'/../configuration.php';
$config['production']['authToken'] = '<AUTH TOKEN>';

/**
 * The namespaces provided by the SDK.
 */
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\BulkDataExchange\Services;
use \DTS\eBaySDK\BulkDataExchange\Types;

/**
 * Create the service object.
 */
$service = new Services\BulkDataExchangeService([
    'credentials' => $config['production']['credentials'],
    'authToken'   => $config['production']['authToken'],
    'sandbox'     => false
]);

/**
 * Create the request object.
 */
$request = new Types\AbortJobRequest();
$request->jobId ='6005936797';

/**
 * Send the request.
 */
$response = $service->abortJob($request);

/**
 * Output the result of calling the service operation.
 */
if (isset($response->errorMessage)) {
    print_r($response->errorMessage->error);
}

if ($response->ack !== 'Failure') {
    /**
     * Just display the first 5 jobs from the response.
     */

    print_r($response);
}
davidtsadler commented 7 years ago

The example has been added https://github.com/davidtsadler/ebay-sdk-examples/blob/master/large-merchant-services/06-abort.job.php