PHP code example of devinlogantest / devintest

1. Go to this page and download the library: Download devinlogantest/devintest library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

devinlogantest / devintest example snippets




namespace Example;

use Devin\DevinClient;
use Devin\Imdb\Types\CreateMovieRequest;

$client = new DevinClient();
$client->imdb->createMovie(
    new CreateMovieRequest([
        'title' => 'title',
        'rating' => 1.1,
    ]),
);


use Devin\Exceptions\DevinApiException;
use Devin\Exceptions\DevinException;

try {
    $response = $client->imdb->createMovie(...);
} catch (DevinApiException $e) {
    echo 'API Exception occurred: ' . $e->getMessage() . "\n";
    echo 'Status Code: ' . $e->getCode() . "\n";
    echo 'Response Body: ' . $e->getBody() . "\n";
    // Optionally, rethrow the exception or handle accordingly.
}

use Devin\DevinClient;

// Create a custom Guzzle client with specific configuration.
$customClient = new \GuzzleHttp\Client([
    'timeout' => 5.0,
]);

// Pass the custom client when creating an instance of the class.
$client = new DevinClient(options: [
    'client' => $customClient
]);

// You can also utilize the same technique to leverage advanced customizations to the client such as adding middleware
$handlerStack = \GuzzleHttp\HandlerStack::create();
$handlerStack->push(MyCustomMiddleware::create());
$customClient = new \GuzzleHttp\Client(['handler' => $handlerStack]);

// Pass the custom client when creating an instance of the class.
$client = new DevinClient(options: [
    'client' => $customClient
]);

$response = $client->imdb->createMovie(
    ...,
    options: [
        'maxRetries' => 0 // Override maxRetries at the request level
    ]
);

$response = $client->imdb->createMovie(
    ...,
    options: [
        'timeout' => 3.0 // Override timeout to 3 seconds
    ]
);