-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add dp_ prefix to the shared functions
- Loading branch information
Showing
5 changed files
with
55 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
* @package curl | ||
* @author Sean Huber <[email protected]> | ||
**/ | ||
if (!class_exists('Curl')) { | ||
|
||
class Curl { | ||
|
||
/** | ||
|
@@ -253,4 +255,6 @@ protected function set_request_options($url, $vars) { | |
} | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
* @package curl | ||
* @author Sean Huber <[email protected]> | ||
**/ | ||
if (!class_exists('CurlResponse')) { | ||
|
||
class CurlResponse { | ||
|
||
/** | ||
|
@@ -75,4 +77,6 @@ function __toString() { | |
return $this->body; | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,50 +6,54 @@ | |
* @package netlicensing | ||
* @author Labs64 <[email protected]> | ||
**/ | ||
class NetLicensing | ||
{ | ||
if (!class_exists('NetLicensing')) { | ||
|
||
const NLIC_BASE_URL = 'https://netlicensing.labs64.com/core/v2/rest'; | ||
class NetLicensing | ||
{ | ||
|
||
private $curl = null; | ||
const NLIC_BASE_URL = 'https://netlicensing.labs64.com/core/v2/rest'; | ||
|
||
/** | ||
* Initializes a NetLicensing object | ||
**/ | ||
function __construct($apiKey) | ||
{ | ||
$user_agent = 'NetLicensing/PHP ' . PHP_VERSION . ' (http://netlicensing.labs64.com)' . '; ' . $_SERVER['HTTP_USER_AGENT']; | ||
private $curl = null; | ||
|
||
$this->curl = new Curl(); | ||
$this->curl->headers['Authorization'] = 'Basic ' . base64_encode("apiKey:" . $apiKey); | ||
$this->curl->headers['Accept'] = 'application/json'; | ||
$this->curl->user_agent = $user_agent; | ||
} | ||
/** | ||
* Initializes a NetLicensing object | ||
**/ | ||
function __construct($apiKey) | ||
{ | ||
$user_agent = 'NetLicensing/PHP ' . PHP_VERSION . ' (http://netlicensing.labs64.com)' . '; ' . $_SERVER['HTTP_USER_AGENT']; | ||
|
||
/** | ||
* Validates active licenses of the licensee | ||
* | ||
* Returns a object containing licensee validation result | ||
* | ||
* @param string $productNumber | ||
* @param string $licenseeNumber | ||
* @param string $licenseeName | ||
* @return licensee validation result | ||
**/ | ||
function validate($productNumber, $licenseeNumber, $licenseeName = '') | ||
{ | ||
if (empty($licenseeName)) { | ||
$licenseeName = $licenseeNumber; | ||
$this->curl = new Curl(); | ||
$this->curl->headers['Authorization'] = 'Basic ' . base64_encode("apiKey:" . $apiKey); | ||
$this->curl->headers['Accept'] = 'application/json'; | ||
$this->curl->user_agent = $user_agent; | ||
} | ||
$params = array( | ||
'productNumber' => $productNumber, | ||
'name' => $licenseeName, | ||
); | ||
$url = self::NLIC_BASE_URL . '/licensee/' . $licenseeNumber . '/validate'; | ||
|
||
$response = $this->curl->get($url, $params); | ||
/** | ||
* Validates active licenses of the licensee | ||
* | ||
* Returns a object containing licensee validation result | ||
* | ||
* @param string $productNumber | ||
* @param string $licenseeNumber | ||
* @param string $licenseeName | ||
* @return licensee validation result | ||
**/ | ||
function validate($productNumber, $licenseeNumber, $licenseeName = '') | ||
{ | ||
if (empty($licenseeName)) { | ||
$licenseeName = $licenseeNumber; | ||
} | ||
$params = array( | ||
'productNumber' => $productNumber, | ||
'name' => $licenseeName, | ||
); | ||
$url = self::NLIC_BASE_URL . '/licensee/' . $licenseeNumber . '/validate'; | ||
|
||
$response = $this->curl->get($url, $params); | ||
|
||
return $response->body; | ||
} | ||
|
||
return $response->body; | ||
} | ||
|
||
} |