Java: Send A Letter With SendLetterV2()
Download our Java samples from this page. Find this sample in directory /test/com/postalmethods/client
This sample demonstrates how to send a letter through PostalMethods using the Address Inside method.
package com.postalmethods.client; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.postalmethods.client.api.SendLetterV2Response; public class SendLetterV2Test { private PostalMethodsClient client; @Before public void setUp() { client = new PostalMethodsClientFactory().build(); } @Test public void testSendLetter() { System.out.println("Making call to SendLetterV2..."); SendLetterV2Response response = client.sendLetterV2("Sending test letter via JUnit integration test.", TestConstants.SAMPLE_LETTER_FILENAME); System.out.println("Service call completed:\n" + response.getResult().toString()); int code = response.getResult().getCode(); assertTrue(code > 0 ); System.out.println("New letter id is: " + code); } }
