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

com.sparkpost.resources.ResourceRecipientLists Maven / Gradle / Ivy

There is a newer version: 0.27
Show newest version

package com.sparkpost.resources;

import com.sparkpost.exception.SparkPostException;
import com.sparkpost.model.RecipientList;
import com.sparkpost.model.responses.RecipientListRetrieveResponse;
import com.sparkpost.model.responses.RecipientListsListAllResponse;
import com.sparkpost.model.responses.Response;
import com.sparkpost.transport.RestConnection;

/**
 * Resource collection that is a 1-to-1 match to the Recipient Lists SparkPost
 * API.
*
* See * Recipient * Lists API * * @author grava */ public class ResourceRecipientLists { public static Response create(RestConnection conn, Integer maxNumberOfRecipientErrors, RecipientList recipientList) throws SparkPostException { String json = recipientList.toJson(); Endpoint ep = new Endpoint("recipient-lists"); ep.addParam("num_rcpt_errors", maxNumberOfRecipientErrors); Response response = conn.post(ep.toString(), json); return response; } public static RecipientListRetrieveResponse retrieve(RestConnection conn, String recipientListId, Boolean showRecipients) throws SparkPostException { Endpoint ep = new Endpoint("recipient-lists/" + recipientListId); ep.addParam("show_recipients", showRecipients); Response response = conn.get(ep.toString()); RecipientListRetrieveResponse retrieveResponse = RecipientListRetrieveResponse.decode(response, RecipientListRetrieveResponse.class); return retrieveResponse; } public static RecipientListsListAllResponse listAll(RestConnection conn) throws SparkPostException { Response response = conn.get("recipient-lists"); RecipientListsListAllResponse listResponse = RecipientListsListAllResponse.decode(response, RecipientListsListAllResponse.class); return listResponse; } public static Response delete(RestConnection conn, String recipientListId) throws SparkPostException { String path = "recipient-lists/" + recipientListId; Response response = conn.delete(path); return response; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy