Skip to content

Commit b3f188b

Browse files
authored
Extend shop token for bundle acquisition (#50)
1 parent 6a9850c commit b3f188b

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public static final class Token {
5858
public static final String TOKEN_PROP_VENDORNUMBER = "vendorNumber";
5959
public static final String TOKEN_PROP_SHOP_URL = "shopURL";
6060
public static final String TOKEN_PROP_PRIVATE_KEY = "privateKey";
61+
public static final String TOKEN_PROP_BUNDLE_NUMBER = "bundleNumber";
62+
public static final String TOKEN_PROP_BUNDLE_PRICE = "bundlePrice";
6163
}
6264

6365
public static final class Vendor {

NetLicensingClient/src/main/java/com/labs64/netlicensing/service/BundleService.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ public static void delete(final Context context, final String number)
120120
* @param context determines the vendor on whose behalf the call is performed
121121
* @param number bundle number
122122
* @param licenseeNumber licensee number
123+
* @param transactionNumber transaction number
123124
* @return collection of created licenses.
124125
* @throws NetLicensingException any subclass of {@linkplain NetLicensingException}. These exceptions will be transformed to the
125126
* corresponding service response messages.
126127
*/
127-
public static Page<License> obtain(final Context context, final String number, final String licenseeNumber)
128+
public static Page<License> obtain(final Context context, final String number, final String licenseeNumber,
129+
final String transactionNumber)
128130
throws NetLicensingException {
129131
CheckUtils.paramNotEmpty(number, "number");
130132
CheckUtils.paramNotEmpty(licenseeNumber, "licenseeNumber");
@@ -134,8 +136,28 @@ public static Page<License> obtain(final Context context, final String number, f
134136
final Form form = new Form();
135137
form.param(Constants.Licensee.LICENSEE_NUMBER, licenseeNumber);
136138

137-
final Netlicensing response = NetLicensingService.getInstance().request(context, HttpMethod.POST, endpoint, form, null);
139+
if (StringUtils.isNotBlank(transactionNumber)) {
140+
form.param(Constants.Transaction.TRANSACTION_NUMBER, transactionNumber);
141+
}
142+
143+
final Netlicensing response = NetLicensingService.getInstance()
144+
.request(context, HttpMethod.POST, endpoint, form, null);
138145

139146
return entityFactory.createPage(response, License.class);
140147
}
148+
149+
/**
150+
* Obtain bundle(create licenses from a bundle license templates).
151+
*
152+
* @param context determines the vendor on whose behalf the call is performed
153+
* @param number bundle number
154+
* @param licenseeNumber licensee number
155+
* @return collection of created licenses.
156+
* @throws NetLicensingException any subclass of {@linkplain NetLicensingException}. These exceptions will be transformed to the
157+
* corresponding service response messages.
158+
*/
159+
public static Page<License> obtain(final Context context, final String number, final String licenseeNumber)
160+
throws NetLicensingException {
161+
return obtain(context, number,licenseeNumber, null);
162+
}
141163
}

0 commit comments

Comments
 (0)