├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── HISTORY.md ├── LICENSE ├── README.md ├── RELEASE.md ├── build.gradle ├── pom-include.xml ├── pom.xml ├── samples └── com │ └── createsend │ └── samples │ ├── AssertException.java │ ├── JourneysSampleRunner.java │ ├── SampleRunner.java │ └── TransactionalSample.java ├── src └── com │ └── createsend │ ├── Administrators.java │ ├── Campaigns.java │ ├── ClassicEmail.java │ ├── Clients.java │ ├── CreateSendBase.java │ ├── General.java │ ├── JourneyEmails.java │ ├── Journeys.java │ ├── Lists.java │ ├── Messages.java │ ├── People.java │ ├── Segments.java │ ├── SmartEmail.java │ ├── Subscribers.java │ ├── Templates.java │ ├── models │ ├── ApiErrorResponse.java │ ├── ApiKey.java │ ├── BillingDetails.java │ ├── ExternalSessionOptions.java │ ├── ExternalSessionResult.java │ ├── OAuthTokenDetails.java │ ├── PagedResult.java │ ├── SystemDate.java │ ├── administrators │ │ ├── Administrator.java │ │ └── AdministratorResult.java │ ├── campaigns │ │ ├── Campaign.java │ │ ├── CampaignClick.java │ │ ├── CampaignEventWithGeoData.java │ │ ├── CampaignForCreation.java │ │ ├── CampaignForCreationFromTemplate.java │ │ ├── CampaignOpen.java │ │ ├── CampaignSummary.java │ │ ├── DraftCampaign.java │ │ ├── EditableField.java │ │ ├── EmailClient.java │ │ ├── ListsAndSegments.java │ │ ├── PreviewData.java │ │ ├── Repeater.java │ │ ├── RepeaterItem.java │ │ ├── Schedule.java │ │ ├── ScheduledCampaign.java │ │ ├── SentCampaign.java │ │ └── TemplateContent.java │ ├── clients │ │ ├── AllClientDetails.java │ │ ├── BillingDetails.java │ │ ├── Client.java │ │ ├── ClientBasics.java │ │ ├── CreditsTransferDetails.java │ │ ├── CreditsTransferResult.java │ │ ├── SuppressionDetails.java │ │ ├── Tag.java │ │ └── Template.java │ ├── journeys │ │ ├── JourneyDetail.java │ │ ├── JourneyEmailBounceDetail.java │ │ ├── JourneyEmailClickDetail.java │ │ ├── JourneyEmailDetailWithGeoBase.java │ │ ├── JourneyEmailOpenDetail.java │ │ ├── JourneyEmailRecipient.java │ │ ├── JourneyEmailSummary.java │ │ ├── JourneyEmailUnsubscribeDetail.java │ │ └── JourneySummary.java │ ├── lists │ │ ├── BaseCustomField.java │ │ ├── CustomField.java │ │ ├── CustomFieldForCreate.java │ │ ├── CustomFieldForUpdate.java │ │ ├── List.java │ │ ├── ListBasics.java │ │ ├── ListForEmail.java │ │ ├── ListForUpdate.java │ │ ├── Statistics.java │ │ ├── UpdateFieldOptions.java │ │ ├── Webhook.java │ │ └── WebhookTestFailureDetails.java │ ├── people │ │ ├── Person.java │ │ ├── PersonResult.java │ │ └── PersonToAdd.java │ ├── segments │ │ ├── ClauseResults.java │ │ ├── Rule.java │ │ ├── RuleCreationFailureDetails.java │ │ ├── RuleGroup.java │ │ └── Segment.java │ ├── subscribers │ │ ├── Action.java │ │ ├── BouncedSubscriber.java │ │ ├── ConsentToTrack.java │ │ ├── CustomField.java │ │ ├── EmailToUnsubscribe.java │ │ ├── FailedImportSubscriber.java │ │ ├── HistoryItem.java │ │ ├── ImportResult.java │ │ ├── Subscriber.java │ │ ├── SubscriberToAdd.java │ │ ├── SubscriberWithJoinedDate.java │ │ ├── SubscribersToAdd.java │ │ └── SuppressedSubscriber.java │ ├── templates │ │ ├── BaseTemplate.java │ │ ├── TemplateDetails.java │ │ └── TemplateForCreate.java │ └── transactional │ │ ├── EmailContent.java │ │ ├── request │ │ ├── Attachment.java │ │ ├── ClassicEmailRequest.java │ │ └── SmartEmailRequest.java │ │ └── response │ │ ├── ClassicEmailGroup.java │ │ ├── GeoLocation.java │ │ ├── MailClient.java │ │ ├── Message.java │ │ ├── MessageDetail.java │ │ ├── MessageLogItem.java │ │ ├── MessageSent.java │ │ ├── SmartEmailDetails.java │ │ ├── SmartEmailItem.java │ │ ├── SmartEmailProperties.java │ │ ├── SmartEmailStatus.java │ │ ├── TransactionalClick.java │ │ ├── TransactionalOpen.java │ │ ├── TransactionalStatistics.java │ │ └── TransactionalStatisticsQuery.java │ └── util │ ├── ApiKeyAuthenticationDetails.java │ ├── AuthenticationDetails.java │ ├── Configuration.java │ ├── ErrorDeserialiser.java │ ├── JerseyClient.java │ ├── JerseyClientImpl.java │ ├── OAuthAuthenticationDetails.java │ ├── config.properties │ ├── exceptions │ ├── BadRequestException.java │ ├── CreateSendException.java │ ├── CreateSendHttpException.java │ ├── ExpiredOAuthTokenException.java │ ├── NotFoundException.java │ ├── RateLimitingException.java │ ├── ServerErrorException.java │ └── UnauthorisedException.java │ └── jersey │ ├── AuthorisedResourceFactory.java │ ├── JsonProvider.java │ ├── OAuth2BearerTokenFilter.java │ ├── ResourceFactory.java │ ├── UnauthorisedResourceFactory.java │ └── UserAgentFilter.java └── update-javadoc.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .classpath 3 | .project 4 | .gradle 5 | .settings 6 | .idea 7 | classes 8 | createsend-java.i* 9 | javadoc.xml 10 | workingsamples 11 | bin 12 | dist 13 | build 14 | doc 15 | target 16 | out 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | dist: trusty 4 | 5 | script: gradle -i 6 | 7 | jdk: 8 | - openjdk8 9 | - openjdk7 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Guidelines for contributing 2 | 3 | 1. [Fork the repository](https://help.github.com/articles/fork-a-repo). 4 | 2. [Create a topic branch](http://learn.github.com/p/branching.html). 5 | 3. Make your changes. 6 | 4. Ensure that the build passes, by running `gradle -i`. The [Travis CI build](https://travis-ci.org/campaignmonitor/createsend-java) runs on: `openjdk6`, `openjdk7`, and `oraclejdk7`. 7 | 5. It should go without saying, but do not increment the version number in your commits. 8 | 6. [Submit a pull request](https://help.github.com/articles/using-pull-requests). 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 James Dennes 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Releasing createsend-java 2 | 3 | ## Requirements 4 | 5 | Before you begin, you must have: 6 | * Apache Maven 3.0.4 or greater installed 7 | * Access to push to the [createsend-java repository on GitHub][] 8 | * A gpg key which is registered on a public key server (see [How To Generate PGP Signatures With Maven][]) 9 | * Sonatype OSS account with publish rights for the `com.createsend` group (see [Sonatype OSS Maven Repository Usage Guide][]) 10 | * `~/.m2/settings.xml` file that includes the Sonatype repositories, your Sonatype credentials, and your gpg keyname and passphrase: 11 | 12 | ```xml 13 | 14 | 15 | 16 | sonatype-nexus-snapshots 17 | username 18 | password 19 | 20 | 21 | sonatype-nexus-staging 22 | username 23 | password 24 | 25 | 26 | 27 | 28 | gpg 29 | 30 | yourkeyname 31 | yourpassphrase 32 | 33 | 34 | 35 | 36 | gpg 37 | 38 | 39 | ``` 40 | 41 | ## Releasing developer snapshot versions 42 | 43 | You can release developer SNAPSHOT versions of the package at any time for developer testing. These are released by running: 44 | 45 | ```sh 46 | $ gradle uploadArchive 47 | ``` 48 | 49 | Developer snapshot versions can be found in the [snapshot repo][]. 50 | 51 | ## Releasing production versions 52 | 53 | ### Prepare release 54 | 55 | * Increment version constants in the following files, ensuring that you use [Semantic Versioning][]: 56 | 57 | - `build.gradle` 58 | - `pom.xml` (as the SNAPSHOT version - change might not be required) 59 | - `src/com/createsend/util/config.properties` 60 | 61 | * Add an entry to `HISTORY.md` which clearly explains the new release. 62 | * Commit your changes: 63 | 64 | ```sh 65 | $ git commit -am "Version X.Y.Z" 66 | ``` 67 | 68 | ### Releasing to Sonatype OSS staging repository 69 | 70 | Ensure that the version specified in `pom.xml` includes the `-SNAPSHOT` suffix. It should take the form: `X.Y.Z-SNAPSHOT` 71 | 72 | Then _prepare_ the release. This will tag the repository and increment the version number in `pom.xml` for the next development iteration. When you are asked for the tag to apply to the release, use a tag of the form: `vX.Y.Z`: 73 | 74 | ```sh 75 | $ mvn -Dresume=false release:prepare 76 | ``` 77 | 78 | Then _perform_ the release. This will build and sign all artifacts and upload them to the staging repository: 79 | 80 | ```sh 81 | $ mvn release:perform 82 | ``` 83 | 84 | ### Promoting the release from staging 85 | 86 | In order to promote the release from the staging repository, log in to [Sonatype OSS][], and from the _Build Promotion_ tab on the left hand site select _Staging Repositories_. 87 | 88 | The release you just uploaded should show up in the list. Select the release and click _Close_. This will check if the deployment is complete and properly signed, then create a staging repository which can be used for testing. Once the closing process is successful, click _Release_ to actually release it to the [release repo][]. The release repo is synced with [Maven Central][]. 89 | 90 | ### Generate and publish javadoc 91 | 92 | Generate and publish the javadoc for the new release: 93 | 94 | ```sh 95 | $ ./update-javadoc.sh 96 | ``` 97 | 98 | Documentation is published to: http://campaignmonitor.github.io/createsend-java/doc/ 99 | 100 | [createsend-java repository on GitHub]: https://github.com/campaignmonitor/createsend-java 101 | [Sonatype OSS Maven Repository Usage Guide]: http://central.sonatype.org/pages/ossrh-guide.html 102 | [Sonatype OSS]: https://oss.sonatype.org/ 103 | [How To Generate PGP Signatures With Maven]: http://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/ 104 | [release repo]: https://oss.sonatype.org/content/repositories/releases/com/createsend/createsend-java/ 105 | [snapshot repo]: https://oss.sonatype.org/content/repositories/snapshots/com/createsend/createsend-java/ 106 | [Maven Central]: http://repo1.maven.org/maven2/ 107 | [Semantic Versioning]: http://semver.org/ -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'maven' 3 | apply plugin: 'eclipse' 4 | apply plugin: 'idea' 5 | 6 | install.dependsOn ':build' 7 | defaultTasks 'clean', 'install' 8 | 9 | sourceCompatibility = 1.7 10 | version = '7.0.1' 11 | group = 'com.createsend' 12 | 13 | def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath 14 | 15 | repositories { 16 | mavenCentral() 17 | } 18 | 19 | dependencies { 20 | compile group: 'com.sun.jersey', name: 'jersey-client', version: '1.17.1' 21 | compile group: 'com.sun.jersey', name: 'jersey-json', version: '1.17.1' 22 | compile group: 'com.sun.jersey', 'name': 'jersey-core', version: '1.17.1' 23 | compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.10.2' 24 | compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.2' 25 | compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.2' 26 | compile group: 'commons-codec', name: 'commons-codec', version: '1.10' 27 | compile group: 'commons-io', name: 'commons-io', version: '2.7' 28 | } 29 | 30 | sourceSets { 31 | main { 32 | java { 33 | srcDir 'src' 34 | } 35 | resources { 36 | srcDir 'src' 37 | } 38 | } 39 | samples { 40 | java { 41 | srcDir 'samples' 42 | } 43 | } 44 | } 45 | 46 | task copyToLib(type: Copy) { 47 | into "$buildDir/libs" 48 | from configurations.runtime 49 | } 50 | 51 | task doc(type: Javadoc) { 52 | source = sourceSets.main.allJava 53 | title = "createsend-java $version" 54 | classpath = sourceSets.main.compileClasspath 55 | destinationDir = new File(new File(buildDir, 'doc'), version) 56 | options.version = true 57 | } 58 | 59 | uploadArchives { 60 | repositories { 61 | mavenDeployer { 62 | snapshotRepository( 63 | url: 'https://oss.sonatype.org/content/repositories/snapshots', 64 | id: 'sonatype-nexus-snapshots') { 65 | authentication(getAuth('sonatype-nexus-snapshots')) 66 | } 67 | repository( 68 | url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/', 69 | id: 'sonatype-nexus-staging') { 70 | authentication(getAuth('sonatype-nexus-staging')) 71 | } 72 | 73 | pom { 74 | project { 75 | name 'createsend-java' 76 | description 'A Java library which implements the complete functionality of the Campaign Monitor API.' 77 | url 'http://campaignmonitor.github.io/createsend-java/' 78 | licenses { 79 | license { 80 | name 'The MIT License' 81 | url 'https://raw.github.com/campaignmonitor/createsend-java/master/LICENSE' 82 | distribution 'repo' 83 | } 84 | } 85 | } 86 | withXml { xml -> 87 | new XmlParser().parse(new File("pom-include.xml")).children().each { kid -> xml.asNode().append(kid) } 88 | } 89 | } 90 | } 91 | } 92 | } 93 | 94 | task writePom << { 95 | uploadArchives.repositories.mavenDeployer().getPom().writeTo("pom.xml") 96 | } 97 | 98 | def getAuth(repo_id) { 99 | def m2_settings = new File("${System.getProperty('user.home')}/.m2/settings.xml") 100 | if (m2_settings.exists()) { 101 | def settings = new XmlSlurper().parse(m2_settings) 102 | def repo = settings.servers.server.find { it.id.text() == repo_id } 103 | if (repo != null) return [userName: repo.username.text(), password: repo.password.text()] 104 | } 105 | [:] 106 | } 107 | -------------------------------------------------------------------------------- /pom-include.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | scm:git:https://github.com/campaignmonitor/createsend-java.git 4 | scm:git:https://github.com/campaignmonitor/createsend-java.git 5 | https://github.com/campaignmonitor/createsend-java.git 6 | 7 | 8 | 9 | 10 | jdennes 11 | James Dennes 12 | jdennes@gmail.com 13 | 14 | 15 | tobio 16 | Toby Brain 17 | tobio85@gmail.com 18 | 19 | 20 | 21 | 22 | 23 | sonatype-nexus-staging 24 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 25 | 26 | 27 | 28 | 29 | src 30 | 31 | 32 | src 33 | 34 | **/*.java 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.plugins 41 | maven-compiler-plugin 42 | 2.3 43 | 44 | 45 | maven-release-plugin 46 | 2.1 47 | 48 | deploy 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | release-sign-artifacts 57 | 58 | 59 | performRelease 60 | true 61 | 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-gpg-plugin 68 | 1.1 69 | 70 | 71 | install 72 | 73 | sign 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /samples/com/createsend/samples/AssertException.java: -------------------------------------------------------------------------------- 1 | package com.createsend.samples; 2 | 3 | public class AssertException extends Exception { 4 | 5 | public AssertException(String message) { 6 | super(message); 7 | } 8 | 9 | /** 10 | * 11 | */ 12 | 13 | 14 | private static final long serialVersionUID = -7496656424119969622L; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/com/createsend/Administrators.java: -------------------------------------------------------------------------------- 1 | package com.createsend; 2 | 3 | import javax.ws.rs.core.MultivaluedMap; 4 | 5 | import com.createsend.models.administrators.Administrator; 6 | import com.createsend.models.administrators.AdministratorResult; 7 | import com.createsend.util.AuthenticationDetails; 8 | import com.createsend.util.JerseyClientImpl; 9 | import com.createsend.util.exceptions.CreateSendException; 10 | import com.sun.jersey.core.util.MultivaluedMapImpl; 11 | 12 | public class Administrators extends CreateSendBase { 13 | 14 | /** 15 | * Constructor. 16 | * @param auth The authentication details to use when making API calls. 17 | * May be either an OAuthAuthenticationDetails or 18 | * ApiKeyAuthenticationDetails instance. 19 | */ 20 | public Administrators(AuthenticationDetails auth) { 21 | this.jerseyClient = new JerseyClientImpl(auth); 22 | } 23 | 24 | /** 25 | * Adds an administrator to the account. 26 | * @param person The administrator to add to the account 27 | * @return The email address of the newly added administrator 28 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 29 | * @see 30 | * Adding a subscriber 31 | */ 32 | public String add(Administrator person) throws CreateSendException { 33 | return jerseyClient.post(AdministratorResult.class, person, "admins.json").EmailAddress; 34 | } 35 | 36 | /** 37 | * Gets the details for the administrator with the given email address 38 | * @param emailAddress The email address of the administrator to get the details for 39 | * @return The details of the person 40 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 41 | * @see 42 | * Getting subscriber details 43 | */ 44 | public Administrator details(String emailAddress) throws CreateSendException { 45 | MultivaluedMap queryString = new MultivaluedMapImpl(); 46 | queryString.add("email", emailAddress); 47 | 48 | return jerseyClient.get(Administrator.class, queryString, "admins.json"); 49 | } 50 | 51 | /** 52 | * Deletes the administrator with the specified email address from this account 53 | * @param emailAddress The email address of the administrator to delete 54 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 55 | * @see 56 | * Deleting a subscriber 57 | */ 58 | public void delete(String emailAddress) throws CreateSendException { 59 | MultivaluedMap queryString = new MultivaluedMapImpl(); 60 | queryString.add("email", emailAddress); 61 | 62 | jerseyClient.delete(queryString, "admins.json"); 63 | } 64 | 65 | /** 66 | * Updates the details for an existing administrator 67 | * @param originalEmailAddress The current email address of the existing administrator 68 | * @param newDetails The new details for the administrator. 69 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 70 | * @see 71 | * Updating a subscriber 72 | */ 73 | public void update(String originalEmailAddress, Administrator newDetails) throws CreateSendException { 74 | MultivaluedMap queryString = new MultivaluedMapImpl(); 75 | queryString.add("email", originalEmailAddress); 76 | 77 | jerseyClient.put(newDetails, queryString, "admins.json"); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/com/createsend/CreateSendBase.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend; 23 | 24 | import java.io.UnsupportedEncodingException; 25 | import java.net.URLEncoder; 26 | 27 | import javax.ws.rs.core.MediaType; 28 | 29 | import com.createsend.models.OAuthTokenDetails; 30 | import com.createsend.util.AuthenticationDetails; 31 | import com.createsend.util.Configuration; 32 | import com.createsend.util.JerseyClient; 33 | import com.createsend.util.JerseyClientImpl; 34 | import com.createsend.util.OAuthAuthenticationDetails; 35 | import com.createsend.util.exceptions.CreateSendException; 36 | 37 | public abstract class CreateSendBase { 38 | protected static final String URL_ENCODING_SCHEME = "UTF-8"; 39 | 40 | protected JerseyClient jerseyClient = null; 41 | 42 | /** 43 | * Refresh the current OAuth token using the current refresh token. 44 | * 45 | * @return New OAuthTokenDetails instance containing the new access token, 46 | * 'expires in' value, and refresh token. 47 | */ 48 | public OAuthTokenDetails refreshToken() throws CreateSendException { 49 | OAuthTokenDetails result = null; 50 | AuthenticationDetails auth = this.jerseyClient 51 | .getAuthenticationDetails(); 52 | if (auth != null && auth instanceof OAuthAuthenticationDetails) { 53 | OAuthAuthenticationDetails oauthDetails = (OAuthAuthenticationDetails) auth; 54 | String body = "grant_type=refresh_token"; 55 | try { 56 | body += "&refresh_token=" 57 | + URLEncoder.encode(oauthDetails.getRefreshToken(), URL_ENCODING_SCHEME); 58 | } catch (UnsupportedEncodingException e) { 59 | body = null; 60 | } 61 | JerseyClient oauthClient = new JerseyClientImpl(null); 62 | 63 | // TODO: Use a custom error deserialiser in the following post 64 | 65 | result = oauthClient.post(Configuration.Current.getOAuthBaseUri(), 66 | OAuthTokenDetails.class, body, 67 | MediaType.APPLICATION_FORM_URLENCODED_TYPE, "token"); 68 | if (result != null && result.access_token != null 69 | && result.refresh_token != null) { 70 | AuthenticationDetails newAuthDetails = new OAuthAuthenticationDetails( 71 | result.access_token, result.refresh_token); 72 | this.jerseyClient.setAuthenticationDetails(newAuthDetails); 73 | } 74 | } 75 | return result; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/createsend/Journeys.java: -------------------------------------------------------------------------------- 1 | package com.createsend; 2 | 3 | import com.createsend.models.journeys.JourneySummary; 4 | import com.createsend.util.AuthenticationDetails; 5 | import com.createsend.util.JerseyClientImpl; 6 | import com.createsend.util.exceptions.CreateSendException; 7 | 8 | public class Journeys extends CreateSendBase { 9 | private String journeyID; 10 | 11 | public Journeys(AuthenticationDetails auth, String journeyID) { 12 | this.journeyID = journeyID; 13 | this.jerseyClient = new JerseyClientImpl(auth); 14 | } 15 | 16 | public JourneySummary summary() throws CreateSendException { 17 | return jerseyClient.get(JourneySummary.class, "journeys", journeyID + ".json"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/com/createsend/People.java: -------------------------------------------------------------------------------- 1 | package com.createsend; 2 | 3 | import javax.ws.rs.core.MultivaluedMap; 4 | 5 | import com.createsend.models.people.Person; 6 | import com.createsend.models.people.PersonResult; 7 | import com.createsend.models.people.PersonToAdd; 8 | import com.createsend.util.AuthenticationDetails; 9 | import com.createsend.util.JerseyClientImpl; 10 | import com.createsend.util.exceptions.CreateSendException; 11 | import com.sun.jersey.core.util.MultivaluedMapImpl; 12 | 13 | public class People extends CreateSendBase { 14 | private String clientID; 15 | 16 | /** 17 | * Constructor. 18 | * @param auth The authentication details to use when making API calls. 19 | * May be either an OAuthAuthenticationDetails or 20 | * ApiKeyAuthenticationDetails instance. 21 | * @param clientID The Client ID to use when making API calls. 22 | */ 23 | public People(AuthenticationDetails auth, String clientID) { 24 | this.setClientID(clientID); 25 | this.jerseyClient = new JerseyClientImpl(auth); 26 | } 27 | 28 | public String getClientID() { 29 | return clientID; 30 | } 31 | 32 | public void setClientID(String clientID) { 33 | this.clientID = clientID; 34 | } 35 | 36 | /** 37 | * Adds a person to the client. If a password is not supplied, an email invitation will be sent to the 38 | * person. Otherwise the person will be added with the specified password and immediately activated 39 | * @param person The person to add to the client 40 | * @return The email address of the newly added person 41 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 42 | * @see 43 | * Adding a person 44 | */ 45 | public String add(PersonToAdd person) throws CreateSendException { 46 | return jerseyClient.post(PersonResult.class, person, "clients", clientID, "people" + ".json").EmailAddress; 47 | } 48 | 49 | /** 50 | * Gets the details for the person with the given email address 51 | * @param emailAddress The email address to get the person details for 52 | * @return The details of the person 53 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 54 | * @see 55 | * Getting person details 56 | */ 57 | public Person details(String emailAddress) throws CreateSendException { 58 | MultivaluedMap queryString = new MultivaluedMapImpl(); 59 | queryString.add("email", emailAddress); 60 | 61 | return jerseyClient.get(Person.class, queryString, "clients", clientID, "people" + ".json"); 62 | } 63 | 64 | /** 65 | * Deletes the person with the specified email address from the client 66 | * @param emailAddress The email address of the person to delete 67 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 68 | * @see 69 | * Deleting a person 70 | */ 71 | public void delete(String emailAddress) throws CreateSendException { 72 | MultivaluedMap queryString = new MultivaluedMapImpl(); 73 | queryString.add("email", emailAddress); 74 | 75 | jerseyClient.delete(queryString, "clients", clientID, "people" + ".json"); 76 | } 77 | 78 | /** 79 | * Updates the details for an existing person 80 | * @param originalEmailAddress The current email address of the existing person 81 | * @param newDetails The new details for the person. 82 | * @throws CreateSendException Thrown when the API responds with HTTP Status >= 400 83 | * @see 84 | * Updating a person 85 | */ 86 | public void update(String originalEmailAddress, Person newDetails) throws CreateSendException { 87 | MultivaluedMap queryString = new MultivaluedMapImpl(); 88 | queryString.add("email", originalEmailAddress); 89 | 90 | jerseyClient.put(newDetails, queryString, "clients", clientID, "people" + ".json"); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/com/createsend/models/ApiErrorResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models; 23 | 24 | public class ApiErrorResponse { 25 | // For deserialisation of API errors 26 | public int Code; 27 | public String Message; 28 | public T ResultData; 29 | 30 | // For deserialisation of OAuth errors 31 | public String error; 32 | public String error_description; 33 | } 34 | -------------------------------------------------------------------------------- /src/com/createsend/models/ApiKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models; 23 | 24 | public class ApiKey { 25 | public String ApiKey; 26 | } 27 | -------------------------------------------------------------------------------- /src/com/createsend/models/BillingDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models; 23 | 24 | public class BillingDetails { 25 | public int Credits; 26 | } -------------------------------------------------------------------------------- /src/com/createsend/models/ExternalSessionOptions.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models; 2 | 3 | public class ExternalSessionOptions { 4 | public String Email; 5 | public String Chrome; 6 | public String Url; 7 | public String IntegratorID; 8 | public String ClientID; 9 | } 10 | -------------------------------------------------------------------------------- /src/com/createsend/models/ExternalSessionResult.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models; 2 | 3 | public class ExternalSessionResult { 4 | public String SessionUrl; 5 | } 6 | -------------------------------------------------------------------------------- /src/com/createsend/models/OAuthTokenDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models; 23 | 24 | public class OAuthTokenDetails { 25 | public String access_token; 26 | public int expires_in; 27 | public String refresh_token; 28 | } 29 | -------------------------------------------------------------------------------- /src/com/createsend/models/PagedResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models; 23 | 24 | import java.util.Arrays; 25 | 26 | public class PagedResult { 27 | public T[] Results; 28 | public String ResultsOrderedBy; 29 | public String OrderDirection; 30 | public int PageNumber; 31 | public int PageSize; 32 | public int RecordsOnThisPage; 33 | public int TotalNumberOfRecords; 34 | public int NumberOfPages; 35 | 36 | @Override 37 | public String toString() { 38 | return String.format("{ Results: %s, ResultsOrderedBy: %s, OrderDirection: %s, PageNumber: %s, PageSize: %s, RecordsOnThisPage: %s, TotalNumberOfRecords: %s, NumberOfPages: %s }", 39 | Arrays.deepToString(Results), ResultsOrderedBy, OrderDirection, PageNumber, 40 | PageSize, RecordsOnThisPage, TotalNumberOfRecords, 41 | NumberOfPages); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/createsend/models/SystemDate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models; 23 | 24 | import java.util.Date; 25 | 26 | public class SystemDate { 27 | public Date SystemDate; 28 | } -------------------------------------------------------------------------------- /src/com/createsend/models/administrators/Administrator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 Paul Duran 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.administrators; 23 | 24 | public class Administrator { 25 | public String EmailAddress; 26 | public String Name; 27 | public String Status; 28 | } 29 | -------------------------------------------------------------------------------- /src/com/createsend/models/administrators/AdministratorResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 Paul Duran 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.administrators; 23 | 24 | public class AdministratorResult { 25 | public String EmailAddress; 26 | } 27 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/Campaign.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | public class Campaign { 25 | public String CampaignID; 26 | public String Subject; 27 | public String Name; 28 | public String FromName; 29 | public String FromEmail; 30 | public String ReplyTo; 31 | 32 | @Override 33 | public String toString() { 34 | return String.format("CampaignID: %s, Subject: %s, Name: %s, FromName: %s, FromEmail: %s, ReplyTo: %s", 35 | CampaignID, Subject, Name, FromName, FromEmail, ReplyTo); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/CampaignClick.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class CampaignClick extends CampaignEventWithGeoData { 4 | public String URL; 5 | 6 | @Override 7 | public String toString() { 8 | return String.format("{ URL: %s, EmailAddress: %s, ListID: %s, Date: %s, IPAddress: %s, Latitude: %s, Longitude: %s, City: %s, Region: %s, CountryCode: %s, CountryName: %s }", 9 | URL, EmailAddress, ListID, Date, IPAddress, Latitude, Longitude, City, Region, CountryCode, CountryName); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/CampaignEventWithGeoData.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class CampaignEventWithGeoData { 4 | public String EmailAddress; 5 | public String ListID; 6 | public java.util.Date Date; 7 | public String IPAddress; 8 | public float Latitude; 9 | public float Longitude; 10 | public String City; 11 | public String Region; 12 | public String CountryCode; 13 | public String CountryName; 14 | 15 | @Override 16 | public String toString() { 17 | return String.format("{ EmailAddress: %s, ListID: %s, Date: %s, IPAddress: %s, Latitude: %s, Longitude: %s, City: %s, Region: %s, CountryCode: %s, CountryName: %s }", 18 | EmailAddress, ListID, Date, IPAddress, Latitude, Longitude, City, Region, CountryCode, CountryName); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/CampaignForCreation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | import java.net.URI; 25 | 26 | public class CampaignForCreation extends Campaign { 27 | public String FromName; 28 | public String FromEmail; 29 | public String ReplyTo; 30 | public URI HtmlUrl; 31 | // Note that TextUrl is optional and if provided as either null or an 32 | // empty string, text content for the campaign will be generated from 33 | // the HTML content. 34 | public URI TextUrl; 35 | public String[] ListIDs; 36 | public String[] SegmentIDs; 37 | } 38 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/CampaignForCreationFromTemplate.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class CampaignForCreationFromTemplate extends Campaign { 4 | public String FromName; 5 | public String FromEmail; 6 | public String ReplyTo; 7 | public String[] ListIDs; 8 | public String[] SegmentIDs; 9 | public String TemplateID; 10 | public TemplateContent TemplateContent; 11 | } 12 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/CampaignOpen.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class CampaignOpen extends CampaignEventWithGeoData { } 4 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/CampaignSummary.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | public class CampaignSummary { 25 | public String Name; 26 | public int Recipients; 27 | public int TotalOpened; 28 | public int Clicks; 29 | public int Unsubscribed; 30 | public int SpamComplaints; 31 | public int Bounced; 32 | public int UniqueOpened; 33 | public int Forwards; 34 | public int Mentions; 35 | public int Likes; 36 | public String WebVersionURL; 37 | public String WebVersionTextURL; 38 | public String WorldviewURL; 39 | 40 | @Override 41 | public String toString() { 42 | return String.format( 43 | "{ Name: %s, Recipients: %s, TotalOpened: %s, Clicks: %s, Unsubscribed: %s, SpamComplaints: %s, " + 44 | "Bounced: %s, UniqueOpened: %s, ForwardToAFriends: %s, TwitterTweets: %s, FacebookLikes: %s, " + 45 | "WebVersionURL: %s, WebVersionTextURL: %s, WorldviewURL: %s }", 46 | Name, Recipients, TotalOpened, Clicks, Unsubscribed, SpamComplaints, 47 | Bounced, UniqueOpened, Forwards, Mentions, Likes, 48 | WebVersionURL, WebVersionTextURL, WorldviewURL); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/DraftCampaign.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | import java.util.Arrays; 25 | import java.util.Date; 26 | 27 | public class DraftCampaign extends Campaign { 28 | public Date DateCreated; 29 | public String PreviewURL; 30 | public String PreviewTextURL; 31 | public String[] Tags; 32 | 33 | @Override 34 | public String toString() { 35 | return String.format( 36 | "{ %s, DateCreated: %s, PreviewURL: %s, PreviewTextURL: %s, Tags: %s }", 37 | super.toString(), DateCreated, PreviewURL, PreviewTextURL, Arrays.toString(Tags)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/EditableField.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class EditableField { 4 | public String Content; 5 | public String Alt; 6 | public String Href; 7 | } 8 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/EmailClient.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class EmailClient { 4 | public String Client; 5 | public String Version; 6 | public float Percentage; 7 | public int Subscribers; 8 | 9 | @Override 10 | public String toString() { 11 | return String.format( 12 | "{ Client: %s, Version: %s, Percentage: %d, Subscribers: %d }", 13 | Client, Version, Percentage, Subscribers); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/ListsAndSegments.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | import java.util.Arrays; 25 | 26 | import com.createsend.models.lists.ListBasics; 27 | import com.createsend.models.segments.Segment; 28 | 29 | public class ListsAndSegments { 30 | public ListBasics[] Lists; 31 | public Segment[] Segments; 32 | 33 | @Override 34 | public String toString() { 35 | return String.format("{ Lists: %s, Segments: %s }", 36 | Arrays.deepToString(Lists), Arrays.deepToString(Segments)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/PreviewData.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | public class PreviewData { 25 | public String[] PreviewRecipients; 26 | public String Personalize; 27 | } 28 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/Repeater.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class Repeater { 4 | public RepeaterItem[] Items; 5 | } 6 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/RepeaterItem.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class RepeaterItem { 4 | public String Layout; 5 | public EditableField[] Singlelines; 6 | public EditableField[] Multilines; 7 | public EditableField[] Images; 8 | } 9 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/Schedule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | public class Schedule { 25 | public String ConfirmationEmail; 26 | public String SendDate; 27 | } 28 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/ScheduledCampaign.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | import java.util.Date; 25 | 26 | public class ScheduledCampaign extends DraftCampaign { 27 | public Date DateScheduled; 28 | public String ScheduledTimeZone; 29 | 30 | @Override 31 | public String toString() { 32 | return String.format( 33 | "{ %s, DateScheduled: %s, ScheduledTimeZone: %s}", 34 | super.toString(), DateScheduled, ScheduledTimeZone); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/SentCampaign.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.campaigns; 23 | 24 | import java.util.Arrays; 25 | import java.util.Date; 26 | 27 | public class SentCampaign extends Campaign { 28 | public String WebVersionURL; 29 | public String WebVersionTextURL; 30 | public Date SentDate; 31 | public int TotalRecipients; 32 | public String[] Tags; 33 | 34 | @Override 35 | public String toString() { 36 | return String.format( 37 | "{ %s, SendDate: %s, WebVersionURL: %s, WebVersionTextURL: %s, TotalRecipients: %d, Tags: %s }", 38 | super.toString(), SentDate, WebVersionURL, WebVersionTextURL, TotalRecipients, Arrays.toString(Tags)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/com/createsend/models/campaigns/TemplateContent.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.campaigns; 2 | 3 | public class TemplateContent { 4 | public EditableField[] Singlelines; 5 | public EditableField[] Multilines; 6 | public EditableField[] Images; 7 | public Repeater[] Repeaters; 8 | } 9 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/AllClientDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.clients; 23 | 24 | public class AllClientDetails { 25 | public String ApiKey; 26 | public Client BasicDetails; 27 | public BillingDetails BillingDetails; 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("%s { Basic: %s, Billing: %s", 32 | ApiKey, BasicDetails, BillingDetails); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/BillingDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.clients; 23 | 24 | public class BillingDetails { 25 | public boolean CanPurchaseCredits; 26 | public int Credits; 27 | public boolean ClientPays; 28 | 29 | public String Currency; 30 | 31 | public Integer MarkupPercentage; 32 | 33 | public Double MarkupOnDesignSpamTest; 34 | public Double BaseRatePerRecipient; 35 | public Double MarkupPerRecipient; 36 | public Double MarkupOnDelivery; 37 | public Double BaseDeliveryRate; 38 | public Double BaseDesignSpamTestRate; 39 | public String MonthlyScheme; // Should be either null, 'Basic' or 'Unlimited' 40 | 41 | @Override 42 | public String toString() { 43 | return String.format("{ CanPurchaseCredits: %s, MarkupOnDesignSpamTest: %s, ClientPays: %s, BaseRatePerRecipient: %s, MarkupPerRecipient: %s, MarkupOnDelivery: %s, BaseDeliveryRate: %s, Currency: %s, BaseDesignSpamTestRate: %s, MonthlyScheme %s }", 44 | CanPurchaseCredits, MarkupOnDesignSpamTest, ClientPays, BaseRatePerRecipient, 45 | MarkupPerRecipient, MarkupOnDelivery, BaseDeliveryRate, Currency, BaseDesignSpamTestRate, MonthlyScheme); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/Client.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.clients; 23 | 24 | public class Client { 25 | public String ClientID; 26 | public String CompanyName; 27 | 28 | public String Country; 29 | public String TimeZone; 30 | 31 | public String toString() { 32 | return String.format("{ ID: %s, Company: %s, Country: %s, TZ: %s }", 33 | ClientID, CompanyName, Country, TimeZone); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/ClientBasics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.clients; 23 | 24 | public class ClientBasics { 25 | public String ClientID; 26 | public String Name; 27 | } 28 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/CreditsTransferDetails.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.clients; 2 | 3 | public class CreditsTransferDetails { 4 | /** 5 | * Represents the number of credits to transfer. This value may be either 6 | * positive if you want to allocate credits from your account to the 7 | * client, or negative if you want to deduct credits 8 | * from the client back into your account. 9 | */ 10 | public int Credits; 11 | /** 12 | * If set to true, will allow the client to continue sending using your 13 | * credits or payment details once they run out of credits, and if set to 14 | * false, will prevent the client from using your credits to continue 15 | * sending until you allocate more credits to them. 16 | */ 17 | public boolean CanUseMyCreditsWhenTheyRunOut; 18 | } 19 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/CreditsTransferResult.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.clients; 2 | 3 | public class CreditsTransferResult { 4 | /** 5 | * Represents the number of credits in your account now. 6 | */ 7 | public int AccountCredits; 8 | /** 9 | * Represents the number of credits in the client's account now. 10 | */ 11 | public int ClientCredits; 12 | } 13 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/SuppressionDetails.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.clients; 2 | 3 | public class SuppressionDetails { 4 | public String[] EmailAddresses; 5 | } 6 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/Tag.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Campaign Monitor 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.clients; 23 | 24 | public class Tag { 25 | public String Name; 26 | public int NumberOfCampaigns; 27 | 28 | @Override 29 | public String toString() { 30 | return String.format( 31 | "{ Name: %s, NumberOfCampaigns: %s }", 32 | Name, NumberOfCampaigns); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/createsend/models/clients/Template.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.clients; 23 | 24 | public class Template { 25 | public String TemplateID; 26 | public String Name; 27 | public String PreviewURL; 28 | public String ScreenshotURL; 29 | 30 | @Override 31 | public String toString() { 32 | return String.format("{ TemplateID: %s, Name: %s, PreviewURL: %s, ScreenshotURL: %s }", 33 | TemplateID, Name, PreviewURL, ScreenshotURL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyDetail.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | public class JourneyDetail { 4 | public String ListID; 5 | public String JourneyID; 6 | public String Name; 7 | public String Status; 8 | } 9 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyEmailBounceDetail.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | public class JourneyEmailBounceDetail { 4 | public String EmailAddress; 5 | public String BounceType; 6 | public java.util.Date Date; 7 | public String Reason; 8 | } 9 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyEmailClickDetail.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | public class JourneyEmailClickDetail extends JourneyEmailDetailWithGeoBase { 4 | public String EmailAddress; 5 | public java.util.Date Date; 6 | public String URL; 7 | } 8 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyEmailDetailWithGeoBase.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | public class JourneyEmailDetailWithGeoBase { 4 | public String IPAddress; 5 | public double Latitude; 6 | public double Longitude; 7 | public String City; 8 | public String Region; 9 | public String CountryCode; 10 | public String CountryName; 11 | } 12 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyEmailOpenDetail.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | import java.util.Date; 4 | 5 | public class JourneyEmailOpenDetail extends JourneyEmailDetailWithGeoBase{ 6 | public String EmailAddress; 7 | public java.util.Date Date; 8 | } 9 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyEmailRecipient.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | import java.util.Date; 4 | 5 | public class JourneyEmailRecipient { 6 | public String EmailAddress; 7 | public Date SentDate; 8 | } 9 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyEmailSummary.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | public class JourneyEmailSummary { 4 | public String EmailID; 5 | public String Name; 6 | public int Sent; 7 | public int Opened; 8 | public int Clicked; 9 | public int Unsubscribed; 10 | public int Bounced; 11 | public int UniqueOpened; 12 | } 13 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneyEmailUnsubscribeDetail.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | public class JourneyEmailUnsubscribeDetail { 4 | public String EmailAddress; 5 | public java.util.Date Date; 6 | public String IPAddress; 7 | } 8 | -------------------------------------------------------------------------------- /src/com/createsend/models/journeys/JourneySummary.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.journeys; 2 | 3 | import java.util.List; 4 | 5 | public class JourneySummary { 6 | public String JourneyID; 7 | public String Name; 8 | public String TriggerType; 9 | public String Status; 10 | public List Emails; 11 | } 12 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/BaseCustomField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | class BaseCustomField { 25 | public String FieldName; 26 | public String DataType; // TODO: Probably want to move this to an enum 27 | public boolean VisibleInPreferenceCenter; 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("FieldName: %s, DataType: %s, VisibleInPreferenceCenter: %s", 32 | FieldName, DataType, VisibleInPreferenceCenter); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/CustomField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | import java.util.Arrays; 25 | 26 | public class CustomField extends BaseCustomField { 27 | public String Key; 28 | public String[] FieldOptions; 29 | 30 | public String toString() { 31 | return String.format("{ Key: %s %s, FieldOptions: %s }", Key, super.toString(), 32 | Arrays.deepToString(FieldOptions)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/CustomFieldForCreate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | public class CustomFieldForCreate extends BaseCustomField { 25 | public String[] Options; 26 | } 27 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/CustomFieldForUpdate.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.lists; 2 | 3 | public class CustomFieldForUpdate { 4 | public String FieldName; 5 | public boolean VisibleInPreferenceCenter; 6 | } 7 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/List.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | import java.net.URI; 25 | 26 | public class List { 27 | public String Title; 28 | public URI UnsubscribePage; 29 | public boolean ConfirmedOptIn; 30 | public URI ConfirmationSuccessPage; 31 | // Must be either "AllClientLists" or "OnlyThisList" 32 | // See http://www.campaignmonitor.com/api/lists/#creating_a_list 33 | // for details. 34 | public String UnsubscribeSetting; 35 | 36 | @Override 37 | public String toString() { 38 | return String.format("{ Title: %s, UnsubscribePage: %s, ConfirmedOptIn: %s, ConfirmationSuccessPage: %s," + 39 | "UnsubscribeSetting: %s }", Title, UnsubscribePage, ConfirmedOptIn, 40 | ConfirmationSuccessPage, UnsubscribeSetting); 41 | } 42 | } -------------------------------------------------------------------------------- /src/com/createsend/models/lists/ListBasics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | public class ListBasics { 25 | public String ListID; 26 | public String Name; 27 | 28 | @Override 29 | public String toString() { 30 | return String.format("{ ListID: %s, Name: %s } ", ListID, Name); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/ListForEmail.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | package com.createsend.models.lists; 24 | 25 | import java.util.Date; 26 | 27 | public class ListForEmail { 28 | public String ListID; 29 | public String ListName; 30 | public String SubscriberState; 31 | public Date DateSubscriberAdded; 32 | 33 | @Override 34 | public String toString() { 35 | return String.format("{ ListID: %s, ListName: %s, SubscriberState: %s, DateSubscriberAdded: %s } ", 36 | ListID, ListName, SubscriberState, DateSubscriberAdded); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/ListForUpdate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | public class ListForUpdate extends List { 25 | public boolean AddUnsubscribesToSuppList; 26 | public boolean ScrubActiveWithSuppList; 27 | } 28 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/Statistics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | public class Statistics { 25 | public int TotalActiveSubscribers; 26 | public int NewActiveSubscribersToday; 27 | public int NewActiveSubscribersYesterday; 28 | public int NewActiveSubscribersThisWeek; 29 | public int NewActiveSubscribersThisMonth; 30 | public int NewActiveSubscribersThisYear; 31 | public int TotalUnsubscribes; 32 | public int UnsubscribesToday; 33 | public int UnsubscribesYesterday; 34 | public int UnsubscribesThisWeek; 35 | public int UnsubscribesThisMonth; 36 | public int UnsubscribesThisYear; 37 | public int TotalDeleted; 38 | public int DeletedToday; 39 | public int DeletedYesterday; 40 | public int DeletedThisWeek; 41 | public int DeletedThisMonth; 42 | public int DeletedThisYear; 43 | 44 | @Override 45 | public String toString() { 46 | return String.format("TotalActiveSubscribers: %s, NewActiveSubscribersToday: %s, NewActiveSubscribersYesterday: %s, NewActiveSubscribersThisWeek: %s, NewActiveSubscribersThisMonth: %s, NewActiveSubscribersThisYear: %s, TotalUnsubscribes: %s, UnsubscribesToday: %s, UnsubscribesYesterday: %s, UnsubscribesThisWeek: %s, UnsubscribesThisMonth: %s, UnsubscribesThisYear: %s, TotalDeleted: %s, DeletedToday: %s, DeletedYesterday: %s, DeletedThisWeek: %s, DeletedThisMonth: %s, DeletedThisYear: %s, TotalBounces: %s, BouncesToday: %s, BouncesYesterday: %s, BouncesThisWeek: %s, BouncesThisMonth: %s, BouncesThisYear: %s", 47 | TotalActiveSubscribers, NewActiveSubscribersToday, NewActiveSubscribersYesterday, 48 | NewActiveSubscribersThisWeek, NewActiveSubscribersThisMonth, NewActiveSubscribersThisYear, 49 | TotalUnsubscribes, UnsubscribesToday, UnsubscribesYesterday, UnsubscribesThisWeek, 50 | UnsubscribesThisMonth, UnsubscribesThisYear, TotalDeleted, DeletedToday, 51 | DeletedYesterday, DeletedThisWeek, DeletedThisMonth, DeletedThisYear, TotalBounces, 52 | BouncesToday, BouncesYesterday, BouncesThisWeek, BouncesThisMonth, BouncesThisYear); 53 | } 54 | public int TotalBounces; 55 | public int BouncesToday; 56 | public int BouncesYesterday; 57 | public int BouncesThisWeek; 58 | public int BouncesThisMonth; 59 | public int BouncesThisYear; 60 | } 61 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/UpdateFieldOptions.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | public class UpdateFieldOptions { 25 | public boolean KeepExistingOptions; 26 | public String[] Options; 27 | } 28 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/Webhook.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | import java.net.URI; 25 | 26 | public class Webhook { 27 | public String WebhookID; 28 | public String[] Events; // TODO: Might want to move this to an enum 29 | public URI Url; 30 | public String Status; // TODO: Might want to move this to an enum 31 | public String PayloadFormat; // TODO: Might want to move this to an enum 32 | } 33 | -------------------------------------------------------------------------------- /src/com/createsend/models/lists/WebhookTestFailureDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.lists; 23 | 24 | public class WebhookTestFailureDetails { 25 | public String FailureStatus; 26 | public String FailureResponseMessage; 27 | public Integer FailureResponseCode; 28 | public String FailureResponse; 29 | 30 | @Override 31 | public String toString() { 32 | return String.format("{ FailureStatus: %s, FailureResponseMessage: %s, FailureResponseCode: %s }", 33 | FailureStatus, FailureResponseMessage, FailureResponseCode); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/createsend/models/people/Person.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 Paul Duran 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.people; 23 | 24 | public class Person { 25 | public String EmailAddress; 26 | public String Name; 27 | public int AccessLevel; 28 | public String Status; 29 | } 30 | -------------------------------------------------------------------------------- /src/com/createsend/models/people/PersonResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 Paul Duran 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.people; 23 | 24 | public class PersonResult { 25 | public String EmailAddress; 26 | } 27 | -------------------------------------------------------------------------------- /src/com/createsend/models/people/PersonToAdd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012 Paul Duran 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.people; 23 | 24 | public class PersonToAdd extends Person { 25 | public String Password; 26 | } 27 | -------------------------------------------------------------------------------- /src/com/createsend/models/segments/ClauseResults.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.segments; 23 | 24 | import com.createsend.models.ApiErrorResponse; 25 | 26 | public class ClauseResults extends ApiErrorResponse { 27 | public String Clause; 28 | } 29 | -------------------------------------------------------------------------------- /src/com/createsend/models/segments/Rule.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.segments; 23 | 24 | public class Rule { 25 | public String RuleType; 26 | public String Clause; 27 | 28 | @Override 29 | public String toString() { 30 | return String.format("{ Rule Type: %s, Clause: %s }", RuleType, Clause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/com/createsend/models/segments/RuleCreationFailureDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.segments; 23 | 24 | import com.createsend.models.ApiErrorResponse; 25 | 26 | public class RuleCreationFailureDetails extends ApiErrorResponse { 27 | public String Subject; 28 | public ClauseResults[] ClauseResults; 29 | } 30 | -------------------------------------------------------------------------------- /src/com/createsend/models/segments/RuleGroup.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.segments; 23 | 24 | import java.util.Arrays; 25 | 26 | public class RuleGroup { 27 | public Rule[] Rules; 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("{ Rules: %s }", Arrays.deepToString(Rules)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/createsend/models/segments/Segment.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.segments; 23 | 24 | import java.util.Arrays; 25 | 26 | public class Segment { 27 | public String ListID; 28 | public String SegmentID; 29 | public String Title; 30 | 31 | public Integer ActiveSubscribers; 32 | public RuleGroup[] RuleGroups; 33 | 34 | @Override 35 | public String toString() { 36 | return String.format("{ ListID: %s, SegmentID: %s, Title: %s, Active: %d, Rule Groups: %s }", ListID, 37 | SegmentID, Title, ActiveSubscribers, Arrays.deepToString(RuleGroups)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/Action.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | import java.util.Date; 25 | 26 | public class Action { 27 | public String Event; 28 | public Date Date; 29 | public String IPAddress; 30 | public String Detail; 31 | } 32 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/BouncedSubscriber.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 Campaign Monitor 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | public class BouncedSubscriber extends Subscriber { 25 | public String BounceType; 26 | public String Reason; 27 | 28 | @Override 29 | public String toString() { 30 | return String.format("{ Subscriber: %s, BouncedSubscriber: { BounceType: %s, Reason: %s } }", super.toString(), BounceType, Reason); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/ConsentToTrack.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.subscribers; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | 5 | public enum ConsentToTrack { 6 | UNCHANGED("Unchanged"), 7 | YES("Yes"), 8 | NO("No"); 9 | 10 | private String value; 11 | 12 | ConsentToTrack(String value) { 13 | this.value = value; 14 | } 15 | 16 | @JsonCreator 17 | public static ConsentToTrack forValue(String value) { 18 | for (ConsentToTrack type : ConsentToTrack.values()) { 19 | if (type.value.toLowerCase().equals(value.toLowerCase())) { 20 | return type; 21 | } 22 | } 23 | 24 | return null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/CustomField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | public class CustomField { 25 | public String Key; 26 | public String Value; 27 | public Boolean Clear; 28 | 29 | @Override 30 | public String toString() { 31 | return String.format("{ Key: %s, Value: %s, Clear: %s }", Key, Value, Clear); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/EmailToUnsubscribe.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | public class EmailToUnsubscribe { 25 | public String EmailAddress; 26 | 27 | public static EmailToUnsubscribe fromString(String emailAddress) { 28 | EmailToUnsubscribe obj = new EmailToUnsubscribe(); 29 | obj.EmailAddress = emailAddress; 30 | 31 | return obj; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/FailedImportSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.subscribers; 2 | 3 | import com.createsend.models.ApiErrorResponse; 4 | 5 | public class FailedImportSubscriber extends ApiErrorResponse { 6 | public String EmailAddress; 7 | } 8 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/HistoryItem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | public class HistoryItem { 25 | public String ID; 26 | public String Type; // TODO: Probably want to move this to an enum 27 | public String Name; 28 | public Action[] Actions; 29 | } 30 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/ImportResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | public class ImportResult { 25 | public FailedImportSubscriber[] FailureDetails; 26 | public int TotalUniqueEmailsSubmitted; 27 | public int TotalExistingSubscribers; 28 | public int TotalNewSubscribers; 29 | public String[] DuplicateEmailsInSubmission; 30 | } 31 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/Subscriber.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | import java.util.Date; 25 | 26 | public class Subscriber { 27 | public String ListID; 28 | public String EmailAddress; 29 | public String Name; 30 | public Date Date; 31 | public String State; // TODO: Probably want to move this to an enum 32 | public CustomField[] CustomFields; 33 | public String ReadsEmailWith; 34 | public ConsentToTrack ConsentToTrack; 35 | 36 | @Override 37 | public String toString() { 38 | return String.format("{ ListID: %s, EmailAddress: %s, Name: %s, Date: %s, State: %s }", 39 | ListID, EmailAddress, Name, Date, State); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/SubscriberToAdd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | public class SubscriberToAdd extends Subscriber { 25 | public boolean Resubscribe; 26 | public boolean RestartSubscriptionBasedAutoresponders; 27 | } 28 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/SubscriberWithJoinedDate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2021 Campaign Monitor 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | import java.util.Date; 25 | 26 | public class SubscriberWithJoinedDate { 27 | public String ListID; 28 | public String EmailAddress; 29 | public String Name; 30 | public Date Date; 31 | public Date ListJoinedDate; 32 | public String State; // TODO: Probably want to move this to an enum 33 | public CustomField[] CustomFields; 34 | public String ReadsEmailWith; 35 | public ConsentToTrack ConsentToTrack; 36 | 37 | @Override 38 | public String toString() { 39 | return String.format("{ ListID: %s, EmailAddress: %s, Name: %s, Date: %s, ListJoinedDate: %s, State: %s }", 40 | ListID, EmailAddress, Name, Date, ListJoinedDate, State); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/SubscribersToAdd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.subscribers; 23 | 24 | public class SubscribersToAdd { 25 | public Subscriber[] Subscribers; 26 | public Boolean Resubscribe; 27 | public Boolean QueueSubscriptionBasedAutoResponders; 28 | public boolean RestartSubscriptionBasedAutoresponders; 29 | } 30 | -------------------------------------------------------------------------------- /src/com/createsend/models/subscribers/SuppressedSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.createsend.models.subscribers; 2 | 3 | public class SuppressedSubscriber extends Subscriber { 4 | public String SuppressionReason; 5 | 6 | @Override 7 | public String toString() { 8 | return String.format("{ Subscriber: %s, SuppressionReason: %s }", super.toString(), SuppressionReason); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/com/createsend/models/templates/BaseTemplate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.templates; 23 | 24 | import java.net.URI; 25 | 26 | class BaseTemplate { 27 | public String Name; 28 | public URI ScreenshotURL; 29 | } 30 | -------------------------------------------------------------------------------- /src/com/createsend/models/templates/TemplateDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.templates; 23 | 24 | import java.net.URI; 25 | 26 | public class TemplateDetails extends BaseTemplate { 27 | public String TemplateID; 28 | public URI PreviewURL; 29 | } 30 | -------------------------------------------------------------------------------- /src/com/createsend/models/templates/TemplateForCreate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.templates; 23 | 24 | import java.net.URI; 25 | 26 | public class TemplateForCreate extends BaseTemplate { 27 | public URI HtmlPageURL; 28 | public URI ZipFileURL; 29 | } 30 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/EmailContent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.List; 27 | 28 | public class EmailContent { 29 | 30 | @JsonProperty("Html") 31 | private String html; 32 | 33 | @JsonProperty("Text") 34 | private String text; 35 | 36 | @JsonProperty("EmailVariables") 37 | private List emailVariables; 38 | 39 | @JsonProperty("InlineCss") 40 | private boolean inlineCss; 41 | 42 | @JsonProperty("TrackOpens") 43 | private boolean trackOpens; 44 | 45 | @JsonProperty("TrackClicks") 46 | private boolean trackClicks; 47 | 48 | /** 49 | * @return the html body. 50 | */ 51 | public String getHtml() { 52 | return html; 53 | } 54 | 55 | /** 56 | * @return the text body. 57 | */ 58 | public String getText() { 59 | return text; 60 | } 61 | 62 | /** 63 | * @return the data merge variables. 64 | */ 65 | public List getEmailVariables() { 66 | return emailVariables; 67 | } 68 | 69 | /** 70 | * @return true if inline css, false otherwise. 71 | */ 72 | public boolean isInlineCss() { 73 | return inlineCss; 74 | } 75 | 76 | /** 77 | * @return true if track opens enabled, false otherwise. 78 | */ 79 | public boolean isTrackOpens() { 80 | return trackOpens; 81 | } 82 | 83 | /** 84 | * @return true if track clicks enabled, false otherwise. 85 | */ 86 | public boolean isTrackClicks() { 87 | return trackClicks; 88 | } 89 | 90 | /** 91 | * @param html html body content. 92 | */ 93 | public void setHtml(String html) { 94 | this.html = html; 95 | } 96 | 97 | /** 98 | * @param text text body content. 99 | */ 100 | public void setText(String text) { 101 | this.text = text; 102 | } 103 | 104 | /** 105 | * @param inlineCss enabled css inlining. 106 | */ 107 | public void setInlineCss(boolean inlineCss) { 108 | this.inlineCss = inlineCss; 109 | } 110 | 111 | /** 112 | * @param trackOpens enabled open tracking. 113 | */ 114 | public void setTrackOpens(boolean trackOpens) { 115 | this.trackOpens = trackOpens; 116 | } 117 | 118 | /** 119 | * @param trackClicks enable click tracking. 120 | */ 121 | public void setTrackClicks(boolean trackClicks) { 122 | this.trackClicks = trackClicks; 123 | } 124 | 125 | @Override 126 | public String toString() { 127 | return String.format("html\n: %s\n\n text\n: %s\n", html, text); 128 | } 129 | } -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/request/Attachment.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.request; 23 | 24 | import org.apache.commons.codec.binary.Base64; 25 | import org.apache.commons.io.IOUtils; 26 | 27 | import java.io.IOException; 28 | import java.io.InputStream; 29 | 30 | public class Attachment { 31 | 32 | /** 33 | * The original file name. 34 | */ 35 | public String Name; 36 | 37 | /** 38 | * The Mime type. For example: "image/png". 39 | */ 40 | public String Type; 41 | 42 | /** 43 | * Must be base64 encoded. 44 | */ 45 | public String Content; 46 | 47 | /** 48 | * Base64 encodes the input stream and stores the result as the Content. 49 | * @param inputStream 50 | * @throws IOException 51 | */ 52 | public void base64EncodeContentStream(InputStream inputStream) throws IOException { 53 | byte[] bytes = IOUtils.toByteArray(inputStream); 54 | byte[] bytesBase64 = Base64.encodeBase64(bytes); 55 | Content = new String(bytesBase64); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/ClassicEmailGroup.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.Date; 27 | 28 | public class ClassicEmailGroup { 29 | @JsonProperty("Group") 30 | private String group; 31 | 32 | @JsonProperty("CreatedAt") 33 | private Date createdAt; 34 | 35 | /** 36 | * @return the Group. 37 | */ 38 | public String getGroup() { 39 | return group; 40 | } 41 | 42 | /** 43 | * @return the Created At date. 44 | */ 45 | public Date getCreatedAt() { 46 | return createdAt; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return String.format("Group: %s, CreatedAt: %s", group, createdAt); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/GeoLocation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | public class GeoLocation { 27 | @JsonProperty("Latitude") 28 | private double latitude; 29 | 30 | @JsonProperty("Longitude") 31 | private double longitude; 32 | 33 | @JsonProperty("City") 34 | private String city; 35 | 36 | @JsonProperty("Region") 37 | private String region; 38 | 39 | @JsonProperty("CountryCode") 40 | private String countryCode; 41 | 42 | @JsonProperty("CountryName") 43 | private String countryName; 44 | 45 | /** 46 | * @return the latitude 47 | */ 48 | public double getLatitude() { 49 | return latitude; 50 | } 51 | 52 | /** 53 | * @return the longitude 54 | */ 55 | public double getLongitude() { 56 | return longitude; 57 | } 58 | 59 | /** 60 | * @return the city 61 | */ 62 | public String getCity() { 63 | return city; 64 | } 65 | 66 | /** 67 | * @return the region 68 | */ 69 | public String getRegion() { 70 | return region; 71 | } 72 | 73 | /** 74 | * @return the country code 75 | */ 76 | public String getCountryCode() { 77 | return countryCode; 78 | } 79 | 80 | /** 81 | * @return the country name 82 | */ 83 | public String getCountryName() { 84 | return countryName; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/MailClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | public class MailClient { 27 | 28 | @JsonProperty("Name") 29 | private String name; 30 | 31 | @JsonProperty("Version") 32 | private String version; 33 | 34 | /** 35 | * @return the name of the mail client 36 | */ 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | /** 42 | * @return the version of the mail client 43 | */ 44 | public String getVersion() { 45 | return version; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/MessageDetail.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.createsend.models.transactional.EmailContent; 25 | import com.createsend.models.transactional.request.Attachment; 26 | import com.fasterxml.jackson.annotation.JsonProperty; 27 | 28 | import java.util.List; 29 | import java.util.Map; 30 | 31 | public class MessageDetail { 32 | @JsonProperty("From") 33 | private String from; 34 | 35 | @JsonProperty("Subject") 36 | private String subject; 37 | 38 | @JsonProperty("To") 39 | private List to; 40 | 41 | @JsonProperty("CC") 42 | private List cc; 43 | 44 | @JsonProperty("BCC") 45 | private List bcc; 46 | 47 | @JsonProperty("ReplyTo") 48 | private String replyTo; 49 | 50 | @JsonProperty("Attachments") 51 | private List attachments; 52 | 53 | @JsonProperty("Body") 54 | private EmailContent body; 55 | 56 | @JsonProperty("Data") 57 | private Map data; 58 | 59 | /** 60 | * @return the From address. 61 | */ 62 | public String getFrom() { 63 | return from; 64 | } 65 | 66 | /** 67 | * @return the subject of the message. 68 | */ 69 | public String getSubject() { 70 | return subject; 71 | } 72 | 73 | /** 74 | * @return the list of To recipients. 75 | */ 76 | public List getTo() { 77 | return to; 78 | } 79 | 80 | /** 81 | * @return the list of Cc recipients. 82 | */ 83 | public List getCc() { 84 | return cc; 85 | } 86 | 87 | /** 88 | * @return the list of Bcc recipients. 89 | */ 90 | public List getBcc() { 91 | return bcc; 92 | } 93 | 94 | /** 95 | * @return the reply to address. 96 | */ 97 | public String getReplyTo() { 98 | return replyTo; 99 | } 100 | 101 | /** 102 | * @return the list of attachment meta data. 103 | * The base64 attachment content is not available from the CampaignMonitor API. 104 | */ 105 | public List getAttachments() { 106 | return attachments; 107 | } 108 | 109 | /** 110 | * @return the email body. 111 | */ 112 | public EmailContent getBody() { 113 | return body; 114 | } 115 | 116 | /** 117 | * @return the data merge variables. 118 | */ 119 | public Map getData() { 120 | return data; 121 | } 122 | 123 | @Override 124 | public String toString() { 125 | return String.format("Message. From: %s, Subject: %s", from, subject); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/MessageLogItem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.Date; 27 | import java.util.UUID; 28 | 29 | public class MessageLogItem { 30 | @JsonProperty("MessageID") 31 | private UUID messageID; 32 | 33 | @JsonProperty("Group") 34 | private String group; 35 | 36 | @JsonProperty("Status") 37 | private String status; 38 | 39 | @JsonProperty("SentAt") 40 | private Date sentAt; 41 | 42 | @JsonProperty("SmartEmailID") 43 | private UUID smartEmailId; 44 | 45 | @JsonProperty("CanBeResent") 46 | private boolean canBeResent; 47 | 48 | @JsonProperty("Recipient") 49 | private String recipient; 50 | 51 | @JsonProperty("From") 52 | private String from; 53 | 54 | @JsonProperty("Subject") 55 | private String subject; 56 | 57 | @JsonProperty("TotalOpens") 58 | private int totalOpens; 59 | 60 | @JsonProperty("TotalClicks") 61 | private int totalClicks; 62 | 63 | /** 64 | * @return the message id. 65 | */ 66 | public UUID getMessageID() { 67 | return messageID; 68 | } 69 | 70 | /** 71 | * @return the group. 72 | */ 73 | public String getGroup() { 74 | return group; 75 | } 76 | 77 | /** 78 | * @return the delivery status of the message. 79 | */ 80 | public String getStatus() { 81 | return status; 82 | } 83 | 84 | /** 85 | * @return the date sent. 86 | */ 87 | public Date getSentAt() { 88 | return sentAt; 89 | } 90 | 91 | /** 92 | * @return the smart email id. 93 | */ 94 | public UUID getSmartEmailId() { 95 | return smartEmailId; 96 | } 97 | 98 | /** 99 | * @return true if the message can be resent, false otherwise. 100 | */ 101 | public boolean isCanBeResent() { 102 | return canBeResent; 103 | } 104 | 105 | /** 106 | * @return the recipient of the message. 107 | */ 108 | public String getRecipient() { 109 | return recipient; 110 | } 111 | 112 | /** 113 | * @return the from address of the message. 114 | */ 115 | public String getFrom() { 116 | return from; 117 | } 118 | 119 | /** 120 | * @return the subject of the message. 121 | */ 122 | public String getSubject() { 123 | return subject; 124 | } 125 | 126 | /** 127 | * @return the total opens of the message. 128 | */ 129 | public int getTotalOpens() { 130 | return totalOpens; 131 | } 132 | 133 | /** 134 | * @return the total clicks of the message. 135 | */ 136 | public int getTotalClicks() { 137 | return totalClicks; 138 | } 139 | 140 | @Override 141 | public String toString() { 142 | return String.format("MessageID: %s, Group: %s, SentAt: %s, Status: %s, Recipient: %s", messageID, group, sentAt, status, recipient); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/MessageSent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.UUID; 27 | 28 | public class MessageSent { 29 | @JsonProperty("MessageID") 30 | private UUID messageID; 31 | 32 | @JsonProperty("Status") 33 | private String status; 34 | 35 | @JsonProperty("Recipient") 36 | private String recipient; 37 | 38 | /** 39 | * @return the message id. 40 | */ 41 | public UUID getMessageID() { 42 | return messageID; 43 | } 44 | 45 | /** 46 | * @return the message delivery status. 47 | */ 48 | public String getStatus() { 49 | return status; 50 | } 51 | 52 | /** 53 | * @return the recipient of the message. 54 | */ 55 | public String getRecipient() { 56 | return recipient; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return String.format("MessageID: %s, Status: %s, Recipient: %s", messageID, status, recipient); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/SmartEmailDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.Date; 27 | import java.util.UUID; 28 | 29 | public class SmartEmailDetails { 30 | @JsonProperty("SmartEmailID") 31 | private UUID smartEmailID; 32 | 33 | @JsonProperty("CreatedAt") 34 | private Date createdAt; 35 | 36 | @JsonProperty("Status") 37 | private String status; 38 | 39 | @JsonProperty("Name") 40 | private String name; 41 | 42 | @JsonProperty("Properties") 43 | private SmartEmailProperties properties; 44 | 45 | @JsonProperty("AddRecipientsToList") 46 | private String addRecipientsToList; 47 | 48 | /** 49 | * @return the smart email id. 50 | */ 51 | public UUID getSmartEmailID() { 52 | return smartEmailID; 53 | } 54 | 55 | /** 56 | * @return the created at date. 57 | */ 58 | public Date getCreatedAt() { 59 | return createdAt; 60 | } 61 | 62 | /** 63 | * @return the status of the smart email. 64 | */ 65 | public String getStatus() { 66 | return status; 67 | } 68 | 69 | /** 70 | * @return the name of the smart email. 71 | */ 72 | public String getName() { 73 | return name; 74 | } 75 | 76 | /** 77 | * @return smart email properties. 78 | */ 79 | public SmartEmailProperties getProperties() { 80 | return properties; 81 | } 82 | 83 | /** 84 | * @return the list id recipients are added to. 85 | */ 86 | public String getAddRecipientsToList() { 87 | return addRecipientsToList; 88 | } 89 | 90 | @Override 91 | public String toString() { 92 | return String.format("ID: %s, Status: %s, Name: %s, Properties:\n%s", getSmartEmailID(), getStatus(), getName(), getProperties()); 93 | } 94 | } -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/SmartEmailItem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.Date; 27 | import java.util.UUID; 28 | 29 | public class SmartEmailItem { 30 | @JsonProperty("ID") 31 | private UUID id; 32 | 33 | @JsonProperty("Name") 34 | private String name; 35 | 36 | @JsonProperty("CreatedAt") 37 | private Date createdAt; 38 | 39 | @JsonProperty("Status") 40 | private SmartEmailStatus status; 41 | 42 | /** 43 | * @return the smart email id. 44 | */ 45 | public UUID getId() { 46 | return id; 47 | } 48 | 49 | /** 50 | * @return the smart email name. 51 | */ 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | /** 57 | * @return the created at date. 58 | */ 59 | public Date getCreatedAt() { 60 | return createdAt; 61 | } 62 | 63 | /** 64 | * @return the status of the smart email. 65 | */ 66 | public SmartEmailStatus getStatus() { 67 | return status; 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | return String.format("ID: %s, Name: %s, Status: %s, CreatedAt: %s", id, name, status, createdAt); 73 | } 74 | } -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/SmartEmailProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.createsend.models.transactional.EmailContent; 25 | import com.fasterxml.jackson.annotation.JsonProperty; 26 | 27 | public class SmartEmailProperties { 28 | 29 | @JsonProperty("From") 30 | private String from; 31 | 32 | @JsonProperty("ReplyTo") 33 | private String replyTo; 34 | 35 | @JsonProperty("Subject") 36 | private String subject; 37 | 38 | @JsonProperty("TextPreviewUrl") 39 | private String textPreviewUrl; 40 | 41 | @JsonProperty("HtmlPreviewUrl") 42 | private String htmlPreviewUrl; 43 | 44 | @JsonProperty("Content") 45 | private EmailContent content; 46 | 47 | /** 48 | * @return the from address of the smart email. 49 | */ 50 | public String getFrom() { 51 | return from; 52 | } 53 | 54 | /** 55 | * @return the replyTo address of the smart email. 56 | */ 57 | public String getReplyTo() { 58 | return replyTo; 59 | } 60 | 61 | /** 62 | * @return the subject of the smart email. 63 | */ 64 | public String getSubject() { 65 | return subject; 66 | } 67 | 68 | /** 69 | * @return the text preview url. 70 | */ 71 | public String getTextPreviewUrl() { 72 | return textPreviewUrl; 73 | } 74 | 75 | /** 76 | * @return the html preview url. 77 | */ 78 | public String getHtmlPreviewUrl() { 79 | return htmlPreviewUrl; 80 | } 81 | 82 | /** 83 | * @return the content of the smart email. 84 | * The Campaign Monitor API does not support returning smart email content. 85 | */ 86 | public EmailContent getContent() { 87 | return content; 88 | } 89 | 90 | @Override 91 | public String toString() { 92 | return String.format("From: %s, Subject: %s, Content:\n%s", from, subject, content); 93 | } 94 | } -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/SmartEmailStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonCreator; 25 | import com.fasterxml.jackson.annotation.JsonValue; 26 | 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | /** 31 | * The valid states of a Smart Email. 32 | */ 33 | public enum SmartEmailStatus { 34 | 35 | ALL, 36 | ACTIVE, 37 | DRAFT; 38 | 39 | private static Map values = new HashMap<>(); 40 | private static Map names = new HashMap<>(); 41 | private static void property(String value, SmartEmailStatus status) { 42 | names.put(value, status); 43 | values.put(status, value); 44 | } 45 | 46 | static { 47 | property("all", ALL); 48 | property("active", ACTIVE); 49 | property("draft", DRAFT); 50 | } 51 | 52 | @JsonCreator 53 | public static SmartEmailStatus forValue(String value) { 54 | return names.get(value.toLowerCase()); 55 | } 56 | 57 | @JsonValue 58 | public String toValue() { 59 | return values.get(this); 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return toValue(); 65 | } 66 | } -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/TransactionalClick.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.Date; 27 | 28 | public class TransactionalClick { 29 | @JsonProperty("EmailAddress") 30 | private String emailAddress; 31 | 32 | @JsonProperty("Date") 33 | private Date date; 34 | 35 | @JsonProperty("IPAddress") 36 | private String ipAddress; 37 | 38 | @JsonProperty("Geolocation") 39 | private GeoLocation geoLocation; 40 | 41 | @JsonProperty("Url") 42 | private String url; 43 | 44 | /** 45 | * @return the recipient address of the event. 46 | */ 47 | public String getEmailAddress() { 48 | return emailAddress; 49 | } 50 | 51 | /** 52 | * @return the date of the event. 53 | */ 54 | public Date getDate() { 55 | return date; 56 | } 57 | 58 | /** 59 | * @return the IP Address the event originated at. 60 | */ 61 | public String getIpAddress() { 62 | return ipAddress; 63 | } 64 | 65 | /** 66 | * @return the location the event originated at. 67 | */ 68 | public GeoLocation getGeoLocation() { 69 | return geoLocation; 70 | } 71 | 72 | /** 73 | * @return the url that was clicked. 74 | */ 75 | public String getUrl() { 76 | return url; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/TransactionalOpen.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.Date; 27 | 28 | public class TransactionalOpen { 29 | @JsonProperty("EmailAddress") 30 | private String emailAddress; 31 | 32 | @JsonProperty("Date") 33 | private Date date; 34 | 35 | @JsonProperty("IPAddress") 36 | private String ipAddress; 37 | 38 | @JsonProperty("Geolocation") 39 | private GeoLocation geoLocation; 40 | 41 | @JsonProperty("MailClient") 42 | private MailClient mailClient; 43 | 44 | /** 45 | * @return the recipient address of the event. 46 | */ 47 | public String getEmailAddress() { 48 | return emailAddress; 49 | } 50 | 51 | /** 52 | * @return the date of the event. 53 | */ 54 | public Date getDate() { 55 | return date; 56 | } 57 | 58 | /** 59 | * @return the IP Address the event originated at. 60 | */ 61 | public String getIpAddress() { 62 | return ipAddress; 63 | } 64 | 65 | /** 66 | * @return the location the event originated at. 67 | */ 68 | public GeoLocation getGeoLocation() { 69 | return geoLocation; 70 | } 71 | 72 | /** 73 | * @return the mail client used to open the message. 74 | */ 75 | public MailClient getMailClient() { 76 | return mailClient; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/TransactionalStatistics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | public class TransactionalStatistics { 27 | @JsonProperty("Sent") 28 | private int sent; 29 | 30 | @JsonProperty("Bounces") 31 | private int bounces; 32 | 33 | @JsonProperty("Delivered") 34 | private int delivered; 35 | 36 | @JsonProperty("Opened") 37 | private int opened; 38 | 39 | @JsonProperty("Clicked") 40 | private int clicked; 41 | 42 | @JsonProperty("Query") 43 | private TransactionalStatisticsQuery query; 44 | 45 | /** 46 | * @return the total sent. 47 | */ 48 | public int getSent() { 49 | return sent; 50 | } 51 | 52 | /** 53 | * @return the total bounced. 54 | */ 55 | public int getBounces() { 56 | return bounces; 57 | } 58 | 59 | /** 60 | * @return the total delivered. 61 | */ 62 | public int getDelivered() { 63 | return delivered; 64 | } 65 | 66 | /** 67 | * @return the total opened. 68 | */ 69 | public int getOpened() { 70 | return opened; 71 | } 72 | 73 | /** 74 | * @return the total clicked. 75 | */ 76 | public int getClicked() { 77 | return clicked; 78 | } 79 | 80 | /** 81 | * @return details about the message. 82 | */ 83 | public TransactionalStatisticsQuery getQuery() { 84 | return query; 85 | } 86 | 87 | @Override 88 | public String toString() { 89 | return String.format("Sent: %s, Bounces: %s, Delivered: %s, Opened: %s, Clicked: %s", sent, bounces, delivered, opened, clicked); 90 | } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/com/createsend/models/transactional/response/TransactionalStatisticsQuery.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015 Richard Bremner 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.models.transactional.response; 23 | 24 | import com.fasterxml.jackson.annotation.JsonProperty; 25 | 26 | import java.util.UUID; 27 | 28 | public class TransactionalStatisticsQuery { 29 | @JsonProperty("Group") 30 | private String group; 31 | 32 | @JsonProperty("SmartEmailID") 33 | private UUID smartEmailID; 34 | 35 | @JsonProperty("From") 36 | private String from; 37 | 38 | @JsonProperty("To") 39 | private String to; 40 | 41 | @JsonProperty("TimeZone") 42 | private String timeZone; 43 | 44 | /** 45 | * @return the group. 46 | */ 47 | public String getGroup() { 48 | return group; 49 | } 50 | 51 | /** 52 | * @return the smart email id. 53 | */ 54 | public UUID getSmartEmailID() { 55 | return smartEmailID; 56 | } 57 | 58 | /** 59 | * @return the from address of the message. 60 | */ 61 | public String getFrom() { 62 | return from; 63 | } 64 | 65 | /** 66 | * @return the to address of the message. 67 | */ 68 | public String getTo() { 69 | return to; 70 | } 71 | 72 | /** 73 | * @return the timezone. 74 | */ 75 | public String getTimeZone() { 76 | return timeZone; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/com/createsend/util/ApiKeyAuthenticationDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util; 23 | 24 | /** 25 | * Represents the authentication details to use when authenticating with the 26 | * Campaign Monitor API using an API key. 27 | * @author jdennes 28 | */ 29 | public class ApiKeyAuthenticationDetails extends AuthenticationDetails { 30 | private String apiKey; 31 | 32 | public ApiKeyAuthenticationDetails(String apiKey) { 33 | this.apiKey = apiKey; 34 | } 35 | 36 | public String getApiKey() { 37 | return apiKey; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/createsend/util/AuthenticationDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util; 23 | 24 | /** 25 | * Abstract class to represent the authentication details to use for 26 | * authenticating with the Campaign Monitor API. 27 | * @author jdennes 28 | */ 29 | public abstract class AuthenticationDetails { } 30 | -------------------------------------------------------------------------------- /src/com/createsend/util/Configuration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util; 23 | 24 | import java.io.FileNotFoundException; 25 | import java.io.IOException; 26 | import java.io.InputStream; 27 | import java.util.Properties; 28 | 29 | public class Configuration { 30 | public static Configuration Current = new Configuration(); 31 | 32 | private Properties properties; 33 | private Configuration() { 34 | properties = new Properties(); 35 | 36 | try { 37 | InputStream configProperties = getClass().getClassLoader().getResourceAsStream("com/createsend/util/config.properties"); 38 | if (configProperties == null) { 39 | throw new FileNotFoundException("Could not find config.properties"); 40 | } 41 | properties.load(configProperties); 42 | 43 | InputStream createsendProperties = getClass().getClassLoader().getResourceAsStream("createsend.properties"); 44 | if(createsendProperties != null) { 45 | properties.load(createsendProperties); 46 | } 47 | } catch (IOException e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | 52 | public void addPropertiesFile(String filename) throws IOException { 53 | properties.load(ClassLoader.getSystemResourceAsStream(filename)); 54 | } 55 | 56 | public String getApiEndpoint() { 57 | return properties.getProperty("createsend.endpoint"); 58 | } 59 | 60 | public String getOAuthBaseUri() { 61 | return properties.getProperty("createsend.oauthbaseuri"); 62 | } 63 | 64 | public String getWrapperVersion() { 65 | return properties.getProperty("createsend.version"); 66 | } 67 | 68 | public boolean isLoggingEnabled() { 69 | return Boolean.parseBoolean(properties.getProperty("createsend.logging")); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/com/createsend/util/ErrorDeserialiser.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util; 23 | 24 | import com.createsend.models.ApiErrorResponse; 25 | import com.sun.jersey.api.client.ClientResponse; 26 | import com.sun.jersey.api.client.GenericType; 27 | 28 | import java.lang.reflect.Field; 29 | import java.lang.reflect.ParameterizedType; 30 | import java.lang.reflect.Type; 31 | 32 | public class ErrorDeserialiser { 33 | 34 | public ApiErrorResponse getResponse(ClientResponse response) { 35 | ParameterizedType returnType = JerseyClientImpl.getGenericReturnType(this.getClass(), 2); 36 | Type genericType = this.getClass().getGenericSuperclass(); 37 | if (genericType instanceof ParameterizedType) { 38 | try { 39 | Field f = returnType.getClass().getDeclaredField("actualTypeArguments"); 40 | f.setAccessible(true); 41 | f.set(returnType, ((ParameterizedType)genericType).getActualTypeArguments()); 42 | f.setAccessible(false); 43 | } catch (NoSuchFieldException e) { 44 | // ok to ignore 45 | } catch (IllegalAccessException e) { 46 | // ok to ignore 47 | } 48 | } 49 | return response.getEntity(new GenericType>(returnType)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/com/createsend/util/OAuthAuthenticationDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util; 23 | 24 | /** 25 | * Represents the authentication details to use when authenticating with the 26 | * Campaign Monitor API using OAuth. 27 | * @author jdennes 28 | */ 29 | public class OAuthAuthenticationDetails extends AuthenticationDetails { 30 | private String accessToken; 31 | private String refreshToken; 32 | 33 | public OAuthAuthenticationDetails(String accessToken, String refreshToken) { 34 | this.accessToken = accessToken; 35 | this.refreshToken = refreshToken; 36 | } 37 | 38 | public String getAccessToken() { 39 | return accessToken; 40 | } 41 | 42 | public String getRefreshToken() { 43 | return refreshToken; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/com/createsend/util/config.properties: -------------------------------------------------------------------------------- 1 | createsend.version = 7.0.1 2 | createsend.endpoint = https://api.createsend.com/api/v3.3/ 3 | createsend.oauthbaseuri = https://api.createsend.com/oauth/ 4 | createsend.logging = false 5 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | /** 25 | * An exception raised when the Campaign Monitor API responds with a 400 Bad Request 26 | */ 27 | public class BadRequestException extends CreateSendHttpException { 28 | private static final long serialVersionUID = -2724621705342365927L; 29 | 30 | private Object resultData; 31 | 32 | public BadRequestException(int apiErrorCode, String apiErrorMessage, Object resultData) { 33 | super( 34 | String.format("The CreateSend API responded with the following client error %d: %s.%s", 35 | apiErrorCode, apiErrorMessage, 36 | resultData != null ? " Check resultData for more details" : ""), 37 | 400, 38 | apiErrorCode, 39 | apiErrorMessage); 40 | 41 | this.resultData = resultData; 42 | } 43 | 44 | public Object getResultData() { 45 | return resultData; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/CreateSendException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | /** 25 | * A base exception for the Java wrapper 26 | */ 27 | public class CreateSendException extends Exception { 28 | private static final long serialVersionUID = 1695317869199799783L; 29 | 30 | public CreateSendException(String message) { 31 | super(message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/CreateSendHttpException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | import com.sun.jersey.api.client.ClientResponse; 25 | import com.sun.jersey.api.client.ClientResponse.Status; 26 | 27 | /** 28 | * An exception raised on any HTTP based error. i.e Status code >= 400 29 | */ 30 | public class CreateSendHttpException extends CreateSendException { 31 | private static final long serialVersionUID = 6026680795882633621L; 32 | 33 | private int httpStatusCode; 34 | private int apiErrorCode; 35 | private String apiErrorMessage; 36 | 37 | public CreateSendHttpException(int httpStatusCode) { 38 | super("The API call failed due to an unexpected HTTP error: " + httpStatusCode); 39 | this.httpStatusCode = httpStatusCode; 40 | this.apiErrorMessage = ""; 41 | } 42 | 43 | public CreateSendHttpException(String message, int httpStatusCode) { 44 | super(message); 45 | this.httpStatusCode = httpStatusCode; 46 | this.apiErrorMessage = apiErrorMessage; 47 | } 48 | 49 | public CreateSendHttpException(String message, int httpStatusCode, int apiErrorCode, String apiErrorMessage) { 50 | super(message); 51 | 52 | this.httpStatusCode = httpStatusCode; 53 | this.apiErrorCode = apiErrorCode; 54 | this.apiErrorMessage = apiErrorMessage; 55 | } 56 | 57 | /** 58 | * @return The HTTP Status code as an integer from the failed request 59 | */ 60 | public int getStatusCode() { 61 | return httpStatusCode; 62 | } 63 | 64 | /** 65 | * This method will only interpret well know HTTP Status Codes. Status codes such as 429 may 66 | * not be correctly interpreted, in which case you can use {@link #getStatusCode} 67 | * 68 | * @return The HTTP Status code from the failed request 69 | */ 70 | public Status getHttpStatusCode() { 71 | return Status.fromStatusCode(httpStatusCode); 72 | } 73 | 74 | /** 75 | * @return The API Error message from the failed request. 76 | */ 77 | public String getApiErrorMessage() { 78 | return apiErrorMessage; 79 | } 80 | 81 | /** 82 | * @return The API Error Code from the failed request. 83 | */ 84 | public int getApiErrorCode() { 85 | return apiErrorCode; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/ExpiredOAuthTokenException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | public class ExpiredOAuthTokenException extends UnauthorisedException { 25 | private static final long serialVersionUID = 6082738273827262638L; 26 | 27 | public ExpiredOAuthTokenException(int apiErrorCode, String apiErrorMessage) { 28 | super(apiErrorCode, apiErrorMessage); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | /** 25 | * An exception raised when the API responds with a 404 Not Found 26 | */ 27 | public class NotFoundException extends CreateSendHttpException { 28 | private static final long serialVersionUID = -7730164870627844838L; 29 | 30 | public NotFoundException(int apiErrorCode, String apiErrorMessage) { 31 | super("The requested resource does not exist", 404, apiErrorCode, apiErrorMessage); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/RateLimitingException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | /** 25 | * An exception raised when the Campaign Monitor API responds with a 429 Too Many Requests 26 | */ 27 | public class RateLimitingException extends CreateSendHttpException { 28 | private static final long serialVersionUID = -2724621705342365927L; 29 | 30 | public RateLimitingException(int apiErrorCode, String message) { 31 | super( 32 | String.format( 33 | "The CreateSend API responded indicating that rate limiting occured%s", 34 | message == null ? "" : ": " + message), 35 | apiErrorCode, 36 | apiErrorCode, 37 | message == null ? "" : message); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/ServerErrorException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | /** 25 | * An exception raised when the API responds with a 500 Server Error 26 | */ 27 | public class ServerErrorException extends CreateSendHttpException { 28 | private static final long serialVersionUID = 7077800306811546975L; 29 | 30 | public ServerErrorException(int apiErrorCode, String apiErrorMessage) { 31 | super("The API call resulted in an internal server error", 500, apiErrorCode, apiErrorMessage); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/createsend/util/exceptions/UnauthorisedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.exceptions; 23 | 24 | /** 25 | * An exception raised when the API responds with a 401 Unauthorized 26 | */ 27 | public class UnauthorisedException extends CreateSendHttpException { 28 | private static final long serialVersionUID = 4596052166026262638L; 29 | 30 | public UnauthorisedException(int apiErrorCode, String apiErrorMessage) { 31 | super( 32 | String.format("The CreateSend API responded with the following authentication error %d: %s", 33 | apiErrorCode, apiErrorMessage), 34 | 401, 35 | apiErrorCode, 36 | apiErrorMessage); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/createsend/util/jersey/AuthorisedResourceFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.jersey; 23 | 24 | import com.sun.jersey.api.client.Client; 25 | import com.sun.jersey.api.client.WebResource; 26 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; 27 | 28 | public class AuthorisedResourceFactory extends ResourceFactory { 29 | private HTTPBasicAuthFilter apiKeyFilter; 30 | private OAuth2BearerTokenFilter oauthTokenFilter; 31 | 32 | public AuthorisedResourceFactory(String accessToken) { 33 | oauthTokenFilter = new OAuth2BearerTokenFilter(accessToken); 34 | } 35 | 36 | public AuthorisedResourceFactory(String username, String password) { 37 | apiKeyFilter = new HTTPBasicAuthFilter(username, password); 38 | } 39 | 40 | @Override 41 | public WebResource getResource(Client client, String... pathElements) { 42 | WebResource resource = super.getResource(client, pathElements); 43 | if (apiKeyFilter != null) 44 | resource.addFilter(apiKeyFilter); 45 | if (oauthTokenFilter != null) 46 | resource.addFilter(oauthTokenFilter); 47 | return resource; 48 | } 49 | } -------------------------------------------------------------------------------- /src/com/createsend/util/jersey/JsonProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.jersey; 23 | 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.io.OutputStream; 27 | import java.lang.annotation.Annotation; 28 | import java.lang.reflect.Type; 29 | import java.text.DateFormat; 30 | import java.text.ParsePosition; 31 | import java.text.SimpleDateFormat; 32 | import java.util.Date; 33 | 34 | import javax.ws.rs.core.MediaType; 35 | import javax.ws.rs.core.MultivaluedMap; 36 | 37 | import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; 38 | import com.fasterxml.jackson.databind.DeserializationFeature; 39 | import com.fasterxml.jackson.databind.ObjectMapper; 40 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 41 | 42 | /** 43 | * An extension of the Jersey JacksonJsonProvider used to set Jackson 44 | * serialisation/deserialisation properties 45 | */ 46 | public class JsonProvider extends JacksonJsonProvider { 47 | 48 | public static final DateFormat ApiDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm") { 49 | final SimpleDateFormat ApiDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 50 | final SimpleDateFormat ApiDateFormatTz = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); 51 | 52 | @Override 53 | public Date parse(String source, ParsePosition pos) { 54 | if (source.length() - pos.getIndex() == ApiDateFormat.toPattern().length()) 55 | return ApiDateFormat.parse(source, pos); 56 | return ApiDateFormatTz.parse(source, pos); 57 | } 58 | }; 59 | 60 | @Override 61 | public void writeTo(Object value, Class type, Type genericType, 62 | Annotation[] annotations, MediaType mediaType, 63 | MultivaluedMap httpHeaders, 64 | OutputStream entityStream) throws IOException { 65 | ObjectMapper mapper = locateMapper(type, mediaType); 66 | mapper.setSerializationInclusion(Include.NON_NULL); 67 | 68 | super.writeTo(value, type, genericType, annotations, mediaType, httpHeaders, 69 | entityStream); 70 | } 71 | 72 | @Override 73 | public Object readFrom(Class type, Type genericType, 74 | Annotation[] annotations, MediaType mediaType, 75 | MultivaluedMap httpHeaders, InputStream entityStream) 76 | throws IOException { 77 | ObjectMapper mapper = locateMapper(type, mediaType); 78 | mapper.setDateFormat(ApiDateFormat); 79 | mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); 80 | 81 | return super.readFrom(type, genericType, annotations, mediaType, httpHeaders, 82 | entityStream); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/com/createsend/util/jersey/OAuth2BearerTokenFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.jersey; 23 | 24 | import com.sun.jersey.api.client.filter.ClientFilter; 25 | import com.sun.jersey.api.client.ClientHandlerException; 26 | import com.sun.jersey.api.client.ClientRequest; 27 | import com.sun.jersey.api.client.ClientResponse; 28 | import javax.ws.rs.core.HttpHeaders; 29 | 30 | /** 31 | * Client filter adding Authorization header containing OAuth2 bearer token 32 | * to the HTTP request, if no such header is already present 33 | */ 34 | public final class OAuth2BearerTokenFilter extends ClientFilter { 35 | 36 | private final String authentication; 37 | 38 | /** 39 | * Creates a new OAuth2 bearer token filter using provided access token. 40 | * 41 | * @param accessToken The OAuth2 access token to be used in the HTTP request. 42 | */ 43 | public OAuth2BearerTokenFilter(final String accessToken) { 44 | authentication = "Bearer " + accessToken; 45 | } 46 | 47 | @Override 48 | public ClientResponse handle(final ClientRequest cr) throws ClientHandlerException { 49 | 50 | if (!cr.getHeaders().containsKey(HttpHeaders.AUTHORIZATION)) { 51 | cr.getHeaders().add(HttpHeaders.AUTHORIZATION, authentication); 52 | } 53 | return getNext().handle(cr); 54 | } 55 | } -------------------------------------------------------------------------------- /src/com/createsend/util/jersey/ResourceFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.jersey; 23 | 24 | import com.createsend.util.Configuration; 25 | import com.sun.jersey.api.client.Client; 26 | import com.sun.jersey.api.client.WebResource; 27 | import com.sun.jersey.api.client.config.ClientConfig; 28 | 29 | public abstract class ResourceFactory { 30 | 31 | public WebResource getResource(Client client, String... pathElements) { 32 | return getResource(Configuration.Current.getApiEndpoint(), 33 | client, pathElements); 34 | } 35 | 36 | public WebResource getResource(String baseUri, Client client, String... pathElements) { 37 | WebResource resource = client.resource(baseUri); 38 | resource.setProperty(ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE, 64 * 1024); 39 | resource.setProperty(com.sun.jersey.api.json.JSONConfiguration.FEATURE_POJO_MAPPING, "true"); 40 | 41 | for (String pathElement : pathElements) { 42 | resource = resource.path(pathElement); 43 | } 44 | 45 | return resource; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/createsend/util/jersey/UnauthorisedResourceFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013 James Dennes 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.jersey; 23 | 24 | public class UnauthorisedResourceFactory extends ResourceFactory {} 25 | -------------------------------------------------------------------------------- /src/com/createsend/util/jersey/UserAgentFilter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011 Toby Brain 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | package com.createsend.util.jersey; 23 | 24 | import com.createsend.util.Configuration; 25 | import com.sun.jersey.api.client.ClientHandlerException; 26 | import com.sun.jersey.api.client.ClientRequest; 27 | import com.sun.jersey.api.client.ClientResponse; 28 | import com.sun.jersey.api.client.filter.ClientFilter; 29 | 30 | /** 31 | * A ClientFilter to set the Java wrappers User-Agent 32 | */ 33 | public class UserAgentFilter extends ClientFilter { 34 | 35 | private static String userAgent; 36 | 37 | static { 38 | userAgent = String.format( 39 | "createsend-java v%s. %s v%s. %s v%s", 40 | Configuration.Current.getWrapperVersion(), 41 | System.getProperty("java.runtime.name", "Unknown runtime"), 42 | System.getProperty("java.runtime.version", "Unknown version"), 43 | System.getProperty("os.name", "Unknown OS"), 44 | System.getProperty("os.version", "Unknown version")); 45 | 46 | } 47 | 48 | @Override 49 | public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { 50 | cr.getHeaders().add("User-Agent", userAgent); 51 | return getNext().handle(cr); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /update-javadoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## Generates and updates javadoc for createsend-java, hosted at: 4 | ## http://campaignmonitor.github.com/createsend-java/doc/ 5 | 6 | BUILD_DOC=build/doc 7 | BUILD_PAGES=build/gh-pages 8 | 9 | set -e 10 | 11 | rm -rf $BUILD_DOC $BUILD_PAGES 12 | git clone git@github.com:campaignmonitor/createsend-java.git $BUILD_PAGES -b gh-pages 13 | gradle doc 14 | VERSION=$(basename $BUILD_DOC/*) 15 | rsync -f 'exclude .git' -r --delete $BUILD_DOC/$VERSION/ $BUILD_PAGES/doc 16 | cd $BUILD_PAGES 17 | git add doc 18 | git commit -m "Generated javadoc for $VERSION" --allow-empty 19 | git push origin gh-pages 20 | cd ../.. 21 | rm -rf $BUILD_DOC $BUILD_PAGES 22 | --------------------------------------------------------------------------------