Search in sources :

Example 71 with ApiResponses

use of io.swagger.annotations.ApiResponses in project killbill by killbill.

the class AccountResource method getInvoices.

/*
     * ************************** INVOICES ********************************
     */
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + INVOICES)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve account invoices", response = InvoiceJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response getInvoices(@PathParam("accountId") final String accountIdString, @QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final boolean withItems, @QueryParam(QUERY_WITH_MIGRATION_INVOICES) @DefaultValue("false") final boolean withMigrationInvoices, @QueryParam(QUERY_UNPAID_INVOICES_ONLY) @DefaultValue("false") final boolean unpaidInvoicesOnly, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
    final TenantContext tenantContext = context.createContext(request);
    // Verify the account exists
    final UUID accountId = UUID.fromString(accountIdString);
    accountUserApi.getAccountById(accountId, tenantContext);
    final List<Invoice> invoices = unpaidInvoicesOnly ? new ArrayList<Invoice>(invoiceApi.getUnpaidInvoicesByAccountId(accountId, null, tenantContext)) : invoiceApi.getInvoicesByAccount(accountId, withMigrationInvoices, tenantContext);
    final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(accountId, auditMode.getLevel(), tenantContext);
    final List<InvoiceJson> result = new LinkedList<InvoiceJson>();
    for (final Invoice invoice : invoices) {
        result.add(new InvoiceJson(invoice, withItems, null, accountAuditLogs));
    }
    return Response.status(Status.OK).entity(result).build();
}
Also used : Invoice(org.killbill.billing.invoice.api.Invoice) InvoiceJson(org.killbill.billing.jaxrs.json.InvoiceJson) TenantContext(org.killbill.billing.util.callcontext.TenantContext) UUID(java.util.UUID) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) LinkedList(java.util.LinkedList) 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 72 with ApiResponses

use of io.swagger.annotations.ApiResponses in project killbill by killbill.

the class AccountResource method createAccount.

@TimedResource
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Create account")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account data supplied") })
public Response createAccount(final AccountJson json, @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, @javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException {
    verifyNonNullOrEmpty(json, "AccountJson body should be specified");
    final AccountData data = json.toAccount(null);
    final Account account = accountUserApi.createAccount(data, context.createContext(createdBy, reason, comment, request));
    return uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccount", account.getId(), request);
}
Also used : Account(org.killbill.billing.account.api.Account) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) AccountData(org.killbill.billing.account.api.AccountData) TimedResource(org.killbill.commons.metrics.TimedResource) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 73 with ApiResponses

use of io.swagger.annotations.ApiResponses in project killbill by killbill.

the class AccountResource method getInvoicePayments.

/*
     * ************************** PAYMENTS ********************************
     */
// STEPH should refactor code since very similar to @Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENTS)
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + INVOICE_PAYMENTS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve account invoice payments", response = InvoicePaymentJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response getInvoicePayments(@PathParam("accountId") final String accountIdStr, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @QueryParam(QUERY_WITH_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo, @QueryParam(QUERY_WITH_ATTEMPTS) @DefaultValue("false") final Boolean withAttempts, @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString, @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
    final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
    final UUID accountId = UUID.fromString(accountIdStr);
    final TenantContext tenantContext = context.createContext(request);
    final Account account = accountUserApi.getAccountById(accountId, tenantContext);
    final List<Payment> payments = paymentApi.getAccountPayments(account.getId(), withPluginInfo, withAttempts, pluginProperties, tenantContext);
    final List<InvoicePayment> invoicePayments = invoicePaymentApi.getInvoicePaymentsByAccount(accountId, tenantContext);
    final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(accountId, auditMode.getLevel(), tenantContext);
    final List<InvoicePaymentJson> result = new ArrayList<InvoicePaymentJson>(payments.size());
    for (final Payment payment : payments) {
        final UUID invoiceId = getInvoiceId(invoicePayments, payment);
        result.add(new InvoicePaymentJson(payment, invoiceId, accountAuditLogs));
    }
    return Response.status(Status.OK).entity(result).build();
}
Also used : Account(org.killbill.billing.account.api.Account) InvoicePayment(org.killbill.billing.invoice.api.InvoicePayment) InvoicePaymentJson(org.killbill.billing.jaxrs.json.InvoicePaymentJson) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) PluginProperty(org.killbill.billing.payment.api.PluginProperty) InvoicePayment(org.killbill.billing.invoice.api.InvoicePayment) Payment(org.killbill.billing.payment.api.Payment) UUID(java.util.UUID) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) 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 74 with ApiResponses

use of io.swagger.annotations.ApiResponses in project killbill by killbill.

the class AccountResource method getEmails.

/*
     * *************************     EMAILS     *****************************
     */
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve an account emails", response = AccountEmailJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied") })
public Response getEmails(@PathParam(ID_PARAM_NAME) final String id, @javax.ws.rs.core.Context final HttpServletRequest request) {
    final UUID accountId = UUID.fromString(id);
    final List<AccountEmail> emails = accountUserApi.getEmails(accountId, context.createContext(request));
    final List<AccountEmailJson> emailsJson = new ArrayList<AccountEmailJson>();
    for (final AccountEmail email : emails) {
        emailsJson.add(new AccountEmailJson(email.getAccountId().toString(), email.getEmail()));
    }
    return Response.status(Status.OK).entity(emailsJson).build();
}
Also used : AccountEmailJson(org.killbill.billing.jaxrs.json.AccountEmailJson) AccountEmail(org.killbill.billing.account.api.AccountEmail) ArrayList(java.util.ArrayList) UUID(java.util.UUID) 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 75 with ApiResponses

use of io.swagger.annotations.ApiResponses in project killbill by killbill.

the class AccountResource method getEmailNotificationsForAccount.

/*
    * ************************** EMAIL NOTIFICATIONS FOR INVOICES ********************************
    */
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve account email notification", response = InvoiceEmailJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response getEmailNotificationsForAccount(@PathParam("accountId") final String accountId, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
    final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), context.createContext(request));
    final InvoiceEmailJson invoiceEmailJson = new InvoiceEmailJson(accountId, account.isNotifiedForInvoices());
    return Response.status(Status.OK).entity(invoiceEmailJson).build();
}
Also used : Account(org.killbill.billing.account.api.Account) InvoiceEmailJson(org.killbill.billing.jaxrs.json.InvoiceEmailJson) 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

ApiResponses (io.swagger.annotations.ApiResponses)612 ApiOperation (io.swagger.annotations.ApiOperation)607 Path (javax.ws.rs.Path)319 Produces (javax.ws.rs.Produces)223 Counted (com.codahale.metrics.annotation.Counted)210 Timed (com.codahale.metrics.annotation.Timed)193 GET (javax.ws.rs.GET)169 POST (javax.ws.rs.POST)119 TimedResource (org.killbill.commons.metrics.TimedResource)111 Consumes (javax.ws.rs.Consumes)109 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)94 Authorisation (nikita.webapp.security.Authorisation)87 PUT (javax.ws.rs.PUT)66 UUID (java.util.UUID)62 DELETE (javax.ws.rs.DELETE)62 AuditEvent (org.graylog2.audit.jersey.AuditEvent)59 TenantContext (org.killbill.billing.util.callcontext.TenantContext)58 RestException (com.yahoo.pulsar.broker.web.RestException)54 ApiResponse (io.swagger.annotations.ApiResponse)53 CallContext (org.killbill.billing.util.callcontext.CallContext)51