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

catalog: revisit simple plan validation #1046

Merged
merged 1 commit into from Oct 5, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -282,10 +282,10 @@ private boolean isCurrencySupported(final Currency targetCurrency) {
}

private void validateNewPlanDescriptor(final SimplePlanDescriptor desc) throws CatalogApiException {
if (desc.getProductCategory() == null ||
desc.getBillingPeriod() == null ||
(desc.getAmount() == null || desc.getAmount().compareTo(BigDecimal.ZERO) < 0) ||
desc.getCurrency() == null) {
final boolean invalidPlan = desc.getPlanId() == null && (desc.getProductCategory() == null || desc.getBillingPeriod() == null);
final boolean invalidPrice = (desc.getAmount() == null || desc.getAmount().compareTo(BigDecimal.ZERO) < 0) ||
desc.getCurrency() == null;
if (invalidPlan || invalidPrice) {
throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, desc);
}

Expand Down
Expand Up @@ -492,6 +492,11 @@ public Integer getTrialLength() {
public TimeUnit getTrialTimeUnit() {
return simplePlan.getTrialTimeUnit();
}

@Override
public String toString() {
return simplePlan.toString();
}
};

catalogUserApi.addSimplePlan(desc, null, callContext);
Expand Down