Ejemplo n.º 1
0
 public function testAttachmentFieldIsSetCorrectlyInRequest()
 {
     // Calling the operation will not set the attachment field if there is no attachment.
     $request = new Types\UploadFileRequest();
     $this->assertEquals(null, $request->fileAttachment);
     $this->service->uploadFile($request);
     $this->assertEquals(null, $request->fileAttachment);
     // Calling the operation results in the attachment field been set by the service if there is an attachment.
     $request = new Types\UploadFileRequest();
     $request->attachment('123ABC');
     $this->assertEquals(null, $request->fileAttachment);
     $this->service->uploadFile($request);
     $this->assertInstanceOf('\\DTS\\eBaySDK\\FileTransfer\\Types\\FileAttachment', $request->fileAttachment);
     $this->assertEquals('<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:attachment.bin@devbay.net"/>', $request->fileAttachment->Data);
     $this->assertEquals(6, $request->fileAttachment->Size);
     // Calling the operation results in the attachment field been set by the service if there is an attachment.
     $request = new Types\UploadFileRequest();
     $request->attachment('123ABC');
     $request->fileAttachment = new Types\FileAttachment();
     $this->assertEquals(null, $request->fileAttachment->Data);
     $this->assertEquals(null, $request->fileAttachment->Size);
     $this->service->uploadFile($request);
     $this->assertInstanceOf('\\DTS\\eBaySDK\\FileTransfer\\Types\\FileAttachment', $request->fileAttachment);
     $this->assertEquals('<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:attachment.bin@devbay.net"/>', $request->fileAttachment->Data);
     $this->assertEquals(6, $request->fileAttachment->Size);
     // Calling the operation shouldn't modify an existing file attachment.
     $request = new Types\UploadFileRequest();
     $request->attachment('123ABC');
     $request->fileAttachment = new Types\FileAttachment();
     $request->fileAttachment->Data = 'ABCD1234';
     $request->fileAttachment->Size = 8;
     $this->service->uploadFile($request);
     $this->assertInstanceOf('\\DTS\\eBaySDK\\FileTransfer\\Types\\FileAttachment', $request->fileAttachment);
     $this->assertEquals('ABCD1234', $request->fileAttachment->Data);
     $this->assertEquals(8, $request->fileAttachment->Size);
 }
 * Output the result of calling the service operation.
 *
 * For more information about working with the service response object, see:
 * http://devbay.net/sdk/guides/getting-started/#response-object
 */
if (isset($createUploadJobResponse->errorMessage)) {
    foreach ($createUploadJobResponse->errorMessage->error as $error) {
        printf("%s: %s\n\n", $error->severity === BulkDataExchange\Enums\ErrorSeverity::C_ERROR ? 'Error' : 'Warning', $error->message);
    }
}
if ($createUploadJobResponse->ack !== 'Failure') {
    printf("JobId [%s] FileReferenceId [%s]\n", $createUploadJobResponse->jobId, $createUploadJobResponse->fileReferenceId);
    /**
     * Pass the required values to the File Transfer service.
     */
    $uploadFileRequest = new FileTransfer\Types\UploadFileRequest();
    $uploadFileRequest->fileReferenceId = $createUploadJobResponse->fileReferenceId;
    $uploadFileRequest->taskReferenceId = $createUploadJobResponse->jobId;
    $uploadFileRequest->fileFormat = 'gzip';
    $payload = buildPayload();
    /**
     * Convert our payload to XML.
     */
    $payloadXml = $payload->toRequestXml();
    /**
     * GZip and attach the XML payload.
     */
    $uploadFileRequest->attachment(gzencode($payloadXml, 9));
    /**
     * Now upload the file.
     */
Ejemplo n.º 3
0
 * Output the result of calling the service operation.
 *
 * For more information about working with the service response object, see:
 * http://devbay.net/sdk/guides/getting-started/#response-object
 */
if (isset($createUploadJobResponse->errorMessage)) {
    foreach ($createUploadJobResponse->errorMessage->error as $error) {
        printf("%s: %s\n\n", $error->severity === BulkDataExchange\Enums\ErrorSeverity::C_ERROR ? 'Error' : 'Warning', $error->message);
    }
}
if ($createUploadJobResponse->ack !== 'Failure') {
    printf("JobId [%s] FileReferenceId [%s]\n", $createUploadJobResponse->jobId, $createUploadJobResponse->fileReferenceId);
    /**
     * Pass the required values to the File Transfer service.
     */
    $uploadFileRequest = new FileTransfer\Types\UploadFileRequest();
    $uploadFileRequest->fileReferenceId = $createUploadJobResponse->fileReferenceId;
    $uploadFileRequest->taskReferenceId = $createUploadJobResponse->jobId;
    $uploadFileRequest->fileFormat = 'gzip';
    /**
     * Attach the gzip file for uploading. You can see the XML used in this file at:
     * https://github.com/davidtsadler/ebay-sdk-examples/blob/master/large-merchant-services/add-fixed-price-item-requests.xml
     */
    $uploadFileRequest->attachment(file_get_contents(__DIR__ . '/add-fixed-price-item-requests.xml.gz'));
    /**
     * Now upload the file.
     */
    print 'Uploading fixed price item requests...';
    $uploadFileResponse = $transferService->uploadFile($uploadFileRequest);
    print "Done\n";
    if (isset($uploadFileResponse->errorMessage)) {