Java: Get Letters And Postcards' Production Details with GetDetailsExtended()

Download our Java samples from this page.
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 java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.postalmethods.client.api.GetDetailsExtendedResponse;
import com.postalmethods.client.api.SendLetterResponse;
import com.postalmethods.client.model.LetterDetailsExtended;
 * Integration test that calls the GetDetailsExtended web method.
 * <p>
 * For details about PostalMethods.GetDetailsExtended see
 * <a href="">the PostalMethods.GetDetailsExtended reference</a>
public class GetDetailsExtendedTest {
    private PostalMethodsClient client;
    private String letterId;
    public void setUp() {
        client = new PostalMethodsClientFactory().build();
        // 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 = Integer.toString(code);
    public void testGetDetailsExtended() {
        System.out.println("Making call to GetDetailsExtended...");
        // GetDetailsExtended accepts an "ID" string which can include a single
        // item, multiple items, or a range of items.  Read the relevant documentation
        // for details (
        // We will be looking for a single letter id, the letter created in
        // the setUp() method of this integration test.
        GetDetailsExtendedResponse response = client.getDetailsExtended(letterId);
        System.out.println("Service call completed:\n" + response.getResult().toString());
        int code = response.getResult().getCode();
        assertEquals(-3000, code); // success
        List<LetterDetailsExtended> letterDetailsList = response.getLetterDetailsList();
        assertEquals(1, letterDetailsList.size());