Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NLIC-2444: Extend shop token for bundle acquisition #50

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public static final class Token {
public static final String TOKEN_PROP_VENDORNUMBER = "vendorNumber";
public static final String TOKEN_PROP_SHOP_URL = "shopURL";
public static final String TOKEN_PROP_PRIVATE_KEY = "privateKey";
public static final String TOKEN_PROP_BUNDLE_NUMBER = "bundleNumber";
public static final String TOKEN_PROP_BUNDLE_PRICE = "bundlePrice";
}

public static final class Vendor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ public static void delete(final Context context, final String number)
* @param context determines the vendor on whose behalf the call is performed
* @param number bundle number
* @param licenseeNumber licensee number
* @param transactionNumber transaction number
* @return collection of created licenses.
* @throws NetLicensingException any subclass of {@linkplain NetLicensingException}. These exceptions will be transformed to the
* corresponding service response messages.
*/
public static Page<License> obtain(final Context context, final String number, final String licenseeNumber)
public static Page<License> obtain(final Context context, final String number, final String licenseeNumber,
final String transactionNumber)
throws NetLicensingException {
CheckUtils.paramNotEmpty(number, "number");
CheckUtils.paramNotEmpty(licenseeNumber, "licenseeNumber");
Expand All @@ -134,8 +136,28 @@ public static Page<License> obtain(final Context context, final String number, f
final Form form = new Form();
form.param(Constants.Licensee.LICENSEE_NUMBER, licenseeNumber);

final Netlicensing response = NetLicensingService.getInstance().request(context, HttpMethod.POST, endpoint, form, null);
if (StringUtils.isNotBlank(transactionNumber)) {
form.param(Constants.Transaction.TRANSACTION_NUMBER, transactionNumber);
}

final Netlicensing response = NetLicensingService.getInstance()
.request(context, HttpMethod.POST, endpoint, form, null);

return entityFactory.createPage(response, License.class);
}

/**
* Obtain bundle(create licenses from a bundle license templates).
*
* @param context determines the vendor on whose behalf the call is performed
* @param number bundle number
* @param licenseeNumber licensee number
* @return collection of created licenses.
* @throws NetLicensingException any subclass of {@linkplain NetLicensingException}. These exceptions will be transformed to the
* corresponding service response messages.
*/
public static Page<License> obtain(final Context context, final String number, final String licenseeNumber)
throws NetLicensingException {
return obtain(context, number,licenseeNumber, null);
}
}