Search in sources :

Example 26 with Consumes

use of javax.ws.rs.Consumes in project killbill by killbill.

the class AccountResource method setEmailNotificationsForAccount.

@TimedResource
@PUT
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Set account email notification")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response setEmailNotificationsForAccount(final InvoiceEmailJson json, @PathParam("accountId") final String accountIdString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
    verifyNonNullOrEmpty(json, "InvoiceEmailJson body should be specified");
    final CallContext callContext = context.createContext(createdBy, reason, comment, request);
    final UUID accountId = UUID.fromString(accountIdString);
    final Account account = accountUserApi.getAccountById(accountId, callContext);
    final MutableAccountData mutableAccountData = account.toMutableAccountData();
    mutableAccountData.setIsNotifiedForInvoices(json.isNotifiedForInvoices());
    accountUserApi.updateAccount(accountId, mutableAccountData, callContext);
    return Response.status(Status.OK).build();
}
Also used : Account(org.killbill.billing.account.api.Account) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) UUID(java.util.UUID) CallContext(org.killbill.billing.util.callcontext.CallContext) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 27 with Consumes

use of javax.ws.rs.Consumes in project killbill by killbill.

the class AccountResource method payAllInvoices.

@TimedResource
@POST
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}/" + INVOICE_PAYMENTS)
@ApiOperation(value = "Trigger a payment for all unpaid invoices")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response payAllInvoices(@PathParam("accountId") final String accountId, @QueryParam(QUERY_PAYMENT_EXTERNAL) @DefaultValue("false") final Boolean externalPayment, @QueryParam(QUERY_PAYMENT_AMOUNT) final BigDecimal paymentAmount, @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException, InvoiceApiException {
    final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
    final CallContext callContext = context.createContext(createdBy, reason, comment, request);
    final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), callContext);
    final Collection<Invoice> unpaidInvoices = invoiceApi.getUnpaidInvoicesByAccountId(account.getId(), clock.getUTCToday(), callContext);
    BigDecimal remainingRequestPayment = paymentAmount;
    if (remainingRequestPayment == null) {
        remainingRequestPayment = BigDecimal.ZERO;
        for (final Invoice invoice : unpaidInvoices) {
            remainingRequestPayment = remainingRequestPayment.add(invoice.getBalance());
        }
    }
    for (final Invoice invoice : unpaidInvoices) {
        final BigDecimal amountToPay = (remainingRequestPayment.compareTo(invoice.getBalance()) >= 0) ? invoice.getBalance() : remainingRequestPayment;
        if (amountToPay.compareTo(BigDecimal.ZERO) > 0) {
            final UUID paymentMethodId = externalPayment ? null : account.getPaymentMethodId();
            createPurchaseForInvoice(account, invoice.getId(), amountToPay, paymentMethodId, externalPayment, null, null, pluginProperties, callContext);
        }
        remainingRequestPayment = remainingRequestPayment.subtract(amountToPay);
        if (remainingRequestPayment.compareTo(BigDecimal.ZERO) == 0) {
            break;
        }
    }
    //
    if (externalPayment && remainingRequestPayment.compareTo(BigDecimal.ZERO) > 0) {
        invoiceApi.insertCredit(account.getId(), remainingRequestPayment, clock.getUTCToday(), account.getCurrency(), true, "pay all invoices", callContext);
    }
    return Response.status(Status.OK).build();
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) Account(org.killbill.billing.account.api.Account) Invoice(org.killbill.billing.invoice.api.Invoice) UUID(java.util.UUID) CallContext(org.killbill.billing.util.callcontext.CallContext) BigDecimal(java.math.BigDecimal) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 28 with Consumes

use of javax.ws.rs.Consumes in project OpenAttestation by OpenAttestation.

the class AbstractJsonapiResource method storeJsonapiCollection.

/**
     * Replace an item in the collection. Input Content-Type is
     * application/vnd.api+json Output Content-Type is application/vnd.api+json
     *
     * The input item must be wrapped in a collection. The output item is always
     * wrapped in a collection.
     *
     * @param locator
     * @param collection
     * @return
     */
@Path("/{id}")
@PUT
@Consumes(DataMediaType.APPLICATION_VND_API_JSON)
@Produces(DataMediaType.APPLICATION_VND_API_JSON)
public C storeJsonapiCollection(@BeanParam L locator, C collection) {
    // misnomer, what we really mean is "store one but wrapped ina  collection for jsonapi"
    log.debug("storeCollection");
    ValidationUtil.validate(collection);
    List<T> list = collection.getDocuments();
    if (list == null || list.isEmpty()) {
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
    T item = list.get(0);
    locator.copyTo(item);
    if (item == null) {
        getRepository().create(item);
    } else {
        getRepository().store(item);
    }
    return collection;
}
Also used : POST(javax.ws.rs.POST) GET(javax.ws.rs.GET) PUT(javax.ws.rs.PUT) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 29 with Consumes

use of javax.ws.rs.Consumes in project OpenAttestation by OpenAttestation.

the class AbstractJsonapiResource method createJsonapiCollection.

/**
     * Add an item to the collection. Input Content-Type is
     * application/vnd.api+json Output Content-Type is application/vnd.api+json
     *
     * The input must represent a collection of items to add, even if the
     * collection only contains a single item.
     *
     *
     * @param collection
     * @return
     */
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public C createJsonapiCollection(C collection) {
    log.debug("createCollection");
    ValidationUtil.validate(collection);
    // this behavior of autmoatically generating uuids if client didn't provide could be implemented in one place and reused in all create() methods...  the utility could accept a DocumentCollection and set the ids... 
    for (T item : collection.getDocuments()) {
        if (item.getId() == null) {
            item.setId(new UUID());
        }
        getRepository().create(item);
    }
    return collection;
}
Also used : POST(javax.ws.rs.POST) GET(javax.ws.rs.GET) PUT(javax.ws.rs.PUT) UUID(com.intel.mtwilson.util.io.UUID) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 30 with Consumes

use of javax.ws.rs.Consumes in project OpenAttestation by OpenAttestation.

the class AssetTagCert method revokeAssetTagCertificate.

/**
     * This REST API would be called by tag provisioning service whenever a valid asset tag certificate is revoked.
     * @param atagObj
     * @return 
     */
//@RolesAllowed({"AssetTagManagement"})
//    @RequiresPermissions({"tag_certificates:store"})
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String revokeAssetTagCertificate(AssetTagCertRevokeRequest atagObj) {
    boolean result;
    AssetTagCertBO object = new AssetTagCertBO();
    result = object.revokeAssetTagCertificate(atagObj, null);
    return Boolean.toString(result);
}
Also used : AssetTagCertBO(com.intel.mtwilson.as.business.AssetTagCertBO) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

Consumes (javax.ws.rs.Consumes)1565 Path (javax.ws.rs.Path)1221 Produces (javax.ws.rs.Produces)1217 POST (javax.ws.rs.POST)892 ApiOperation (io.swagger.annotations.ApiOperation)503 ApiResponses (io.swagger.annotations.ApiResponses)445 PUT (javax.ws.rs.PUT)417 GET (javax.ws.rs.GET)223 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)215 URI (java.net.URI)202 IOException (java.io.IOException)147 WebApplicationException (javax.ws.rs.WebApplicationException)139 Response (javax.ws.rs.core.Response)136 ArrayList (java.util.ArrayList)134 Authorizable (org.apache.nifi.authorization.resource.Authorizable)100 DELETE (javax.ws.rs.DELETE)86 TimedResource (org.killbill.commons.metrics.TimedResource)84 CallContext (org.killbill.billing.util.callcontext.CallContext)83 Timed (com.codahale.metrics.annotation.Timed)78 HashMap (java.util.HashMap)76