Search in sources :

Example 21 with Subscription

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();
}
Also used : Account(org.killbill.billing.account.api.Account) SubscriptionJson(org.killbill.billing.jaxrs.json.SubscriptionJson) TenantContext(org.killbill.billing.util.callcontext.TenantContext) Subscription(org.killbill.billing.entitlement.api.Subscription) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Subscription (org.killbill.billing.entitlement.api.Subscription)21 LocalDate (org.joda.time.LocalDate)15 Account (org.killbill.billing.account.api.Account)12 Test (org.testng.annotations.Test)12 UUID (java.util.UUID)11 Entitlement (org.killbill.billing.entitlement.api.Entitlement)10 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiResponses (io.swagger.annotations.ApiResponses)8 BigDecimal (java.math.BigDecimal)8 Produces (javax.ws.rs.Produces)8 DefaultEntitlement (org.killbill.billing.entitlement.api.DefaultEntitlement)8 Invoice (org.killbill.billing.invoice.api.Invoice)8 Path (javax.ws.rs.Path)7 DateTime (org.joda.time.DateTime)7 ExpectedInvoiceItemCheck (org.killbill.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck)7 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)7 DefaultEntitlementSpecifier (org.killbill.billing.entitlement.api.DefaultEntitlementSpecifier)7 TenantContext (org.killbill.billing.util.callcontext.TenantContext)6 TimedResource (org.killbill.commons.metrics.TimedResource)6 GET (javax.ws.rs.GET)5