Skip to content

Commit

Permalink
Extend shop token for bundle acquisition (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rudkovskiy authored Jul 15, 2024
1 parent 6a9850c commit b3f188b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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);
}
}

0 comments on commit b3f188b

Please sign in to comment.