Skip to content

Commit 8754803

Browse files
committed
Replace constants to common Constants class (add @deprecated tag)
1 parent 61f5998 commit 8754803

16 files changed

Lines changed: 247 additions & 73 deletions

Constants.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

common/Constants.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/**
3+
* @author Labs64 <netlicensing@labs64.com>
4+
* @license Apache-2.0
5+
* @link http://netlicensing.io
6+
* @copyright 2017 Labs64 NetLicensing
7+
*/
8+
9+
namespace NetLicensing;
10+
11+
12+
class Constants
13+
{
14+
/**
15+
* Security modes
16+
*/
17+
const BASIC_AUTHENTICATION = 'BASIC_AUTH';
18+
const APIKEY_IDENTIFICATION = 'APIKEY';
19+
20+
const XML_NS = 'http://netlicensing.labs64.com/schema/context';
21+
22+
/**
23+
* Licensing Models
24+
*/
25+
const LICENSING_MODEL_TRY_AND_BUY = "TryAndBuy";
26+
const LICENSING_MODEL_RENTAL = "Rental";
27+
const LICENSING_MODEL_SUBSCRIPTION = "Subscription";
28+
const LICENSING_MODEL_FLOATING = "Floating";
29+
const LICENSING_MODEL_MULTI_FEATURE = "MultiFeature";
30+
const LICENSING_MODEL_MULTI_PAY_PER_USE = "PayPerUse";
31+
const LICENSING_MODEL_PRICING_TABLE = "PricingTable";
32+
const LICENSING_MODEL_QUOTA = "Quota";
33+
34+
/**
35+
* Licensee
36+
*/
37+
const LICENSEE_ENDPOINT_PATH = 'licensee';
38+
const LICENSEE_ENDPOINT_PATH_VALIDATE = 'validate';
39+
const LICENSEE_ENDPOINT_PATH_TRANSFER = 'transfer';
40+
41+
/**
42+
* License
43+
*/
44+
const LICENSE_ENDPOINT_PATH = 'license';
45+
46+
/*
47+
* License Template
48+
*/
49+
const LICENSE_TEMPLATE_ENDPOINT_PATH = 'licensetemplate';
50+
51+
/**
52+
* Payment Method
53+
*/
54+
const PAYMENT_METHOD_ENDPOINT_PATH = 'paymentmethod';
55+
56+
/**
57+
* Product Module
58+
*/
59+
const PRODUCT_MODULE_ENDPOINT_PATH = 'productmodule';
60+
61+
/*
62+
* Product
63+
*/
64+
const PRODUCT_ENDPOINT_PATH = 'product';
65+
66+
/*
67+
* Token
68+
*/
69+
const TOKEN_ENDPOINT_PATH = 'token';
70+
71+
/*
72+
* Transaction
73+
*/
74+
const TRANSACTION_ENDPOINT_PATH = 'transaction';
75+
76+
/**
77+
* Utility
78+
*/
79+
const UTILITY_ENDPOINT_PATH = 'utility';
80+
}
81+
82+
83+
84+

demo/NetLicensingDemo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class NetLicensingDemo
1414
{
1515
const BASE_URL = 'https://go.netlicensing.io/core/v2/rest';
16-
const SECURITY_MODE = \NetLicensing\Context::BASIC_AUTHENTICATION;
16+
const SECURITY_MODE = \NetLicensing\Constants::BASIC_AUTHENTICATION;
1717
const USERNAME = 'demo';
1818
const PASSWORD = 'demo';
1919

entity/ProductModule.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,55 @@
6464
*/
6565
class ProductModule extends BaseEntity
6666
{
67+
/**
68+
* @deprecated
69+
* No longer used by internal code and not recommended, will be removed in future versions.
70+
* Use class Constants::LICENSING_MODEL_TRY_AND_BUY instead.
71+
*/
72+
const LICENSING_MODEL_TRY_AND_BUY = "TryAndBuy";
73+
/**
74+
* @deprecated
75+
* No longer used by internal code and not recommended, will be removed in future versions.
76+
* Use class Constants::LICENSING_MODEL_RENTAL instead.
77+
*/
78+
const LICENSING_MODEL_RENTAL = "Rental";
79+
/**
80+
* @deprecated
81+
* No longer used by internal code and not recommended, will be removed in future versions.
82+
* Use class Constants::LICENSING_MODEL_SUBSCRIPTION instead.
83+
*/
84+
const LICENSING_MODEL_SUBSCRIPTION = "Subscription";
85+
/**
86+
* @deprecated
87+
* No longer used by internal code and not recommended, will be removed in future versions.
88+
* Use class Constants::LICENSING_MODEL_FLOATING instead.
89+
*/
90+
const LICENSING_MODEL_FLOATING = "Floating";
91+
/**
92+
* @deprecated
93+
* No longer used by internal code and not recommended, will be removed in future versions.
94+
* Use class Constants::LICENSING_MODEL_MULTI_FEATURE instead.
95+
*/
96+
const LICENSING_MODEL_MULTI_FEATURE = "MultiFeature";
97+
/**
98+
* @deprecated
99+
* No longer used by internal code and not recommended, will be removed in future versions.
100+
* Use class Constants::LICENSING_MODEL_MULTI_PAY_PER_USE instead.
101+
*/
102+
const LICENSING_MODEL_MULTI_PAY_PER_USE = "PayPerUse";
103+
/**
104+
* @deprecated
105+
* No longer used by internal code and not recommended, will be removed in future versions.
106+
* Use class Constants::LICENSING_MODEL_PRICING_PLANS instead.
107+
*/
108+
const LICENSING_MODEL_PRICING_PLANS = "PricingPlans";
109+
/**
110+
* @deprecated
111+
* No longer used by internal code and not recommended, will be removed in future versions.
112+
* Use class Constants::LICENSING_MODEL_QUOTA instead.
113+
*/
114+
const LICENSING_MODEL_QUOTA = "Quota";
115+
67116
/**
68117
* The attributes that should be cast to native types.
69118
*

netlicensing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @copyright 2017 Labs64 NetLicensing
77
*/
88

9-
require_once(__DIR__ . '/Constants.php');
9+
require_once(__DIR__ . '/common/Constants.php');
1010

1111
require_once(__DIR__ . '/vo/Context.php');
1212
require_once(__DIR__ . '/vo/NetLicensingCurl.php');

service/LicenseService.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
*/
1717
class LicenseService
1818
{
19+
/**
20+
* @deprecated
21+
* No longer used by internal code and not recommended, will be removed in future versions.
22+
* Use class Constants::LICENSE_ENDPOINT_PATH instead.
23+
*/
1924
const ENDPOINT_PATH = 'license';
2025

2126
/**
@@ -56,7 +61,7 @@ public static function create(Context $context, $licenseeNumber, $licenseTemplat
5661

5762
if ($transactionNumber) $license->setProperty('transactionNumber', $transactionNumber);
5863

59-
return NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH, $license->asPropertiesMap(), $license);
64+
return NetLicensingService::getInstance()->post($context, Constants::LICENSE_ENDPOINT_PATH, $license->asPropertiesMap(), $license);
6065
}
6166

6267
/**
@@ -78,7 +83,7 @@ public static function get(Context $context, $number)
7883

7984
CheckUtils::paramNotEmpty($number, 'number');
8085

81-
return NetLicensingService::getInstance()->get($context, self::ENDPOINT_PATH . '/' . $number, [], License::class);
86+
return NetLicensingService::getInstance()->get($context, Constants::LICENSE_ENDPOINT_PATH . '/' . $number, [], License::class);
8287
}
8388

8489
/**
@@ -100,7 +105,7 @@ public static function getList(Context $context, $filter = null)
100105

101106
$queryParams = (!is_null($filter)) ? ['filter' => $filter] : [];
102107

103-
return NetLicensingService::getInstance()->getList($context, self::ENDPOINT_PATH, $queryParams, License::class);
108+
return NetLicensingService::getInstance()->getList($context, Constants::LICENSE_ENDPOINT_PATH, $queryParams, License::class);
104109
}
105110

106111
/**
@@ -131,7 +136,7 @@ public static function update(Context $context, $number, $transactionNumber = nu
131136

132137
if ($transactionNumber) $license->setProperty('transactionNumber', $transactionNumber);
133138

134-
return NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH . '/' . $number, $license->asPropertiesMap(), $license);
139+
return NetLicensingService::getInstance()->post($context, Constants::LICENSE_ENDPOINT_PATH . '/' . $number, $license->asPropertiesMap(), $license);
135140
}
136141

137142
/**
@@ -159,6 +164,6 @@ public static function delete(Context $context, $number, $forceCascade = false)
159164

160165
$queryParams['forceCascade'] = ((bool)$forceCascade) ? 'true' : 'false';
161166

162-
return NetLicensingService::getInstance()->delete($context, self::ENDPOINT_PATH . '/' . $number, $queryParams);
167+
return NetLicensingService::getInstance()->delete($context, Constants::LICENSE_ENDPOINT_PATH . '/' . $number, $queryParams);
163168
}
164169
}

service/LicenseTemplateService.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
*/
1717
class LicenseTemplateService
1818
{
19+
/**
20+
* @deprecated
21+
* No longer used by internal code and not recommended, will be removed in future versions.
22+
* Use class Constants::LICENSE_TEMPLATE_ENDPOINT_PATH instead.
23+
*/
1924
const ENDPOINT_PATH = 'licensetemplate';
2025

2126
/**
@@ -43,7 +48,7 @@ public static function create(Context $context, $productModuleNumber, LicenseTem
4348

4449
$licenseTemplate->setProperty('productModuleNumber', $productModuleNumber);
4550

46-
return NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH, $licenseTemplate->asPropertiesMap(), $licenseTemplate);
51+
return NetLicensingService::getInstance()->post($context, Constants::LICENSE_TEMPLATE_ENDPOINT_PATH, $licenseTemplate->asPropertiesMap(), $licenseTemplate);
4752
}
4853

4954
/**
@@ -65,7 +70,7 @@ public static function get(Context $context, $number)
6570

6671
$context->setSecurityMode(Context::BASIC_AUTHENTICATION);
6772

68-
return NetLicensingService::getInstance()->get($context, self::ENDPOINT_PATH . '/' . $number, [], LicenseTemplate::class);
73+
return NetLicensingService::getInstance()->get($context, Constants::LICENSE_TEMPLATE_ENDPOINT_PATH . '/' . $number, [], LicenseTemplate::class);
6974
}
7075

7176
/**
@@ -87,7 +92,7 @@ public static function getList(Context $context, $filter = null)
8792

8893
$queryParams = (!is_null($filter)) ? ['filter' => $filter] : [];
8994

90-
return NetLicensingService::getInstance()->getList($context, self::ENDPOINT_PATH, $queryParams, LicenseTemplate::class);
95+
return NetLicensingService::getInstance()->getList($context, Constants::LICENSE_TEMPLATE_ENDPOINT_PATH, $queryParams, LicenseTemplate::class);
9196
}
9297

9398
/**
@@ -112,7 +117,7 @@ public static function update(Context $context, $number, LicenseTemplate $licens
112117

113118
$context->setSecurityMode(Context::BASIC_AUTHENTICATION);
114119

115-
return NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH . '/' . $number, $licenseTemplate->asPropertiesMap(), $licenseTemplate);
120+
return NetLicensingService::getInstance()->post($context, Constants::LICENSE_TEMPLATE_ENDPOINT_PATH . '/' . $number, $licenseTemplate->asPropertiesMap(), $licenseTemplate);
116121
}
117122

118123
/**
@@ -138,6 +143,6 @@ public static function delete(Context $context, $number, $forceCascade = false)
138143

139144
$queryParams['forceCascade'] = ((bool)$forceCascade) ? 'true' : 'false';
140145

141-
return NetLicensingService::getInstance()->delete($context, self::ENDPOINT_PATH . '/' . $number, $queryParams);
146+
return NetLicensingService::getInstance()->delete($context, Constants::LICENSE_TEMPLATE_ENDPOINT_PATH . '/' . $number, $queryParams);
142147
}
143148
}

service/LicenseeService.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@
1616
*/
1717
class LicenseeService
1818
{
19+
/**
20+
* @deprecated
21+
* No longer used by internal code and not recommended, will be removed in future versions.
22+
* Use class Constants::LICENSEE_ENDPOINT_PATH instead.
23+
*/
1924
const ENDPOINT_PATH = 'licensee';
25+
/**
26+
* @deprecated
27+
* No longer used by internal code and not recommended, will be removed in future versions.
28+
* Use class Constants::LICENSEE_ENDPOINT_PATH_VALIDATE instead.
29+
*/
2030
const ENDPOINT_PATH_VALIDATE = 'validate';
31+
/**
32+
* @deprecated
33+
* No longer used by internal code and not recommended, will be removed in future versions.
34+
* Use class Constants::LICENSEE_ENDPOINT_PATH_TRANSFER instead.
35+
*/
2136
const ENDPOINT_PATH_TRANSFER = 'transfer';
2237

2338
/**
@@ -43,7 +58,7 @@ public static function create(Context $context, $productNumber, Licensee $licens
4358

4459
$licensee->setProperty('productNumber', $productNumber);
4560

46-
return NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH, $licensee->asPropertiesMap(), $licensee);
61+
return NetLicensingService::getInstance()->post($context, Constants::LICENSEE_ENDPOINT_PATH, $licensee->asPropertiesMap(), $licensee);
4762
}
4863

4964
/**
@@ -63,7 +78,7 @@ public static function get(Context $context, $number)
6378
{
6479
CheckUtils::paramNotEmpty($number, 'number');
6580

66-
return NetLicensingService::getInstance()->get($context, self::ENDPOINT_PATH . '/' . $number, [], Licensee::class);
81+
return NetLicensingService::getInstance()->get($context, Constants::LICENSEE_ENDPOINT_PATH . '/' . $number, [], Licensee::class);
6782
}
6883

6984
/**
@@ -83,7 +98,7 @@ public static function getList(Context $context, $filter = null)
8398
{
8499
$queryParams = (!is_null($filter)) ? ['filter' => $filter] : [];
85100

86-
return NetLicensingService::getInstance()->getList($context, self::ENDPOINT_PATH, $queryParams, Licensee::class);
101+
return NetLicensingService::getInstance()->getList($context, Constants::LICENSEE_ENDPOINT_PATH, $queryParams, Licensee::class);
87102
}
88103

89104
/**
@@ -106,7 +121,7 @@ public static function update(Context $context, $number, Licensee $licensee)
106121
{
107122
CheckUtils::paramNotEmpty($number, 'number');
108123

109-
return NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH . '/' . $number, $licensee->asPropertiesMap(), $licensee);
124+
return NetLicensingService::getInstance()->post($context, Constants::LICENSEE_ENDPOINT_PATH . '/' . $number, $licensee->asPropertiesMap(), $licensee);
110125
}
111126

112127
/**
@@ -130,7 +145,7 @@ public static function delete(Context $context, $number, $forceCascade = false)
130145

131146
$queryParams['forceCascade'] = ((bool)$forceCascade) ? 'true' : 'false';
132147

133-
return NetLicensingService::getInstance()->delete($context, self::ENDPOINT_PATH . '/' . $number, $queryParams);
148+
return NetLicensingService::getInstance()->delete($context, Constants::LICENSEE_ENDPOINT_PATH . '/' . $number, $queryParams);
134149
}
135150

136151

@@ -177,7 +192,7 @@ public static function validate(Context $context, $number, ValidationParameters
177192
$pmIndex++;
178193
}
179194

180-
$data = NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH . '/' . $number . '/' . self::ENDPOINT_PATH_VALIDATE, $queryParams);
195+
$data = NetLicensingService::getInstance()->post($context, Constants::LICENSEE_ENDPOINT_PATH . '/' . $number . '/' . Constants::LICENSEE_ENDPOINT_PATH_VALIDATE, $queryParams);
181196

182197
$validationResults = new ValidationResults();
183198
$validationResults->setProductModuleValidation($data['productModuleNumber'], $data);
@@ -208,6 +223,6 @@ public static function transfer(Context $context, $number, $sourceLicenseeNumber
208223

209224
$queryParams['sourceLicenseeNumber'] = $sourceLicenseeNumber;
210225

211-
NetLicensingService::getInstance()->post($context, self::ENDPOINT_PATH . '/' . $number . '/' . self::ENDPOINT_PATH_TRANSFER, $queryParams);
226+
NetLicensingService::getInstance()->post($context, Constants::LICENSEE_ENDPOINT_PATH . '/' . $number . '/' . Constants::LICENSEE_ENDPOINT_PATH_TRANSFER, $queryParams);
212227
}
213228
}

0 commit comments

Comments
 (0)