Repository navigation
Licenses
This documents how to use the Licenses 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 list of licenses from the REST API you can do:
$response = $api->lisenses()->get(['per_page' => 10]);
print_r($response->get_data());Array
(
[0] => Array
(
[id] => 2
[order_id] => 23
[product_id] => 12
[user_id] => 1
[license_key] => ABCZ-AC15-352C-21ZW
[expires_at] => 2021-06-07 00:00:00
[valid_for] => 365
[source] => 1
[status] => 1
[times_activated] => 0
[activations_limit] => 5
[is_expired] => 1
[created_at] => 2021-06-07 00:31:32
[updated_at] => 2021-07-07 14:03:08
)
[1] => Array
(
[id] => 3
[order_id] => 24
[product_id] => 12
[user_id] => 1
[license_key] => W0Z2-5203-CCA1-Z055
[expires_at] => 2022-06-07 00:00:00
[valid_for] => 365
[source] => 1
[status] => 2
[times_activated] => 0
[activations_limit] => 5
[is_expired] => 0
[created_at] => 2021-06-07 00:39:34
[updated_at] => 2021-06-20 21:26:27
)
)To retrieve single license from the REST API you can do:
$response = $api->licenses()->find( 'DWA9-AAZZ-3199-Z312' );
print_r($response->get_data());Array
(
[id] => 33
[order_id] => 56
[product_id] => 12
[user_id] => 1
[license_key] => DWA9-AAZZ-3199-Z312
[expires_at] => 2022-07-25 09:38:12
[valid_for] => 365
[source] => 1
[status] => 2
[times_activated] => 5
[activations_limit] => 5
[is_expired] => 0
[created_at] => 2021-07-25 09:38:12
[updated_at] => 2021-07-25 09:38:12
[activations] => Array
(
[0] => Array
(
[id] => 11
[token] => fa587c7786608c8fef4684f2d5452578321a3635
[license_id] => 33
[label] => NULL
[source] => 2
[ip_address] => 127.0.0.1
[user_agent] => ''
[meta_data] => Array()
[created_at] => 2021-07-30 16:37:53
[updated_at] => 2021-08-22 17:27:35
[deactivated_at] => NULL
)
[1] => Array
(
[id] => 12
[token] => 7ebb5cc3be72451894ce1241165de263731ee87e
[license_id] => 33
[label] => NULL
[source] => 2
[ip_address] => 127.0.0.1
[user_agent] => ''
[meta_data] => Array()
[created_at] => 2021-07-30 16:39:09
[updated_at] => NULL
[deactivated_at] => NULL
)
)
)To create a License 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->licenses()->create([
'order_id' => 39,
'product_id' => 12,
'user_id' => 1,
'license_key' => 'DASK-1281-JCAJ-8888',
'valid_for' => '365',
//'expires_at' => '2022-04-05 11:00:00', // Mutually exclusive with valid_for.
'activations_limit' => '3',
'status' => 1
]);
print_r($response->get_data());Array
(
[id] => 35
[order_id] => 39
[product_id] => 12
[user_id] => 1
[license_key] => DASK-1281-JCAJ-8888
[expires_at] => 2022-08-28 07:00:46
[valid_for] => 365
[source] => 3
[status] => 1
[times_activated] => 0
[activations_limit] => 3
[is_expired] => false
[created_at] => 2021-08-28 07:00:46
[created_by] => 1
[updated_at] => NULL
)To update a License 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->licenses()->update('DASK-1281-JCAJ-8888', [
'expires_at' => '2022-04-05 12:00:00',
]);Array
(
[id] => 35
[order_id] => 39
[product_id] => 12
[user_id] => 1
[license_key] => DASK-1281-JCAJ-8888
[expires_at] => 2022-04-05 12:00:00
[valid_for] => 365
[source] => 3
[status] => 1
[times_activated] => 0
[activations_limit] => 3
[is_expired] => false
[created_at] => 2021-08-28 07:00:46
[updated_at] => 2021-08-28 07:24:48
)To deletea License through the REST API you can do:
$response = $api->licenses()->delete('DASK-1281-JCAJ-8888');Array
(
)To activate a License through the REST API you can do:
Note: Please store the token somewhere secure because it will be needed for deactivation and validation of the license.
$response = $api->licenses()->activate('DWA9-AAZZ-3199-Z312', ['label' => 'My Device'] );
print_r($response->get_data());Array
(
[id] => 16
[token] => 94face23474767399c106d7598685764853b49b5
[license_id] => 33
[label] => 'My Device'
[source] => 2
[ip_address] => 127.0.0.1
[user_agent] => DLM cURL Client v10
[meta_data] => Array ()
[created_at] => 2021-08-23 10:55:18
[updated_at] => NULL
[deactivated_at] => NULL
[license] => Array
(
[id] => 33
[order_id] => 56
[product_id] => 12
[user_id] => 1
[license_key] => DWA9-AAZZ-3199-Z312
[expires_at] => 2022-07-25 09:38:12
[valid_for] => 365
[source] => 1
[status] => 2
[times_activated] => 2
[activations_limit] => 5
[is_expired] => false
[created_at] => 2021-07-25 09:38:12
[updated_at] => 2021-07-25 09:38:12
)
)To deactivate existing Activation through the REST API you need to supply an activation token:
Note: The deactivate($token) method accepts the activation token that you previously obtained when activating the license.
$response = $api->licenses()->deactivate('94face23474767399c106d7598685764853b49b5');
print_r($response->get_data());Array
(
[id] => 20
[token] => 94face23474767399c106d7598685764853b49b5
[license_id] => 33
[label] => 'My Device'
[source] => 2
[ip_address] => 127.0.0.1
[user_agent] => DLM cURL Client v10
[meta_data] => Array()
[created_at] => 2021-08-28 06:32:40
[updated_at] => 2021-08-28 10:59:53
[deactivated_at] => 2021-08-28 10:59:53
[license] => Array
(
[id] => 33
[order_id] => 56
[product_id] => 12
[user_id] => 1
[license_key] => DWA9-AAZZ-3199-Z312
[expires_at] => 2022-07-25 09:38:12
[valid_for] => 365
[source] => 1
[status] => 2
[times_activated] => 2
[activations_limit] => 5
[is_expired] => false
[created_at] => 2021-07-25 09:38:12
[updated_at] => 2021-07-25 09:38:12
)
)To validate existing activation through the REST API you need to supply an activation token:
Note: The validate($token) method accepts the activation token that you previously obtained when activating the license.
$response = $api->licenses()->validate('94face23474767399c106d7598685764853b49b5');
print_r($response->get_data());Array
(
[id] => 20
[token] => 94face23474767399c106d7598685764853b49b5
[license_id] => 33
[label] => My Device
[source] => 2
[ip_address] => 127.0.0.1
[user_agent] => DLM cURL Client v10
[meta_data] => Array()
[created_at] => 2021-08-28 06:32:40
[updated_at] => NULL
[deactivated_at] => NULL
)For more information check this document.