PHP code example of ocolin / plume

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

    

ocolin / plume example snippets


// Setting manually for demonstration
$_ENV['PLUME_AUTH_URL']   = 'https://url.to.authserver.test';
$_ENV['PLUME_AUTH_HASH']  = 'MyAuthenticationTokenHashHere';
$_ENV['PLUME_PARTNER_ID'] = 'myPartnerIdHere';
$_ENV['PLUME_GROUP_ID']   = 'myGroupIdHere';
$_ENV['PLUME_API_URL']    = 'https://url.to.apiserver.test';
$plume = new Ocolin\Plume\Plume();

$config = new Ocolin\Plume\Config(
       api_url: 'https://url.to.authserver.test',
      auth_url: 'https://url.to.apiserver.test',
     auth_hash: 'MyAuthenticationTokenHashHere',
    partner_id: 'myPartnerIdHere',
      group_id: 'myGroupIdHere'
);

$plume = new Ocolin\Plume\Plume( config: $config );

$plume = new Ocolin\Plume\Plume(
    options: [ 'timeout' => 30, 'verify' => false ]
    throwOnError: true
);

$plume    = new Ocolin\Plume\Plume();
$response = $plume->get(
    endpoint: '/customers/{id}',
       query: [ 'id' => 'theClientsId' ]
);

echo $response->status;          // 200
echo $response->status_message;  // OK
echo $response->body->name;      // Customer name

Example:
$body = [ 'groupId' => '', 'partnerId' => '' ];

$plume  = new Ocolin\Plume\Plume();
$plume->get(
    endpoint: '/customers/{id}',
      query: [ 'id' => 'theClientsId' ] 
);

$plume  = new Ocolin\Plume\Plume();
$plume->post(
    endpoint: '/customers/',
        body: [ 
        'name' => 'My Name',
        'accountId' => 'Account Id' 
    ] 
);

$plume  = new Ocolin\Plume\Plume();
$plume->put(
    endpoint: '/customers/{id}',
       query: [ 'id' => 'myCustomerId' ],
        body: [ 
             'name' => 'My Name',
        'accountId' => 'Account Id' 
    ] 
);

$plume  = new Ocolin\Plume\Plume();
$plume->patch(
    endpoint: '/customers/{id}',
       query: [ 'id' => 'myCustomerId' ],
        body: [ 
             'name' => 'My Name',
        'accountId' => 'Account Id' 
    ] 
);

$plume  = new Ocolin\Plume\Plume();
$plume->delete(
    endpoint: '/Customers/{id}',
       query: [ 'id' => 'theClientsId' ] 
);

$plume  = new Ocolin\Plume\Plume();
$plume->head(
    endpoint: '/Customers/{id}/Locations/{locationId}',
       query: [ 
            'id'         => 'theClientsId',
            'locationId' => 'theLocationId'
        ] 
);

$plume  = new Ocolin\Plume\Plume();
$plume->request(
    endpoint: '/customers/{id}',
      method: 'PATCH',
       query: [ 'id' => 'theClientsId' ],
        body: [ 
             'name' => 'My Name',
        'accountId' => 'Account Id' 
        ],
    formData: true
);