Skip to content

Commit 4af249d

Browse files
committed
Add CreateTrialKey method
1 parent 0b4c550 commit 4af249d

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

src/main/java/io/cryptolens/methods/Key.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import io.cryptolens.internal.BasicResult;
44
import io.cryptolens.internal.HelperMethods;
5-
import io.cryptolens.models.ActivateModel;
5+
import io.cryptolens.models.*;
66
import io.cryptolens.internal.ActivateResult;
7-
import io.cryptolens.models.DeactivateModel;
8-
import io.cryptolens.models.LicenseKey;
97

108
import java.util.HashMap;
119
import java.util.Map;
@@ -92,4 +90,24 @@ public static boolean Deactivate (String token, DeactivateModel model) {
9290
return true;
9391
}
9492

93+
/**
94+
* <p>This method creates a license key that is time-limited, <a href="https://help.cryptolens.io/licensing-models/node-locked" target="_blank">node-locked</a>
95+
* and with the "Time-Limited" and "Trial" features set to true (which can be set by editing the
96+
* <a href="https://help.cryptolens.io/web-interface/feature-definitions" target="_blank">feature definitions</a> on the product page).
97+
* Note, by default, the trial will work for 15 days. To change this limit, you can set the <b>Feature Lock</b>
98+
* to the desired value, when creating the access token.</p>
99+
*
100+
* <p>If a trial key was already created for a certain machine code, this method will try to find the license
101+
* key and return it instead. However, this will only occur if the license key is still a trial key (based
102+
* on feature definitions) and is not blocked.</p>
103+
* @param token The access token with 'CreateTrialKey' permission.
104+
* @param model Method parameters.
105+
* @return A new license key or error message.
106+
*/
107+
public static CreateKeyResult CreateTrialKey(String token, CreateTrialKeyModel model) {
108+
Map<String,String> extraParams = new HashMap<>();
109+
extraParams.put("token", token);
110+
111+
return HelperMethods.SendRequestToWebAPI("key/createtrialkey", model, extraParams, CreateKeyResult.class);
112+
}
95113
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.cryptolens.models;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import io.cryptolens.internal.BasicResult;
5+
6+
public class CreateKeyResult extends BasicResult {
7+
@SerializedName(value = "key", alternate = {"Key"})
8+
public String Key;
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.cryptolens.models;
2+
3+
public class CreateTrialKeyModel {
4+
public int ProductId;
5+
public String MachineCode;
6+
7+
public CreateTrialKeyModel(int productId, String machineCode) {
8+
ProductId = productId;
9+
MachineCode = machineCode;
10+
}
11+
}

0 commit comments

Comments
 (0)