Repository navigation
Generators
This documents how to use the Generators API.
To start using the library and call the plugin endpoints first you need an instance of the main class.
If you need help installing the library, check this document.
To get started, you need to create an instance of IdeoLogix\DigitalLicenseManagerClient\Service and authenticate.
The authentication documentation can be found here.
use IdeoLogix\DigitalLicenseManagerClient\Service;
$api = new Service( 'http://dlm.test', 'ck_XXXX', 'cs_XXXX' );To retrieve a list of generators from the REST API you can do:
$response = $api->generators()->get(['per_page' => 10]);
print_r($response->get_data());Array
(
[0] => Array
(
[id] => 1
[name] => Games
[charset] => ABCDWZ123590
[chunks] => 4
[chunk_length] => 4
[activations_limit] => 5
[separator] => -
[prefix] => NULL
[suffix] => NULL
[expires_in] => 365
[created_at] => 2021-06-07 00:30:42
[updated_at] => 2021-07-07 18:43:01
)
[1] => Array
(
[id] => 4
[name] => test
[charset] => ABCD1234567
[chunks] => 2
[chunk_length] => 4
[activations_limit] => 2
[separator] => -
[prefix] => DG
[suffix] => EK
[expires_in] => 365
[created_at] => 2021-07-09 16:56:11
[updated_at] => 2021-07-09 16:59:34
)
)To retrieve single generator from the REST API you can do:
$response = $api->generators()->find(1);
print_r($response->get_data());Array
(
[id] => 1
[name] => Games
[charset] => ABCDWZ123590
[chunks] => 4
[chunk_length] => 4
[activations_limit] => 5
[separator] => -
[prefix] => NULL
[suffix] => NULL
[expires_in] => 365
[created_at] => 2021-06-07 00:30:42
[updated_at] => 2021-07-07 18:43:01
)To create a Generator through the REST API you can do:
$response = $api->generators()->create( [
'name' => 'Mobile Apps',
'charset' => 'ABCD1234',
'chunks' => 4,
'chunk_length' => 4,
'activations_limit' => 1,
'separator' => '-',
'prefix' => '',
'suffix' => '',
'expires_in' => 365 // days.
] );
print_r($response->get_data());Array
(
[id] => 5
[name] => Mobile Apps
[charset] => ABCD1234
[chunks] => 4
[chunk_length] => 4
[activations_limit] => 1
[separator] => -
[prefix] => NULL
[suffix] => NULL
[expires_in] => 365
[created_at] => 2021-08-28 12:06:43
[updated_at] =>
)To update a Generator through the REST API you can do:
$response = $api->generators()->update( 5, [
'name' => 'Android Apps',
]);Array
(
[id] => 5
[name] => Android Apps
[charset] => ABCD1234
[chunks] => 4
[chunk_length] => 4
[activations_limit] => 1
[separator] => -
[prefix] => NULL
[suffix] => NULL
[expires_in] => 365
[created_at] => 2021-08-28 12:06:43
[updated_at] => 2021-08-28 12:42:31
)To delete Generator through the REST API you can do:
$response = $api->generators()->delete(5);Array
(
)To generate a specific amount of Licenses through the REST API you can do:
Note: Status values are numeric. (1 for SOLD, 2 for DELIVERED, 3 for ACTIVE, 4 for INACTIVE, and 5 for DISABLED.)
$response = $api->generators()->generate( 1, [
'save' => 1,
'amount' => 5,
'status' => 4,
//'product_id' => '',
//'order_id' => '',
//'user_id' => '',
] );
print_r($response->get_data());Array
(
[0] => DZWW-BWC1-DD0W-ZZCA
[1] => W902-A112-C0A9-CCZC
[2] => 5B2A-DAB5-B91B-CA35
[3] => 0BWA-9C2C-3393-1A92
[4] => CD22-A9C1-D3AD-CB3C
)For more information check this document.