PHP code example of rpungello / sdk-client

1. Go to this page and download the library: Download rpungello/sdk-client 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/ */

    

rpungello / sdk-client example snippets


$client = new Rpungello\SdkClient('https://example.com');

// Returns a Psr\Http\Message\ResponseInterface response
$response = $client->get('/api/v1/users');

// Specify a query string
$response = $client->get('/api/v1/users', [
    'page' => 1,
    'limit' => 10,
]);

// Returns a json-decoded array from the response body
$response = $client->getJson('/api/v1/users');

// Takes the JSON data returned and wraps it in a DTO for static typing
$response = $client->getDto('/api/v1/users/1', UserDto::class);

// Takes the JSON data returned and converts it to an array of DTOs for static typing
$response = $client->getDtoArray('/api/v1/users', UserDto::class);

// Returns a Psr\Http\Message\ResponseInterface response
$response = $client->post('/api/v1/users', [
    'name' => 'John Doe',
    'email' => '[email protected]',
]);

// Returns a json-decoded array from the response body
$response = $client->postJson('/api/v1/users', [
    'name' => 'John Doe',
    'email' => '[email protected]',
]);

// Takes the JSON data returned and wraps it in a DTO for static typing
$user = new UserDto([
    'name' => 'John Doe',
    'email' => '[email protected]',
]);
$response = $client->postDto('/api/v1/users', $user);