<commit_before>/*
 * CODENVY CONFIDENTIAL
 * __________________
 *
 *  [2012] - [2015] Codenvy, S.A.
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Codenvy S.A. and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Codenvy S.A.
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Codenvy S.A..
 */
package com.codenvy.api.account.billing;

import com.codenvy.api.account.impl.shared.dto.Invoice;
import com.codenvy.api.account.impl.shared.dto.InvoiceDescriptor;
import com.codenvy.api.core.NotFoundException;
import com.codenvy.api.core.ServerException;
import com.codenvy.api.core.rest.Service;
import com.codenvy.api.core.rest.shared.dto.Link;
import com.codenvy.api.core.util.LinksHelper;
import com.codenvy.dto.server.DtoFactory;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiParam;

import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 * @author <NAME>
 *
 */
@Api(value = "/invoice",
        description = "Invoice manager")
@Path("/invoice/{accountId}")
public class InvoiceService extends Service {

    public static final String HTML_TEMPLATE_FILE = "invoice.html.template.file";

    private final BillingService billingService;

    private final String templateFile;

    @Inject
    public InvoiceService(@Named(HTML_TEMPLATE_FILE) String templateFile, BillingService billingService) {
        this.templateFile = templateFile;
        this.billingService = billingService;
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed({"account/owner", "system/admin", "system/manager"})
    public List<InvoiceDescriptor> getAccountInvoices(@ApiParam(value = "Account ID", required = true)
                                                      @PathParam("accountId") String accountId,
                                                      @ApiParam(value = "Max items count", required = false)
                                                      @DefaultValue("-1") @QueryParam("maxItems") int maxItems,
                                                      @ApiParam(value = "Skip count", required = false)
                                                      @QueryParam("skipCount") int skipCount,
                                                      @ApiParam(value = "Period start time", required = false)
                                                      @DefaultValue("-1L") @QueryParam("startPeriod") long startPeriod,
                                                      @ApiParam(value = "Period end time", required = false)<commit_msg>Added invoice service;<commit_after>/*
 * CODENVY CONFIDENTIAL
 * __________________
 *
 *  [2012] - [2015] Codenvy, S.A.
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Codenvy S.A. and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Codenvy S.A.
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Codenvy S.A..
 */
package com.codenvy.api.account.billing;

import com.codenvy.api.account.impl.shared.dto.Invoice;
import com.codenvy.api.account.impl.shared.dto.InvoiceDescriptor;
import com.codenvy.api.core.NotFoundException;
import com.codenvy.api.core.ServerException;
import com.codenvy.api.core.rest.Service;
import com.codenvy.api.core.rest.shared.dto.Link;
import com.codenvy.api.core.util.LinksHelper;
import com.codenvy.dto.server.DtoFactory;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiParam;

import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 * @author <NAME>
 *
 */
@Api(value = "/invoice",
        description = "Invoice manager")
@Path("/invoice/{accountId}")
public class InvoiceService extends Service {

    public static final String HTML_TEMPLATE_FILE = "invoice.html.template.file";

    private final BillingService billingService;

    //private final String templateFile;

    @Inject
    public InvoiceService(BillingService billingService) {
        //this.templateFile = templateFile;
        this.billingService = billingService;
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed({"account/owner", "system/admin", "system/manager"})
    public List<InvoiceDescriptor> getAccountInvoices(@ApiParam(value = "Account ID", required = true)
                                                      @PathParam("accountId") String accountId,
                                                      @ApiParam(value = "Max items count", required = false)
                                                      @DefaultValue("-1") @QueryParam("maxItems") int maxItems,
                                                      @ApiParam(value = "Skip count", required = false)
                                                      @QueryParam("skipCount") int skipCount,
                                                      @ApiParam(value = "Period start time", required = false)
                                                      @DefaultValue("-1L") @QueryParam("startPeriod") long startPeriod,
                                                      @ApiParam(value = "Period end time", required = false)
{'fraction_non_alphanumeric': 0.10047846889952153, 'fraction_numerical': 0.0028998115122517037, 'mean_word_length': 2.6343519494204424, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4337930', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1843, 'n_words': 466}