Search in sources :

Example 1 with CatalogJson

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

the class CatalogResource method getCatalogJson.

@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve the catalog as JSON", response = StaticCatalog.class)
@ApiResponses(value = {})
public Response getCatalogJson(@QueryParam(QUERY_REQUESTED_DT) final String requestedDate, @javax.ws.rs.core.Context final HttpServletRequest request) throws Exception {
    final TenantContext tenantContext = context.createContext(request);
    final DateTime catalogDateVersion = requestedDate != null ? DATE_TIME_FORMATTER.parseDateTime(requestedDate).toDateTime(DateTimeZone.UTC) : null;
    // Yack...
    final VersionedCatalog catalog = (VersionedCatalog) catalogUserApi.getCatalog(catalogName, tenantContext);
    final List<CatalogJson> result = new ArrayList<CatalogJson>();
    if (catalogDateVersion != null) {
        result.add(new CatalogJson(catalog, catalogDateVersion));
    } else {
        for (final StandaloneCatalog v : catalog.getVersions()) {
            result.add(new CatalogJson(catalog, new DateTime(v.getEffectiveDate())));
        }
    }
    return Response.status(Status.OK).entity(result).build();
}
Also used : VersionedCatalog(org.killbill.billing.catalog.VersionedCatalog) StandaloneCatalog(org.killbill.billing.catalog.StandaloneCatalog) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) CatalogJson(org.killbill.billing.jaxrs.json.CatalogJson) DateTime(org.joda.time.DateTime) 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 CatalogJson

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

the class CatalogResource method getCatalogJson.

@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve the catalog as JSON", responseContainer = "List", response = CatalogJson.class)
@ApiResponses(value = {})
public Response getCatalogJson(@QueryParam(QUERY_REQUESTED_DT) final String requestedDate, @QueryParam(QUERY_ACCOUNT_ID) final UUID accountId, @javax.ws.rs.core.Context final HttpServletRequest request) throws Exception {
    final TenantContext tenantContext = accountId != null ? context.createTenantContextWithAccountId(accountId, request) : context.createTenantContextNoAccountId(request);
    final DateTime catalogDateVersion = requestedDate != null ? DATE_TIME_FORMATTER.parseDateTime(requestedDate).toDateTime(DateTimeZone.UTC) : null;
    final VersionedCatalog catalog = catalogUserApi.getCatalog(catalogName, tenantContext);
    final Collection<CatalogJson> result = new ArrayList<CatalogJson>();
    if (catalogDateVersion == null) {
        for (final StaticCatalog v : catalog.getVersions()) {
            result.add(new CatalogJson(v));
        }
    } else {
        final StaticCatalog target = catalog.getVersion(catalogDateVersion.toDate());
        result.add(new CatalogJson(target));
    }
    return Response.status(Status.OK).entity(result).build();
}
Also used : VersionedCatalog(org.killbill.billing.catalog.api.VersionedCatalog) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) CatalogJson(org.killbill.billing.jaxrs.json.CatalogJson) StaticCatalog(org.killbill.billing.catalog.api.StaticCatalog) DateTime(org.joda.time.DateTime) 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)2 ApiResponses (io.swagger.annotations.ApiResponses)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 DateTime (org.joda.time.DateTime)2 CatalogJson (org.killbill.billing.jaxrs.json.CatalogJson)2 TenantContext (org.killbill.billing.util.callcontext.TenantContext)2 TimedResource (org.killbill.commons.metrics.TimedResource)2 StandaloneCatalog (org.killbill.billing.catalog.StandaloneCatalog)1 VersionedCatalog (org.killbill.billing.catalog.VersionedCatalog)1 StaticCatalog (org.killbill.billing.catalog.api.StaticCatalog)1 VersionedCatalog (org.killbill.billing.catalog.api.VersionedCatalog)1