com.createsend
Class Segments

java.lang.Object
  extended by com.createsend.CreateSendBase
      extended by com.createsend.Segments

public class Segments
extends CreateSendBase

Provides methods for accessing all Segment resources in the Campaign Monitor API


Field Summary
 
Fields inherited from class com.createsend.CreateSendBase
jerseyClient, urlEncodingScheme
 
Constructor Summary
Segments(AuthenticationDetails auth)
          Constructor used to create new segments.
Segments(AuthenticationDetails auth, java.lang.String segmentID)
          Constructor for working with existing segments.
 
Method Summary
 PagedResult<Subscriber> active()
          Gets a paged collection of active subscribers within the specified segment.
 PagedResult<Subscriber> active(java.util.Date subscribedFrom, java.lang.Integer page, java.lang.Integer pageSize, java.lang.String orderField, java.lang.String orderDirection)
          Gets a paged collection of active subscribers within the specified segment since the provided date.
 PagedResult<Subscriber> active(java.lang.Integer page, java.lang.Integer pageSize, java.lang.String orderField, java.lang.String orderDirection)
          Gets a paged collection of active subscribers within the specified segment.
 void addRule(Rule rule)
          Adds a new rule to an existing list segment
 java.lang.String create(java.lang.String listID, Segment segment)
          Creates a new segment on the specified list.
 void delete()
          Deletes the specified segment.
 void deleteRules()
          Deletes all rules from the specifed segment
 Segment details()
          Gets the details of the specified segment, including all rules and the current number of active subscribers.
 java.lang.String getSegmentID()
          Gets the current segment ID.
 void setSegmentID(java.lang.String segmentID)
          Sets the current segment ID
 void update(Segment segment)
          Updates an existing segment with the specified details
 
Methods inherited from class com.createsend.CreateSendBase
refreshToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Segments

public Segments(AuthenticationDetails auth)
Constructor used to create new segments.

Parameters:
auth - The authentication details to use when making API calls. May be either an OAuthAuthenticationDetails or ApiKeyAuthenticationDetails instance.

Segments

public Segments(AuthenticationDetails auth,
                java.lang.String segmentID)
Constructor for working with existing segments.

Parameters:
auth - The authentication details to use when making API calls. May be either an OAuthAuthenticationDetails or ApiKeyAuthenticationDetails instance.
segmentID - The Segment ID to use when making API calls.
Method Detail

setSegmentID

public void setSegmentID(java.lang.String segmentID)
Sets the current segment ID

Parameters:
segmentID - The ID of the segment to apply calls to.

getSegmentID

public java.lang.String getSegmentID()
Gets the current segment ID.

Returns:
The current segment ID.

create

public java.lang.String create(java.lang.String listID,
                               Segment segment)
                        throws CreateSendException
Creates a new segment on the specified list. A successful call to this method will set the current segment ID to that of the newly created segment.

Parameters:
listID - The ID of the list to segment
segment - The segment details
Returns:
The ID of the newly created segment
Throws:
CreateSendException - Thrown when the API responds with HTTP Status >= 400
See Also:
Creating a segment

update

public void update(Segment segment)
            throws CreateSendException
Updates an existing segment with the specified details

Parameters:
segment - The details of the segment to update. The SegmentID field of this object must be populated
Throws:
CreateSendException - Thrown when the API responds with HTTP Status >= 400
See Also:
Updating a segment

addRule

public void addRule(Rule rule)
             throws CreateSendException
Adds a new rule to an existing list segment

Parameters:
rule - The rule specification
Throws:
CreateSendException - Raised when the API responds with HTTP Status >= 400
See Also:
Adding a segment rule

details

public Segment details()
                throws CreateSendException
Gets the details of the specified segment, including all rules and the current number of active subscribers.

Returns:
The details of the specified segment.
Throws:
CreateSendException - Raised when the API responds with HTTP Status >= 400
See Also:
Getting a segment

active

public PagedResult<Subscriber> active()
                               throws CreateSendException
Gets a paged collection of active subscribers within the specified segment.

Returns:
The paged subscribers returned by the api call.
Throws:
CreateSendException - Thrown when the API responds with a HTTP Status >= 400
See Also:
Getting active subscribers

active

public PagedResult<Subscriber> active(java.lang.Integer page,
                                      java.lang.Integer pageSize,
                                      java.lang.String orderField,
                                      java.lang.String orderDirection)
                               throws CreateSendException
Gets a paged collection of active subscribers within the specified segment.

Parameters:
page - The page number or results to get. Use null for the default (page=1)
pageSize - The number of records to get on the current page. Use null for the default.
orderField - The field used to order the results by. Use null for the default.
orderDirection - The direction to order the results by. Use null for the default.
Returns:
The paged subscribers returned by the api call.
Throws:
CreateSendException - Thrown when the API responds with a HTTP Status >= 400
See Also:
Getting active subscribers

active

public PagedResult<Subscriber> active(java.util.Date subscribedFrom,
                                      java.lang.Integer page,
                                      java.lang.Integer pageSize,
                                      java.lang.String orderField,
                                      java.lang.String orderDirection)
                               throws CreateSendException
Gets a paged collection of active subscribers within the specified segment since the provided date.

Parameters:
subscribedFrom - The API will only return subscribers who became active on or after this date. This field is required
page - The page number or results to get. Use null for the default (page=1)
pageSize - The number of records to get on the current page. Use null for the default.
orderField - The field used to order the results by. Use null for the default.
orderDirection - The direction to order the results by. Use null for the default.
Returns:
The paged subscribers returned by the api call.
Throws:
CreateSendException - Thrown when the API responds with a HTTP Status >= 400
See Also:
Getting active subscribers

delete

public void delete()
            throws CreateSendException
Deletes the specified segment.

Throws:
CreateSendException - Raised when the API responds with HTTP Status >= 400
See Also:
Deleting a segment

deleteRules

public void deleteRules()
                 throws CreateSendException
Deletes all rules from the specifed segment

Throws:
CreateSendException - Raised when the API responds with HTTP Status >= 400
See Also:
Deleting a segments rules