77#include " netlicensing/validation_parameters.h"
88#include " netlicensing/context.h"
99#include " netlicensing/constants.h"
10+ #include " netlicensing/datatypes.h"
11+ #include " netlicensing/entity.h"
1012
1113void cleanUp (netlicensing::Context& ctx, const std::string& productNumber, bool forceCascade) {
1214 // clean up
@@ -58,17 +60,15 @@ int main(int argc, char* argv[]) {
5860 if (licenseTypes.size ()) {
5961 std::cout << " License Types:" << std::endl;
6062 for (auto const & i : licenseTypes) {
61- std::string licenseTypesString = i.toString ();
62- std::cout << licenseTypesString << std::endl;
63+ std::cout << i.toString () << std::endl;
6364 }
6465 }
6566
6667 std::list<LicensingModel> licensingModels = UtilityService::listLicensingModels (ctx);
6768 if (licensingModels.size ()) {
6869 std::cout << " LicensingModel:" << std::endl;
6970 for (auto const & i : licensingModels) {
70- std::string licensingModelString = i.toString ();
71- std::cout << licensingModelString << std::endl;
71+ std::cout << i.toString () << std::endl;
7272 }
7373 }
7474
@@ -91,8 +91,7 @@ int main(int argc, char* argv[]) {
9191 if (products.size ()) {
9292 std::cout << " Got the following products:" << std::endl;
9393 for (auto const & i : products) {
94- productString = i.toString ();
95- std::cout << productString << std::endl;
94+ std::cout << i.toString () << std::endl;
9695 }
9796 }
9897
@@ -110,8 +109,7 @@ int main(int argc, char* argv[]) {
110109 if (products.size ()) {
111110 std::cout << " Got the following products:" << std::endl;
112111 for (auto const & i : products) {
113- productString = i.toString ();
114- std::cout << productString << std::endl;
112+ std::cout << i.toString () << std::endl;
115113 }
116114 }
117115
@@ -124,8 +122,7 @@ int main(int argc, char* argv[]) {
124122 if (products.size ()) {
125123 std::cout << " Got the following products:" << std::endl;
126124 for (auto const & i : products) {
127- productString = i.toString ();
128- std::cout << productString << std::endl;
125+ std::cout << i.toString () << std::endl;
129126 }
130127 }
131128
@@ -150,8 +147,7 @@ int main(int argc, char* argv[]) {
150147 if (productModules.size ()) {
151148 std::cout << " Got the following product modules: " << std::endl;
152149 for (auto const & i : productModules) {
153- productModuleString = i.toString ();
154- std::cout << productModuleString << std::endl;
150+ std::cout << i.toString () << std::endl;
155151 }
156152 }
157153
@@ -167,8 +163,7 @@ int main(int argc, char* argv[]) {
167163 if (productModules.size ()) {
168164 std::cout << " Got the following product modules: " << std::endl;
169165 for (auto const & i : productModules) {
170- productModuleString = i.toString ();
171- std::cout << productModuleString << std::endl;
166+ std::cout << i.toString () << std::endl;
172167 }
173168 }
174169
@@ -180,8 +175,7 @@ int main(int argc, char* argv[]) {
180175 if (productModules.size ()) {
181176 std::cout << " Got the following product modules: " << std::endl;
182177 for (auto const & i : productModules) {
183- productModuleString = i.toString ();
184- std::cout << productModuleString << std::endl;
178+ std::cout << i.toString () << std::endl;
185179 }
186180 }
187181
@@ -192,9 +186,9 @@ int main(int argc, char* argv[]) {
192186 LicenseTemplate newLicenseTemplate;
193187 newLicenseTemplate.setNumber (licenseTemplateNumber);
194188 newLicenseTemplate.setName (" Demo Evaluation Period" );
195- newLicenseTemplate.setLicenseType (" FEATURE" );
196- newLicenseTemplate.setPrice (" 12.5 " );
197- newLicenseTemplate.setCurrency (" EUR" );
189+ newLicenseTemplate.setLicenseType (LicenseTypeEnum:: FEATURE);
190+ newLicenseTemplate.setPrice (FixedPoint ( " 12.50 " ) );
191+ newLicenseTemplate.setCurrency (Currency:: EUR);
198192 newLicenseTemplate.setAutomatic (false );
199193 newLicenseTemplate.setHidden (false );
200194 newLicenseTemplate.setProductModuleNumber (productModuleNumber);
@@ -209,8 +203,7 @@ int main(int argc, char* argv[]) {
209203 if (licenseTemplates.size ()) {
210204 std::cout << " Got the following license templates: " << std::endl;
211205 for (auto const & i : licenseTemplates) {
212- licenseTemplateString = i.toString ();
213- std::cout << licenseTemplateString << std::endl;
206+ std::cout << i.toString () << std::endl;
214207 }
215208 }
216209
@@ -226,8 +219,7 @@ int main(int argc, char* argv[]) {
226219 if (licenseTemplates.size ()) {
227220 std::cout << " Got the following license templates: " << std::endl;
228221 for (auto const & i : licenseTemplates) {
229- licenseTemplateString = i.toString ();
230- std::cout << licenseTemplateString << std::endl;
222+ std::cout << i.toString () << std::endl;
231223 }
232224 }
233225
@@ -239,8 +231,7 @@ int main(int argc, char* argv[]) {
239231 if (licenseTemplates.size ()) {
240232 std::cout << " Got the following license templates: " << std::endl;
241233 for (auto const & i : licenseTemplates) {
242- licenseTemplateString = i.toString ();
243- std::cout << licenseTemplateString << std::endl;
234+ std::cout << i.toString () << std::endl;
244235 }
245236 }
246237
@@ -261,8 +252,7 @@ int main(int argc, char* argv[]) {
261252 if (licensees.size ()) {
262253 std::cout << " Got the following licensees:" << std::endl;
263254 for (auto const & i : licensees) {
264- licenseeString = i.toString ();
265- std::cout << licenseeString << std::endl;
255+ std::cout << i.toString () << std::endl;
266256 }
267257 }
268258
@@ -273,8 +263,7 @@ int main(int argc, char* argv[]) {
273263 if (licensees.size ()) {
274264 std::cout << " Got the following licensees after delete: " << std::endl;
275265 for (auto const & i : licensees) {
276- licenseeString = i.toString ();
277- std::cout << licenseeString << std::endl;
266+ std::cout << i.toString () << std::endl;
278267 }
279268 }
280269
@@ -294,6 +283,7 @@ int main(int argc, char* argv[]) {
294283 newLicense.setNumber (licenseNumber);
295284 newLicense.setLicenseTemplateNumber (licenseTemplateNumber);
296285 newLicense.setLicenseeNumber (licenseeNumber);
286+ newLicense.setPrice (FixedPoint (" 1.00" ));
297287 License license = LicenseService::create (ctx, newLicense);
298288 std::cout << " Added license: " << license.getName ().toString () << std::endl;
299289
@@ -303,8 +293,7 @@ int main(int argc, char* argv[]) {
303293 if (licenses.size ()) {
304294 std::cout << " Got the following licenses:" << std::endl;
305295 for (auto const & i : licenses) {
306- licenseString = i.toString ();
307- std::cout << licenseString << std::endl;
296+ std::cout << i.toString () << std::endl;
308297 }
309298 }
310299
@@ -315,8 +304,7 @@ int main(int argc, char* argv[]) {
315304 if (licenses.size ()) {
316305 std::cout << " Got the following licenses: " << std::endl;
317306 for (auto const & i : licenses) {
318- licenseString = i.toString ();
319- std::cout << licenseString << std::endl;
307+ std::cout << i.toString () << std::endl;
320308 }
321309 }
322310
@@ -335,8 +323,7 @@ int main(int argc, char* argv[]) {
335323 if (paymentMethods.size ()) {
336324 std::cout << " Got the payment methods:" << std::endl;
337325 for (auto const & i : paymentMethods) {
338- std::string paymentMethodString = i.toString ();
339- std::cout << paymentMethodString << std::endl;
326+ std::cout << i.toString () << std::endl;
340327 }
341328 }
342329
@@ -345,11 +332,11 @@ int main(int argc, char* argv[]) {
345332 // region ********* Token
346333
347334 Token newToken;
348- newToken.setTokenType (" APIKEY" );
335+ newToken.setTokenType (TokenType:: APIKEY);
349336 Token apiKey = TokenService::create (ctx, newToken);
350337 std::cout << " Created APIKey: " << apiKey.getNumber ().toString () << std::endl;
351338
352- newToken.setTokenType (" SHOP" );
339+ newToken.setTokenType (TokenType:: SHOP);
353340 newToken.addProperty (LICENSEE_NUMBER, licenseeNumber);
354341 ctx.set_security_mode (netlicensing::Context::APIKEY_IDENTIFICATION);
355342 ctx.set_api_key (apiKey.getNumber ().toString ());
@@ -358,30 +345,27 @@ int main(int argc, char* argv[]) {
358345 std::string tokenString (shopToken.toString ());
359346 std::cout << " Got the following shop token: " << tokenString << std::endl;
360347
361- std::list<Token> tokens = TokenService::list (ctx, std::string (TOKEN_TYPE)+" =SHOP " );
348+ std::list<Token> tokens = TokenService::list (ctx, std::string (TOKEN_TYPE)+" =" + tokenTypeToString (TokenType::SHOP) );
362349 if (tokens.size ()) {
363350 std::cout << " Got the following shop tokens: " << std::endl;
364351 for (auto const & i : tokens) {
365- tokenString = i.toString ();
366- std::cout << tokenString << std::endl;
352+ std::cout << i.toString () << std::endl;
367353 }
368354 }
369355
370356 TokenService::del (ctx, shopToken.getNumber (), true );
371357 std::cout << " Deleted shop token!" << std::endl;
372358
373- tokens = TokenService::list (ctx, std::string (TOKEN_TYPE)+" =SHOP " );
359+ tokens = TokenService::list (ctx, std::string (TOKEN_TYPE)+" =" + tokenTypeToString (TokenType::SHOP) );
374360 if (tokens.size ()) {
375361 std::cout << " Got the following shop tokens after delete: " << std::endl;
376362 for (auto const & i : tokens) {
377- tokenString = i.toString ();
378- std::cout << tokenString << std::endl;
363+ std::cout << i.toString () << std::endl;
379364 }
380365 }
381366
382367 // endregion
383368
384-
385369 // region ********* Validate
386370
387371 ValidationParameters vParams = ValidationParameters ();
@@ -415,8 +399,7 @@ int main(int argc, char* argv[]) {
415399 if (licenses.size ()) {
416400 std::cout << " Got the following licenses after transfer:" << std::endl;
417401 for (auto const & i : licenses) {
418- licenseString = i.toString ();
419- std::cout << licenseString << std::endl;
402+ std::cout << i.toString () << std::endl;
420403 }
421404 }
422405
@@ -441,8 +424,7 @@ int main(int argc, char* argv[]) {
441424 if (licenses.size ()) {
442425 std::cout << " Got the following licenses after transfer: " << std::endl;
443426 for (auto const & i : licenses) {
444- licenseString = i.toString ();
445- std::cout << licenseString << std::endl;
427+ std::cout << i.toString () << std::endl;
446428 }
447429 }
448430
@@ -453,17 +435,15 @@ int main(int argc, char* argv[]) {
453435 if (transactions.size ()) {
454436 std::cout << " Got the following transactions shop only: " << std::endl;
455437 for (auto const & i : transactions) {
456- std::string transactionString (i.toString ());
457- std::cout << transactionString << std::endl;
438+ std::cout << i.toString () << std::endl;
458439 }
459440 }
460441
461442 transactions = TransactionService::list (ctx, " " );
462443 if (transactions.size ()) {
463444 std::cout << " Got the following transactions after transfer: " << std::endl;
464445 for (auto const & i : transactions) {
465- std::string transactionString (i.toString ());
466- std::cout << transactionString << std::endl;
446+ std::cout << i.toString () << std::endl;
467447 }
468448 }
469449
0 commit comments