Search in sources :

Example 1 with CreditJson

use of org.killbill.billing.jaxrs.json.CreditJson in project killbill by killbill.

the class CreditResource method getCredit.

@GET
@Path("/{creditId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a credit by id", response = CreditJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid credit id supplied"), @ApiResponse(code = 404, message = "Credit not found") })
public Response getCredit(@PathParam("creditId") final String creditId, @javax.ws.rs.core.Context final HttpServletRequest request) throws InvoiceApiException, AccountApiException {
    final TenantContext tenantContext = context.createContext(request);
    final InvoiceItem credit = invoiceUserApi.getCreditById(UUID.fromString(creditId), tenantContext);
    final Invoice invoice = invoiceUserApi.getInvoice(credit.getInvoiceId(), tenantContext);
    final CreditJson creditJson = new CreditJson(invoice, credit);
    return Response.status(Response.Status.OK).entity(creditJson).build();
}
Also used : InvoiceItem(org.killbill.billing.invoice.api.InvoiceItem) Invoice(org.killbill.billing.invoice.api.Invoice) TenantContext(org.killbill.billing.util.callcontext.TenantContext) CreditJson(org.killbill.billing.jaxrs.json.CreditJson) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Invoice (org.killbill.billing.invoice.api.Invoice)1 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)1 CreditJson (org.killbill.billing.jaxrs.json.CreditJson)1 TenantContext (org.killbill.billing.util.callcontext.TenantContext)1