/** * Batch Save processor. * * <p>Saves a Batch. Note that you should pass-in your console credentials for this method, * instead of the API ones * * <p>{@sample.xml ../../../doc/avalara-connector.xml.sample avalara:save-batch} * * @param batchType The kind of records to be imported. * @param companyId The id of the company. (Need to be retrived from address bar in Avalara after * hitting the Organization Tab) * @param content The content of this import, usually a csv file. * @param batchName The name of the batch. * @return The {@link BatchSaveResult} * @throws AvalaraRuntimeException */ @Processor public BatchSaveResult saveBatch( BatchType batchType, int companyId, String content, @Optional String batchName) { final BatchFile batchFile = new BatchFile(); batchFile.setContent(content.getBytes()); // cxf takes care of base64 encoding batchFile.setContentType("application/csv"); batchFile.setName( batchName + ".csv"); // Must set extension, or Avalara will complain about missing ext final ArrayOfBatchFile arrayOfBatchFile = new ArrayOfBatchFile(); arrayOfBatchFile.getBatchFile().add(batchFile); // Batch object to contain the file. // Have tested batchfile as well but all examples from Avalara is using this one. final Batch batch = new Batch(); batch.setName(batchName); batch.setBatchTypeId(batchType.value()); batch.setCompanyId(companyId); batch.setFiles(arrayOfBatchFile); return apiClient.sendBatchRequestToAvalara(BatchRequestType.BatchSave, batch); }