use of org.killbill.billing.entitlement.api.Subscription in project killbill by killbill.
the class SubscriptionResource method getSubscription.
@TimedResource
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a subscription by id", response = SubscriptionJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid subscription id supplied"), @ApiResponse(code = 404, message = "Subscription not found") })
public Response getSubscription(@PathParam("subscriptionId") final UUID subscriptionId, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException, AccountApiException, CatalogApiException {
final TenantContext context = this.context.createTenantContextNoAccountId(request);
final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(subscriptionId, context);
final Account account = accountUserApi.getAccountById(subscription.getAccountId(), context);
final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(subscription.getAccountId(), auditMode.getLevel(), context);
final SubscriptionJson json = new SubscriptionJson(subscription, account.getCurrency(), accountAuditLogs);
return Response.status(Status.OK).entity(json).build();
}
Aggregations