Java: Get Letter Metadata with GetLetterDetails()
Download Java samples [.zip]. Find this sample in directory /test/com/postalmethods/client
package com.postalmethods.client; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import com.postalmethods.client.api.GetLetterDetailsResponse; import com.postalmethods.client.api.SendLetterResponse; public class GetLetterDetailsTest { private PostalMethodsClient client; private int letterId; @Before public void setUp() { client = new PostalMethodsClientFactory().build(TestConstants.USERNAME, TestConstants.PASSWORD); // Send a sample letter so we have a letterId to check status on. SendLetterResponse sendResponse = client.sendLetter("Junit test letter 1", TestConstants.SAMPLE_LETTER_FILENAME); int code = sendResponse.getResult().getCode(); assertTrue(code > 0 ); this.letterId = code; } @Test public void testGetLetterDetails() { System.out.println("Making call to GetLetterDetails..."); GetLetterDetailsResponse response = client.getLetterDetails(letterId); System.out.println("Service call completed:\n" + response.getResult().toString()); int code = response.getResult().getCode(); assertEquals( -3000, code ); // success System.out.println(response.getLetterDetails().toString()); } }
