Skip to content

Latest commit

 

History

History
181 lines (129 loc) · 7.25 KB

File metadata and controls

181 lines (129 loc) · 7.25 KB

CodeSamples

(codeSamples)

Overview

REST APIs for retrieving Code Samples

Available Operations

generateCodeSamplePreview

This endpoint generates Code Sample previews from a file and configuration parameters.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Speakeasy\SpeakeasyClientSDK;
use Speakeasy\SpeakeasyClientSDK\Models\Shared;

$sdk = SpeakeasyClientSDK\SDK::builder()
    ->setSecurity(
        new Shared\Security(
            apiKey: '<YOUR_API_KEY_HERE>',
        )
    )
    ->build();

$request = new Shared\CodeSampleSchemaInput(
    languages: [
        '<value>',
    ],
    schemaFile: new Shared\SchemaFile(
        content: '0xc3dD8BfBef',
        fileName: 'example.file',
    ),
);

$response = $sdk->codeSamples->generateCodeSamplePreview(
    request: $request
);

if ($response->twoHundredApplicationJsonBytes !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Shared\CodeSampleSchemaInput ✔️ The request object to use for the request.

Response

?Operations\GenerateCodeSamplePreviewResponse

Errors

Error Type Status Code Content Type
Errorors\Error 4XX application/json
Errorors\Error 5XX application/json

generateCodeSamplePreviewAsync

This endpoint generates Code Sample previews from a file and configuration parameters, receiving an async JobID response for polling.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Speakeasy\SpeakeasyClientSDK;
use Speakeasy\SpeakeasyClientSDK\Models\Shared;

$sdk = SpeakeasyClientSDK\SDK::builder()
    ->setSecurity(
        new Shared\Security(
            apiKey: '<YOUR_API_KEY_HERE>',
        )
    )
    ->build();

$request = new Shared\CodeSampleSchemaInput(
    languages: [
        '<value>',
    ],
    schemaFile: new Shared\SchemaFile(
        content: '0xED5CDd177E',
        fileName: 'example.file',
    ),
);

$response = $sdk->codeSamples->generateCodeSamplePreviewAsync(
    request: $request
);

if ($response->object !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Shared\CodeSampleSchemaInput ✔️ The request object to use for the request.

Response

?Operations\GenerateCodeSamplePreviewAsyncResponse

Errors

Error Type Status Code Content Type
Errorors\Error 4XX application/json
Errorors\Error 5XX application/json

getCodeSamplePreviewAsync

Poll for the result of an asynchronous Code Sample preview generation.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Speakeasy\SpeakeasyClientSDK;
use Speakeasy\SpeakeasyClientSDK\Models\Operations;
use Speakeasy\SpeakeasyClientSDK\Models\Shared;

$sdk = SpeakeasyClientSDK\SDK::builder()
    ->setSecurity(
        new Shared\Security(
            apiKey: '<YOUR_API_KEY_HERE>',
        )
    )
    ->build();

$request = new Operations\GetCodeSamplePreviewAsyncRequest(
    jobID: '<id>',
);

$response = $sdk->codeSamples->getCodeSamplePreviewAsync(
    request: $request
);

if ($response->twoHundredApplicationJsonBytes !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\GetCodeSamplePreviewAsyncRequest ✔️ The request object to use for the request.

Response

?Operations\GetCodeSamplePreviewAsyncResponse

Errors

Error Type Status Code Content Type
Errorors\Error 4XX application/json
Errorors\Error 5XX application/json