All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.silanis.esl.sdk.service.FieldSummaryService Maven / Gradle / Ivy

The newest version!
package com.silanis.esl.sdk.service;

import com.silanis.esl.sdk.EslException;
import com.silanis.esl.sdk.FieldSummary;
import com.silanis.esl.sdk.PackageId;
import com.silanis.esl.sdk.internal.*;

import java.util.List;

/**
 * The FieldSummaryService class provides a method to get the field summary for a package.
 */
public class FieldSummaryService extends EslComponent {

    public FieldSummaryService(RestClient client, String baseUrl ) {
        super( client, baseUrl);
    }

    /**
     * Gets the field summary for the package and returns a list of field summaries.
     *
     * @param packageId
     * @return A list of field summaries
     * @throws com.silanis.esl.sdk.EslException
     */
    public List getFieldSummary( PackageId packageId ) throws EslException {
        String path = new UrlTemplate(getBaseUrl()).urlFor( UrlTemplate.FIELD_SUMMARY_PATH )
                .replace( "{packageId}", packageId.getId() )
                .build();

        List fieldSummary;
        try {
            String stringResponse = getClient().get(path);


            fieldSummary = Serialization.fromJsonToList(stringResponse, FieldSummary.class);
        } catch ( RequestException e ) {
            throw new EslServerException( "Could not get the field summary.", e );
        } catch ( Exception e ) {
            throw new EslException( "Could not get the field summary.", e );
        }
        return fieldSummary;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy