Search in sources :

Example 1 with BlockingStateJson

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

the class AccountResource method getBlockingStates.

/*
     * *************************      BLOCKING STATE     *****************************
     */
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + BLOCK)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve blocking states for account", response = BlockingStateJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied") })
public Response getBlockingStates(@PathParam(ID_PARAM_NAME) final String id, @QueryParam(QUERY_BLOCKING_STATE_TYPES) final List<BlockingStateType> typeFilter, @QueryParam(QUERY_BLOCKING_STATE_SVCS) final List<String> svcsFilter, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException {
    final TenantContext tenantContext = this.context.createContext(request);
    final UUID accountId = UUID.fromString(id);
    final Iterable<BlockingState> blockingStates = subscriptionApi.getBlockingStates(accountId, typeFilter, svcsFilter, OrderingType.ASCENDING, SubscriptionApi.ALL_EVENTS, tenantContext);
    final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(accountId, auditMode.getLevel(), tenantContext);
    final List<BlockingStateJson> result = ImmutableList.copyOf(Iterables.transform(blockingStates, new Function<BlockingState, BlockingStateJson>() {

        @Override
        public BlockingStateJson apply(final BlockingState input) {
            return new BlockingStateJson(input, accountAuditLogs);
        }
    }));
    return Response.status(Status.OK).entity(result).build();
}
Also used : Function(com.google.common.base.Function) TenantContext(org.killbill.billing.util.callcontext.TenantContext) BlockingState(org.killbill.billing.entitlement.api.BlockingState) UUID(java.util.UUID) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) BlockingStateJson(org.killbill.billing.jaxrs.json.BlockingStateJson) 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

Function (com.google.common.base.Function)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 UUID (java.util.UUID)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 BlockingState (org.killbill.billing.entitlement.api.BlockingState)1 BlockingStateJson (org.killbill.billing.jaxrs.json.BlockingStateJson)1 AccountAuditLogs (org.killbill.billing.util.audit.AccountAuditLogs)1 TenantContext (org.killbill.billing.util.callcontext.TenantContext)1 TimedResource (org.killbill.commons.metrics.TimedResource)1