Skip to content

Commit 5ab273c

Browse files
committed
clean up
1 parent 8c01599 commit 5ab273c

18 files changed

Lines changed: 476 additions & 413 deletions

client_demo/netlicensing_client_demo.cc

Lines changed: 32 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
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

1113
void 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

include/netlicensing/constants.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <list>
55
#include <string>
6+
#include "netlicensing/datatypes.h"
67

78
namespace netlicensing {
89

@@ -12,7 +13,7 @@ namespace netlicensing {
1213
static const char* const NUMBER = "number";
1314
static const char* const NAME = "name";
1415
static const char* const VERSION = "version";
15-
static const char* const LICENSEE_AUTOCREATE = "licenseeAutoCreate";
16+
static const char* const DEPRECATED(LICENSEE_AUTOCREATE) = "licenseeAutoCreate";
1617
static const char* const DELETED = "deleted";
1718
static const char* const CASCADE = "forceCascade";
1819
static const char* const PRICE = "price";

include/netlicensing/converters.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace netlicensing {
3636
parameters_type params = toParametersList<BaseEntity>(value);
3737
params.push_back(std::make_pair(NAME, value.getName()));
3838
params.push_back(std::make_pair(VERSION, value.getVersion()));
39-
params.push_back(std::make_pair(LICENSEE_AUTOCREATE, value.getLicenseeAutoCreate().toString()));
39+
params.push_back(std::make_pair(LICENSEE_AUTO_CREATE, value.getLicenseeAutoCreate().toString()));
4040
params.push_back(std::make_pair(DESCRIPTION, value.getDescription()));
4141
params.push_back(std::make_pair(LICENSING_INFO, value.getLicensingInfo()));
4242

@@ -69,9 +69,9 @@ namespace netlicensing {
6969
parameters_type params = toParametersList<BaseEntity>(value);
7070
params.push_back(std::make_pair(NAME, value.getName()));
7171
params.push_back(std::make_pair(PRODUCT_MODULE_NUMBER, value.getProductModuleNumber()));
72-
params.push_back(std::make_pair(LICENSE_TYPE, value.getLicenseType()));
73-
params.push_back(std::make_pair(PRICE, value.getPrice()));
74-
params.push_back(std::make_pair(CURRENCY, value.getCurrency()));
72+
params.push_back(std::make_pair(LICENSE_TYPE, licenseTypeToString(value.getLicenseType())));
73+
params.push_back(std::make_pair(PRICE, value.getPrice().toString()));
74+
params.push_back(std::make_pair(CURRENCY, currencyToString(value.getCurrency())));
7575
params.push_back(std::make_pair(AUTOMATIC, value.getAutomatic().toString()));
7676
params.push_back(std::make_pair(HIDDEN, value.getHidden().toString()));
7777
params.push_back(std::make_pair(HIDE_LICENSES, value.getHideLicenses().toString()));
@@ -97,8 +97,8 @@ namespace netlicensing {
9797
inline parameters_type toParametersList<License>(License value) {
9898
parameters_type params = toParametersList<BaseEntity>(value);
9999
params.push_back(std::make_pair(NAME, value.getName()));
100-
params.push_back(std::make_pair(PRICE, value.getPrice()));
101-
params.push_back(std::make_pair(CURRENCY, value.getCurrency()));
100+
params.push_back(std::make_pair(PRICE, value.getPrice().toString()));
101+
params.push_back(std::make_pair(CURRENCY, currencyToString(value.getCurrency())));
102102
params.push_back(std::make_pair(HIDDEN, value.getHidden().toString()));
103103
params.push_back(std::make_pair(LICENSEE_NUMBER, value.getLicenseeNumber()));
104104
params.push_back(std::make_pair(LICENSE_TEMPLATE_NUMBER, value.getLicenseTemplateNumber()));
@@ -109,21 +109,21 @@ namespace netlicensing {
109109
inline parameters_type toParametersList<Token>(Token value) {
110110
parameters_type params = toParametersList<BaseEntity>(value);
111111
params.push_back(std::make_pair(VENDOR_NUMBER, value.getVendorNumber()));
112-
params.push_back(std::make_pair(EXPIRATION_TIME, value.getExpirationTime()));
113-
params.push_back(std::make_pair(TOKEN_TYPE, value.getTokenType()));
112+
params.push_back(std::make_pair(EXPIRATION_TIME, value.getExpirationTime().toString()));
113+
params.push_back(std::make_pair(TOKEN_TYPE, tokenTypeToString(value.getTokenType())));
114114
return params;
115115
}
116116

117117
template<>
118118
inline parameters_type toParametersList<Transaction>(Transaction value) {
119119
parameters_type params = toParametersList<BaseEntity>(value);
120-
params.push_back(std::make_pair(STATUS, value.getStatus()));
121-
params.push_back(std::make_pair(SOURCE, value.getSource()));
122-
params.push_back(std::make_pair(GRAND_TOTAL, value.getGrandTotal()));
123-
params.push_back(std::make_pair(DISCOUNT, value.getDiscount()));
124-
params.push_back(std::make_pair(CURRENCY, value.getCurrency()));
125-
params.push_back(std::make_pair(DATE_CREATED, value.getDateCreated()));
126-
params.push_back(std::make_pair(DATE_CLOSED, value.getDateClosed()));
120+
params.push_back(std::make_pair(STATUS, transactionStatusToString(value.getStatus())));
121+
params.push_back(std::make_pair(SOURCE, transactionSourceToString(value.getSource())));
122+
params.push_back(std::make_pair(GRAND_TOTAL, value.getGrandTotal().toString()));
123+
params.push_back(std::make_pair(DISCOUNT, value.getDiscount().toString()));
124+
params.push_back(std::make_pair(CURRENCY, currencyToString(value.getCurrency())));
125+
params.push_back(std::make_pair(DATE_CREATED, value.getDateCreated().toString()));
126+
params.push_back(std::make_pair(DATE_CLOSED, value.getDateClosed().toString()));
127127

128128
return params;
129129
}

include/netlicensing/country.h

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,18 @@ namespace netlicensing {
5151
return vatPercent_i;
5252
}
5353

54-
String_t toString() const {
55-
std::string name(this->getName());
56-
std::string isEu(this->getIsEu() == true?"true":"false");
57-
std::string code(this->getCode());
58-
std::string vatPercent(this->getVatPercent());
54+
std::string toString() const {
55+
std::string name(getName());
56+
std::string isEu(getIsEu() == true?"true":"false");
57+
std::string code(getCode());
58+
std::string vatPercent(getVatPercent());
5959

6060
std::stringstream ss;
6161
ss << "Country [";
62-
ss << NAME;
63-
ss << ": ";
64-
ss << name;
65-
ss << ", ";
66-
ss << "isEu: ";
67-
ss << isEu;
68-
ss << ", ";
69-
ss << "code: ";
70-
ss << code;
71-
ss << ", ";
72-
ss << "vatPercent: ";
73-
ss << vatPercent;
62+
ss << NAME << ": " << name << ", ";
63+
ss << "isEu: " << isEu << ", ";
64+
ss << "code: " << code << ", ";
65+
ss << "vatPercent: " << vatPercent;
7466
ss << "]";
7567
return ss.str();
7668
}

0 commit comments

Comments
 (0)