@@ -221,34 +221,25 @@ namespace netlicensing {
221
221
* Validates active licenses of the licensee. See NetLicensingAPI for details:
222
222
* https://netlicensing.io/wiki/licensee-services#validate-licensee
223
223
*/
224
+ [[deprecated(" Use LicenseeService::validate(Context, std::string, ValidationParameters) instead" )]]
224
225
ValidationResult LicenseeService::validate (Context& ctx,
225
226
const std::string& licenseeNumber,
226
227
const std::string& productNumber/* = std::string()*/ ,
227
228
const std::string& licenseeName/* = std::string()*/ ,
228
229
const parameters_type& validationParameters) {
229
230
230
- std::string endpoint = std::string (LICENSEE_ENDPOINT_PATH) + " / " + escape_string (licenseeNumber) + " / " + ENDPOINT_PATH_VALIDATE ;
231
- parameters_type params;
232
- if (!productNumber. empty ()) params. push_back ( std::make_pair (PRODUCT_NUMBER, escape_string ( productNumber)) );
233
- if (!licenseeName. empty ()) params. push_back ( std::make_pair (PROP_LICENSEE_NAME, escape_string ( licenseeName)) );
231
+ ValidationParameters vp ;
232
+
233
+ vp. setProductNumber ( productNumber);
234
+ vp. setLicenseeName ( licenseeName);
234
235
235
236
// Add licensing model specific validation parameters
236
237
for (parameters_type::const_iterator paramIt = validationParameters.begin ();
237
- paramIt != validationParameters.end (); ++paramIt) {
238
- params.push_back (std::make_pair (escape_string (paramIt->first ), escape_string (paramIt->second )));
239
- }
240
-
241
- long http_code;
242
- std::string res = ctx.post (endpoint, params, http_code);
243
- ValidationResult validationResult;
244
- ValidationResultMapper vrm (validationResult);
245
- traverse (vrm, res);
246
-
247
- if (http_code != 200 ) {
248
- throw RestException (vrm.getInfos (), http_code);
238
+ paramIt != validationParameters.end (); ++paramIt) {
239
+ vp.setLicenseeProperty (escape_string (paramIt->first ), escape_string (paramIt->second ));
249
240
}
250
241
251
- return validationResult ;
242
+ return LicenseeService::validate (ctx, licenseeNumber, vp) ;
252
243
}
253
244
254
245
/* *
@@ -265,19 +256,12 @@ namespace netlicensing {
265
256
if (!escape_string (validationParameters.getProductNumber ()).empty ()) {
266
257
params.push_back (std::make_pair (PRODUCT_NUMBER, escape_string (validationParameters.getProductNumber ())));
267
258
}
268
- if (!escape_string (validationParameters.getLicenseeName ()).empty ()) {
269
- params.push_back (std::make_pair (PROP_LICENSEE_NAME, escape_string (validationParameters.getLicenseeName ())));
270
- }
271
- #ifdef __clang__
272
- #pragma clang diagnostic push
273
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
274
- #endif
275
- if (!escape_string (validationParameters.getLicenseeSecret ()).empty ()) {
276
- params.push_back (std::make_pair (PROP_LICENSEE_SECRET, escape_string (validationParameters.getLicenseeSecret ())));
259
+
260
+ for (auto const & ent1 : validationParameters.getLicenseeProperties ()) {
261
+ auto const &key = ent1.first ;
262
+ auto const & value = ent1.second ;
263
+ params.push_back (std::make_pair (key, escape_string (value)));
277
264
}
278
- #ifdef __clang__
279
- #pragma clang diagnostic pop
280
- #endif
281
265
282
266
int paramIt = 0 ;
283
267
for (auto const &ent1 : validationParameters.getParameters ()) {
0 commit comments