This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from constantcontact/refactor-and-fix
Refactor and fix
- Loading branch information
Showing
101 changed files
with
552 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
components/src/main/java/com/constantcontact/v2/DefaultOkHttpClientBuilderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.constantcontact.v2; | ||
|
||
import okhttp3.OkHttpClient; | ||
import okhttp3.logging.HttpLoggingInterceptor; | ||
|
||
import javax.inject.Inject; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
*/ | ||
public class DefaultOkHttpClientBuilderFactory { | ||
|
||
@Inject | ||
public DefaultOkHttpClientBuilderFactory() { | ||
} | ||
|
||
public OkHttpClient.Builder create(String apiKey, String token) { | ||
return create(apiKey, token, HttpLoggingInterceptor.Level.NONE); | ||
} | ||
|
||
public OkHttpClient.Builder create(String apiKey, String token, HttpLoggingInterceptor.Level loggingLevel) { | ||
OkHttpClient.Builder | ||
builder = | ||
new OkHttpClient().newBuilder() | ||
.readTimeout(10, TimeUnit.SECONDS) | ||
.connectTimeout(5, TimeUnit.SECONDS) | ||
.addInterceptor(new CCApiInterceptor(apiKey, token)); | ||
|
||
if (loggingLevel != HttpLoggingInterceptor.Level.NONE) { | ||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); | ||
interceptor.setLevel(loggingLevel); | ||
builder.addInterceptor(interceptor); | ||
} | ||
|
||
return builder; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
components/src/main/java/com/constantcontact/v2/DefaultRetrofitBuilderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.constantcontact.v2; | ||
|
||
import com.constantcontact.v2.converter.jackson.JacksonConverterFactory; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import okhttp3.OkHttpClient; | ||
import retrofit2.Retrofit; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
/** | ||
* A factory for creating the default {@link Retrofit.Builder}. | ||
* <p> | ||
* NOTE: Can be used with dependency injection since the constructor | ||
* is marked with {@code @Inject}, and requires a {@link OkHttpClient} dependency named "ccapi2". If you aren't using DI | ||
* then the annotations will not affect you. | ||
*/ | ||
public class DefaultRetrofitBuilderFactory { | ||
public static final String BASE_URL = "https://api.constantcontact.com/"; | ||
|
||
private final OkHttpClient _okHttpClient; | ||
|
||
/** | ||
* Creates an instance of the factory. | ||
* | ||
* @param client the client used to initialize the created builder | ||
*/ | ||
@Inject | ||
public DefaultRetrofitBuilderFactory(@Named("ccapi2") OkHttpClient client) { | ||
_okHttpClient = client; | ||
} | ||
|
||
/** | ||
* Creates a new builder instance with the default base url. Initialized with a default Jackson JSON converter. | ||
* | ||
* @return a builder instance initialized for use with service classes | ||
*/ | ||
public Retrofit.Builder create() { | ||
return create(BASE_URL); | ||
} | ||
|
||
/** | ||
* Creates a new builder instance with the provided base url. Initialized with a default Jackson JSON converter. | ||
* | ||
* @param baseUrl the base url | ||
* @return a builder instance initialized for use with service classes | ||
*/ | ||
public Retrofit.Builder create(String baseUrl) { | ||
return create(baseUrl, new ObjectMapper()); | ||
} | ||
|
||
/** | ||
* Creates a new builder instance with the provided base url. Initialized with a Jackson JSON converter using the | ||
* provided object mapper. | ||
* | ||
* @param baseUrl the base url | ||
* @param objectMapper the object mapper | ||
* @return a builder instance initialized for use with service classes | ||
*/ | ||
public Retrofit.Builder create(String baseUrl, ObjectMapper objectMapper) { | ||
return new Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.client(_okHttpClient) | ||
.addConverterFactory(JacksonConverterFactory.create(objectMapper)); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
components/src/main/java/com/constantcontact/v2/QueryDate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.constantcontact.v2; | ||
|
||
import java.util.Date; | ||
|
||
import static com.constantcontact.v2.converter.jackson.JacksonConverterFactory.ISO_8601_DATE_FORMAT; | ||
|
||
/** | ||
* A date wrapper to Constant Contact API specific ISO-8601 date format for query parameters. | ||
*/ | ||
public class QueryDate { | ||
private final Date date; | ||
|
||
public QueryDate() { | ||
date = new Date(); | ||
} | ||
|
||
public QueryDate(long dateInMilliseconds) { | ||
date = new Date(dateInMilliseconds); | ||
} | ||
|
||
public QueryDate(Date date) { | ||
this.date = date; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ISO_8601_DATE_FORMAT.format(date); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
components/src/main/java/com/constantcontact/v2/account/AccountEmailAddressStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
components/src/main/java/com/constantcontact/v2/campaigns/EmailFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.constantcontact.v2.campaigns; | ||
|
||
/** | ||
* @author woogienoogie | ||
*/ | ||
public enum EmailFormat { | ||
HTML, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
components/src/main/java/com/constantcontact/v2/contacts/AddressType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.constantcontact.v2.contacts; | ||
|
||
/** | ||
* @author woogienoogie | ||
*/ | ||
public enum AddressType { | ||
PERSONAL, | ||
|
1 change: 0 additions & 1 deletion
1
components/src/main/java/com/constantcontact/v2/contacts/ConfirmStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.constantcontact.v2.contacts; | ||
|
||
/** | ||
* @author woogienoogie | ||
*/ | ||
public enum ConfirmStatus { | ||
CONFIRMED, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
components/src/main/java/com/constantcontact/v2/contacts/ContactListStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.constantcontact.v2.contacts; | ||
|
||
/** | ||
* @author woogienoogie | ||
*/ | ||
public enum ContactListStatus { | ||
ACTIVE, | ||
|
1 change: 0 additions & 1 deletion
1
components/src/main/java/com/constantcontact/v2/contacts/ContactStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.constantcontact.v2.contacts; | ||
|
||
/** | ||
* @author woogienoogie | ||
*/ | ||
public enum ContactStatus { | ||
ALL, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
components/src/main/java/com/constantcontact/v2/contacts/OptInSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.