Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 13 additions & 101 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,19 @@
<http-components.version>4.5.13</http-components.version>

<!-- Jackson version -->
<jackson.version>2.12.1</jackson.version>
<jackson.version>2.13.0</jackson.version>

<!-- Specify which Checkstyle ruleset to use -->
<checkstyle.ruleset>build/checkstyle.xml</checkstyle.ruleset>
<checkstyle.plugin.version>3.1.2</checkstyle.plugin.version>
<checkstyle.version>8.29</checkstyle.version>

<!-- Log4J Version -->
<log4j2.version>2.17.0</log4j2.version>
<slf4j.version>1.7.30</slf4j.version>
<!-- Logging version -->
<slf4j.version>1.7.32</slf4j.version>

<!-- test toggling -->
<!-- tests -->
<junit.version>5.8.2</junit.version>
<mockito.version>4.1.0</mockito.version>
<skipTests>false</skipTests>
<skipCodeCoverage>true</skipCodeCoverage>
<skipCheckStyle>false</skipCheckStyle>
Expand Down Expand Up @@ -107,21 +108,21 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.1</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.1</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<!-- Mocking in Tests -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.8.0</version>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>

Expand All @@ -137,27 +138,15 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.37.v20210219</version>
<version>11.0.6</version>
<scope>test</scope>
</dependency>

<!-- Logging in tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -192,65 +181,6 @@
</configuration>
</plugin>

<!-- Enforce check styles validation -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<executions>
<execution>
<id>checkstyle-validate</id>
<phase>validate</phase><!-- when we need to run checkstyle::check -->
<configuration>
<configLocation>${checkstyle.ruleset}</configLocation>
<encoding>utf-8</encoding>
<consoleOutput>true</consoleOutput>
<violationSeverity>warning</violationSeverity>
<failsOnError>true</failsOnError>
<enableRSS>false</enableRSS>

<!-- By default we run checkstyle validation-->
<skip>${skipCheckStyle}</skip>
</configuration>
<goals>
<!-- Generate site/html report -->
<goal>checkstyle</goal>

<!-- Enforce failing build on checkstyle failure -->
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- License Auditing -->
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>3.0</version>
<configuration>
<header>LICENSE.txt</header>
<excludes>
<exclude>**/.md</exclude>
<exclude>**/.bak</exclude>
<exclude>**.yml</exclude>
<exclude>**.yaml</exclude>
<exclude>**.xml</exclude>
<exclude>build/**</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/main/resources/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Release plugin -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
Expand All @@ -264,24 +194,6 @@
</configuration>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<!-- Use a current version of checkstyle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>

<!-- For deploying to maven central -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@
import org.sourcelab.activecampaign.apiv3.request.account.AccountUpdateRequest;
import org.sourcelab.activecampaign.apiv3.request.contact.Contact;
import org.sourcelab.activecampaign.apiv3.request.contact.ContactCreateRequest;
import org.sourcelab.activecampaign.apiv3.request.contact.ContactGetRequest;
import org.sourcelab.activecampaign.apiv3.request.contact.ContactUpdateRequest;
import org.sourcelab.activecampaign.apiv3.request.contact.ContactRetrieveRequest;
import org.sourcelab.activecampaign.apiv3.request.contactList.ContactListSubscribeRequest;
import org.sourcelab.activecampaign.apiv3.request.contactTag.ContactTag;
import org.sourcelab.activecampaign.apiv3.request.contactTag.ContactTagCreateRequest;
import org.sourcelab.activecampaign.apiv3.request.contactTag.ContactTagDeleteRequest;
import org.sourcelab.activecampaign.apiv3.request.customField.CustomFieldListRequest;
import org.sourcelab.activecampaign.apiv3.request.ecomCustomer.EcomCustomer;
import org.sourcelab.activecampaign.apiv3.request.ecomCustomer.EcomCustomerDeleteRequest;
import org.sourcelab.activecampaign.apiv3.request.ecomCustomer.EcomCustomerGetRequest;
import org.sourcelab.activecampaign.apiv3.request.ecomCustomer.EcomCustomerPostRequest;
import org.sourcelab.activecampaign.apiv3.request.ecomOrder.EcomOrder;
import org.sourcelab.activecampaign.apiv3.request.ecomOrder.EcomOrderPostRequest;
import org.sourcelab.activecampaign.apiv3.request.list.ListListRequest;
import org.sourcelab.activecampaign.apiv3.request.tag.TagCreateRequest;
import org.sourcelab.activecampaign.apiv3.request.tag.TagListRequest;
Expand All @@ -39,10 +47,13 @@
import org.sourcelab.activecampaign.apiv3.response.account.AccountListResponse;
import org.sourcelab.activecampaign.apiv3.response.account.AccountResponse;
import org.sourcelab.activecampaign.apiv3.response.contact.ContactCreateResponse;
import org.sourcelab.activecampaign.apiv3.response.contact.ContactGetResponse;
import org.sourcelab.activecampaign.apiv3.response.contact.ContactUpdateResponse;
import org.sourcelab.activecampaign.apiv3.response.contact.ContactRetrieveResponse;
import org.sourcelab.activecampaign.apiv3.response.contactTag.ContactTagCreateResponse;
import org.sourcelab.activecampaign.apiv3.response.contactTag.ContactTagDeleteResponse;
import org.sourcelab.activecampaign.apiv3.response.customField.CustomFieldListResponse;
import org.sourcelab.activecampaign.apiv3.response.ecomCustomer.EcomCustomerResponse;
import org.sourcelab.activecampaign.apiv3.response.list.ListListResponse;
import org.sourcelab.activecampaign.apiv3.response.tag.TagCreateResponse;
import org.sourcelab.activecampaign.apiv3.response.tag.TagListResponse;
Expand Down Expand Up @@ -133,14 +144,38 @@ public boolean accountDelete(final Account account) {
return submitRequest(new AccountDeleteRequest(account));
}

public ContactGetResponse getContact(final Long id) {
return submitRequest(new ContactGetRequest(id));
}

public ContactCreateResponse contactCreate(final Contact contactToCreate) {
return submitRequest(new ContactCreateRequest(contactToCreate));
}

public ContactUpdateResponse updateContact(final Contact contactToUpdate) {
return submitRequest(new ContactUpdateRequest(contactToUpdate));
}

public ContactCreateResponse contactSync(final Contact contactToCreate) {
return submitRequest(new ContactCreateRequest(contactToCreate));
}

public EcomCustomerResponse getEcomCustomer(final Long id) {
return submitRequest(new EcomCustomerGetRequest(id));
}

public EcomCustomerResponse createEcomCustomer(final EcomCustomer ecomCustomer) {
return submitRequest(new EcomCustomerPostRequest(ecomCustomer));
}

public Void deleteEcomCustomer(final Long id) {
return submitRequest(new EcomCustomerDeleteRequest(id));
}

public Void createEcomOrder(final EcomOrder ecomOrder) {
return submitRequest(new EcomOrderPostRequest(ecomOrder));
}

public ContactRetrieveResponse contactRetrieve(final long contactId) {
return submitRequest(new ContactRetrieveRequest(contactId));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright 2021 Unicornify https://github.com/unicornify/activecampaign-java-client
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package org.sourcelab.activecampaign.apiv3.request.contact;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.sourcelab.activecampaign.JacksonFactory;
import org.sourcelab.activecampaign.apiv3.response.contact.ContactGetResponse;
import org.sourcelab.http.rest.request.Request;
import org.sourcelab.http.rest.request.RequestMethod;
import org.sourcelab.http.rest.request.body.RequestBodyContent;
import org.sourcelab.http.rest.request.body.StringBodyContent;

import java.io.IOException;

/**
* Represents an account create request.
*/
public class ContactGetRequest implements Request<ContactGetResponse> {
private final Long id;

/**
* Constructor.
* @param contact Contact
*/
public ContactGetRequest(final Long id) {
this.id = id;
}

@Override
public String getApiEndpoint() {
return "api/3/contacts/" + id;
}

@Override
public RequestMethod getRequestMethod() {
return RequestMethod.GET;
}

@Override
public RequestBodyContent getRequestBody() {
try {
return new StringBodyContent(
JacksonFactory.newInstance().writeValueAsString(id)
);
} catch (final JsonProcessingException exception) {
throw new RuntimeException(exception);
}
}

@Override
public ContactGetResponse parseResponse(final String response) throws IOException {
return JacksonFactory.newInstance().readValue(response, ContactGetResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright 2021 Unicornify https://github.com/unicornify/activecampaign-java-client
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package org.sourcelab.activecampaign.apiv3.request.contact;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.sourcelab.activecampaign.JacksonFactory;
import org.sourcelab.activecampaign.apiv3.response.contact.ContactUpdateResponse;
import org.sourcelab.http.rest.request.Request;
import org.sourcelab.http.rest.request.RequestMethod;
import org.sourcelab.http.rest.request.body.RequestBodyContent;
import org.sourcelab.http.rest.request.body.StringBodyContent;

import java.io.IOException;
import java.util.Objects;

/**
* Represents an account create request.
*/
public class ContactUpdateRequest implements Request<ContactUpdateResponse> {
private final Contact contact;

/**
* Constructor.
* @param contact Contact
*/
public ContactUpdateRequest(final Contact contact) {
this.contact = Objects.requireNonNull(contact);
}

@Override
public String getApiEndpoint() {
return "api/3/contacts/" + contact.getId();
}

@Override
public RequestMethod getRequestMethod() {
return RequestMethod.PUT;
}

@Override
public RequestBodyContent getRequestBody() {
try {
return new StringBodyContent(
JacksonFactory.newInstance().writeValueAsString(contact)
);
} catch (final JsonProcessingException exception) {
throw new RuntimeException(exception);
}
}

@Override
public ContactUpdateResponse parseResponse(final String response) throws IOException {
return JacksonFactory.newInstance().readValue(response, ContactUpdateResponse.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CustomFieldListRequest implements GetRequest<CustomFieldListRespons

@Override
public String getApiEndpoint() {
return "api/3/fields";
return "api/3/fields?limit=100";
}

@Override
Expand Down
Loading