Java and Android library for accessing the Constant Contact API. Based on the Retrofit framework.
You'll need an API key and access token to use the SDK. Do so by creating a developer account here, then register an app to generate an API key and access token for an account.
Then, start by creating the CCApi2
object, and make the call you need through the appropriate service. Learn more about signing up
for a developer account here.
All of the calls respond with Retrofit Call
objects, which can be consumed synchronously (execute
) or
asynchronously (enqueue
). Full documentation of the Call
class can be found here.
Each service is fully documented in the Javadoc with full explanations of each parameter.
CCApi2 api = new CCApi2("your_api_key", "your_access_token");
try {
AccountSummaryInformation accountSummary = api.getAccountService()
.getAccountSummaryInformation()
.execute()
.body();
} catch (IOException e) {
// Handle exception
}
CCApi2 api = new CCApi2("your_api_key", "your_access_token");
Callback<Paged<Contact>> callback = new Callback<Paged<Contact>>() {
@Override
public void onResponse(Response<Paged<Contact>> response) {
List<Contact> contacts = response.body().getResults();
}
@Override
public void onFailure(Throwable t) {
}
}
api.getContactService().getContacts(50, ContactStatus.ACTIVE).enqueue(callback);
The JAR is available on JCenter, or you can download manually from the releases page. Note, if you download manually, you will also need to download the Components JAR and include it in your build file.
The base library is the java-sdk
artifact. If you use RxJava there are two artifacts available depending on the version:
java-sdk-rx
for RxJava 1 users and java-sdk-rx2
for RxJava 2 users (all calls return Observable
).
compile 'com.constantcontact:java-sdk:5.1.8'
allprojects {
repositories {
maven("https://oss.jfrog.org/artifactory/oss-snapshot-local/")
}
}
compile 'com.constantcontact:java-sdk:X.X.X-SNAPSHOT'
<dependencies>
<dependency>
<groupId>com.constantcontact</groupId>
<artifactId>java-sdk</artifactId>
<version>5.1.8</version>
</dependency>
</dependencies>
Copyright (c) 2016, Constant Contact, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.