Search in sources :

Example 1 with PlanDetailJson

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

the class CatalogResource method getAvailableAddons.

// Need to figure out dependency on StandaloneCatalog
//    @GET
//    @Path("/xsd")
//    @Produces(APPLICATION_XML)
//    public String getCatalogXsd() throws Exception
//    {
//        InputStream stream = XMLSchemaGenerator.xmlSchema(StandaloneCatalog.class);
//        StringWriter writer = new StringWriter();
//        IOUtils.copy(stream, writer);
//        String result = writer.toString();
//
//        return result;
//    }
@TimedResource
@GET
@Path("/availableAddons")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve available add-ons for a given product", response = PlanDetailJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getAvailableAddons(@QueryParam("baseProductName") final String baseProductName, @Nullable @QueryParam("priceListName") final String priceListName, @javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
    final TenantContext tenantContext = context.createContext(request);
    final StaticCatalog catalog = catalogUserApi.getCurrentCatalog(catalogName, tenantContext);
    final List<Listing> listings = catalog.getAvailableAddOnListings(baseProductName, priceListName);
    final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>();
    for (final Listing listing : listings) {
        details.add(new PlanDetailJson(listing));
    }
    return Response.status(Status.OK).entity(details).build();
}
Also used : PlanDetailJson(org.killbill.billing.jaxrs.json.PlanDetailJson) Listing(org.killbill.billing.catalog.api.Listing) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) StaticCatalog(org.killbill.billing.catalog.api.StaticCatalog) 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)

Example 2 with PlanDetailJson

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

the class CatalogResource method getAvailableBasePlans.

@TimedResource
@GET
@Path("/availableBasePlans")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve available base plans", response = PlanDetailJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getAvailableBasePlans(@javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
    final TenantContext tenantContext = context.createContext(request);
    final StaticCatalog catalog = catalogUserApi.getCurrentCatalog(catalogName, tenantContext);
    final List<Listing> listings = catalog.getAvailableBasePlanListings();
    final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>();
    for (final Listing listing : listings) {
        details.add(new PlanDetailJson(listing));
    }
    return Response.status(Status.OK).entity(details).build();
}
Also used : PlanDetailJson(org.killbill.billing.jaxrs.json.PlanDetailJson) Listing(org.killbill.billing.catalog.api.Listing) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) StaticCatalog(org.killbill.billing.catalog.api.StaticCatalog) 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)

Example 3 with PlanDetailJson

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

the class CatalogResource method getAvailableBasePlans.

@TimedResource
@GET
@Path("/availableBasePlans")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve available base plans", response = PlanDetailJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getAvailableBasePlans(@QueryParam(QUERY_ACCOUNT_ID) final UUID accountId, @javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
    final TenantContext tenantContext = accountId != null ? context.createTenantContextWithAccountId(accountId, request) : context.createTenantContextNoAccountId(request);
    final StaticCatalog catalog = catalogUserApi.getCurrentCatalog(catalogName, tenantContext);
    final List<Listing> listings = catalog.getAvailableBasePlanListings();
    final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>();
    for (final Listing listing : listings) {
        details.add(new PlanDetailJson(listing));
    }
    return Response.status(Status.OK).entity(details).build();
}
Also used : PlanDetailJson(org.killbill.billing.jaxrs.json.PlanDetailJson) Listing(org.killbill.billing.catalog.api.Listing) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) StaticCatalog(org.killbill.billing.catalog.api.StaticCatalog) 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)

Example 4 with PlanDetailJson

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

the class CatalogResource method getAvailableAddons.

// Need to figure out dependency on StandaloneCatalog
// @GET
// @Path("/xsd")
// @Produces(APPLICATION_XML)
// public String getCatalogXsd() throws Exception
// {
// InputStream stream = XMLSchemaGenerator.xmlSchema(StandaloneCatalog.class);
// StringWriter writer = new StringWriter();
// IOUtils.copy(stream, writer);
// String result = writer.toString();
// 
// return result;
// }
@TimedResource
@GET
@Path("/availableAddons")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve available add-ons for a given product", response = PlanDetailJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getAvailableAddons(@QueryParam("baseProductName") final String baseProductName, @Nullable @QueryParam("priceListName") final String priceListName, @QueryParam(QUERY_ACCOUNT_ID) final UUID accountId, @javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
    final TenantContext tenantContext = accountId != null ? context.createTenantContextWithAccountId(accountId, request) : context.createTenantContextNoAccountId(request);
    final StaticCatalog catalog = catalogUserApi.getCurrentCatalog(catalogName, tenantContext);
    final List<Listing> listings = catalog.getAvailableAddOnListings(baseProductName, priceListName);
    final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>();
    for (final Listing listing : listings) {
        details.add(new PlanDetailJson(listing));
    }
    return Response.status(Status.OK).entity(details).build();
}
Also used : PlanDetailJson(org.killbill.billing.jaxrs.json.PlanDetailJson) Listing(org.killbill.billing.catalog.api.Listing) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) StaticCatalog(org.killbill.billing.catalog.api.StaticCatalog) 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

ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 ArrayList (java.util.ArrayList)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Listing (org.killbill.billing.catalog.api.Listing)4 StaticCatalog (org.killbill.billing.catalog.api.StaticCatalog)4 PlanDetailJson (org.killbill.billing.jaxrs.json.PlanDetailJson)4 TenantContext (org.killbill.billing.util.callcontext.TenantContext)4 TimedResource (org.killbill.commons.metrics.TimedResource)4