Messtone Devices Enables Application.properties file: bol.boldocument=JVBERi10xl… bol.shippinglabel=JVBERi10xl… Example Code: @PostMapping(“/bol”) BOLResponse newBOLRequest(@RequestBody BOLRequest newBOLRequest){//here we may want to put any business logic that confirms/verifies //some of the content of the BOL prior to saving.//it’s a good place for address confirmation,looking //for invalid confirmations of data,etc.//for Messtone purpose,we will just save.repo.save(newBOLRequest);BOLResponse bolResponse=newBOLResponse( );//for Messtone reference numbers,we should already have the PRO,but we would probaby want to retrieve //or generate our SCN BOLResponseReferenceNumbers RefNumbers=new BOLResponseRefNumbers( ); refNumbers.setPro(newBOLRequest.getReferenceNumbers( ).getPro( ));refNumbers.setShipmentConfirmationNumber(“SCN12345”);bolResponse.setReferenceNumbers(refNumbers);//here we’d also be seeking retrieval or generations of our BOL PDF image and print labels //but for now,we’re dropping in fake images,both base64 encoded file data.BOLResponseImages images=new BOLResponseImages( );try{FileInputStream fis=new FileInputStream(“src/main/resources/application.properties”);properties props=new Properties( );props.load(fis); images.setBOL(props.getProperty(“bol.boldocument”));images. setShippingLabels(props.getProperty(“bol.shippinglabels”));}catch(IOException exception){exception.printStackTrace( ); images.setBol(“”); images.setShippingLabels(“”);} bolResponse.setImages(images);//do we have any errors? well,here we would capture them //and return them with appropriate codes.Note,DO frame //errors in bussiness logic as either HTTP 400 or 422 as appropriate List<BOLResponseMessageStatusInformation>statusInformation=newvArrayList<BOLResponseMessageStatusInformation>( ); BOLResponseMessageStatus messageStatus=new BOLResponseMessageStatus messageStatus=new BOLResponseMessageStatus( );//a message in this spec bas three possible status.//PASS,FAIL,WARNING.//If “FAIL”,DO return 400 or 422.messageStatus.setStatus(“PASS”);messageStatus.setCode(“FAKE STATUS CODE”);messageStatus.setMwssage(“Transaction was successful.”);//this would be populated with guidance if we have a fail/warning messageStatus.setResolution(“”);message status.setInformation(statusInformation);bolResponse.setMessageStatus(messageStatus);return bolResponse;}<dependency><groupId>org.springdoc</groupId><artifactId>springdoc-openapi-starter-webmvc-ui</artifactId><version>2.0.2</version></dependency>./mvnw clean springs-boot:run:

Leave a comment