Skip to content

Commit da4b63d

Browse files
author
stephen powis
committed
start implementing Prospect end point
1 parent 11bfe5b commit da4b63d

File tree

24 files changed

+1181
-26
lines changed

24 files changed

+1181
-26
lines changed

src/main/java/com/darksci/pardot/api/Example.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import com.darksci.pardot.api.response.account.Account;
77
import com.darksci.pardot.api.response.campaign.CampaignQueryResponse;
88

9-
import java.io.IOException;
10-
119
/**
1210
* Just a simple example code showing basic usage.
1311
*/

src/main/java/com/darksci/pardot/api/PardotClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.darksci.pardot.api.parser.email.EmailReadResponseParser;
99
import com.darksci.pardot.api.parser.email.EmailStatsResponseParser;
1010
import com.darksci.pardot.api.parser.login.LoginResponseParser;
11+
import com.darksci.pardot.api.parser.prospect.ProspectReadResponseParser;
1112
import com.darksci.pardot.api.parser.user.UserAbilitiesParser;
1213
import com.darksci.pardot.api.parser.user.UserQueryResponseParser;
1314
import com.darksci.pardot.api.parser.user.UserReadResponseParser;
@@ -22,6 +23,7 @@
2223
import com.darksci.pardot.api.request.email.EmailSendOneToOneRequest;
2324
import com.darksci.pardot.api.request.email.EmailStatsRequest;
2425
import com.darksci.pardot.api.request.login.LoginRequest;
26+
import com.darksci.pardot.api.request.prospect.ProspectReadRequest;
2527
import com.darksci.pardot.api.request.user.UserAbilitiesRequest;
2628
import com.darksci.pardot.api.request.user.UserQueryRequest;
2729
import com.darksci.pardot.api.request.user.UserReadRequest;
@@ -32,6 +34,7 @@
3234
import com.darksci.pardot.api.response.email.Email;
3335
import com.darksci.pardot.api.response.email.EmailStatsResponse;
3436
import com.darksci.pardot.api.response.login.LoginResponse;
37+
import com.darksci.pardot.api.response.prospect.Prospect;
3538
import com.darksci.pardot.api.response.user.User;
3639
import com.darksci.pardot.api.response.user.UserAbilitiesResponse;
3740
import com.darksci.pardot.api.response.user.UserQueryResponse;
@@ -285,6 +288,15 @@ public Email emailSendList(final EmailSendListRequest request) {
285288
return submitRequest(request, new EmailReadResponseParser());
286289
}
287290

291+
/**
292+
* Make API request to read a prospect.
293+
* @param request Request definition.
294+
* @return Parsed api response.
295+
*/
296+
public Prospect prospectRead(final ProspectReadRequest request) {
297+
return submitRequest(request, new ProspectReadResponseParser());
298+
}
299+
288300
/**
289301
* Clean up instance, releasing any resources held internally.
290302
*/

src/main/java/com/darksci/pardot/api/ParserException.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.darksci.pardot.api;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
5-
63
/**
74
* Thrown when a parser implementation has an error.
85
*/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.darksci.pardot.api.parser.prospect;
2+
3+
import com.darksci.pardot.api.parser.JacksonFactory;
4+
import com.darksci.pardot.api.parser.ResponseParser;
5+
import com.darksci.pardot.api.response.prospect.Prospect;
6+
import com.darksci.pardot.api.response.prospect.ProspectReadResponse;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
10+
import java.io.IOException;
11+
12+
/**
13+
* Parses Prospect Read API response.
14+
*/
15+
public class ProspectReadResponseParser implements ResponseParser<Prospect> {
16+
private static final Logger logger = LoggerFactory.getLogger(ProspectReadResponseParser.class);
17+
18+
@Override
19+
public Prospect parseResponse(final String responseStr) throws IOException {
20+
logger.info("{}", responseStr);
21+
return JacksonFactory
22+
.newInstance()
23+
.readValue(responseStr, ProspectReadResponse.class).getProspect();
24+
}
25+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.darksci.pardot.api.request.prospect;
2+
3+
import com.darksci.pardot.api.request.BaseRequest;
4+
5+
/**
6+
* Defines a Prospect Read Request.
7+
*/
8+
public class ProspectReadRequest extends BaseRequest<ProspectReadRequest> {
9+
public ProspectReadRequest() {
10+
super();
11+
12+
// Default to full output
13+
setParam("output", "full");
14+
}
15+
16+
@Override
17+
public String getApiEndpoint() {
18+
return "prospect/do/read";
19+
}
20+
21+
/**
22+
* Returns data for the prospect specified by id.
23+
* @param id Prospect Id to read.
24+
* @return RequestBuilder
25+
*/
26+
public ProspectReadRequest selectById(final Long id) {
27+
setParam("email", null);
28+
return setParam("id", id);
29+
}
30+
31+
/**
32+
* Returns data for the prospect specified by email.
33+
* @param email Prospect Email to read.
34+
* @return RequestBuilder
35+
*/
36+
public ProspectReadRequest selectByEmail(final String email) {
37+
setParam("id", null);
38+
return setParam("email", email);
39+
}
40+
41+
/**
42+
* Get Response in 'Full' format.
43+
* @return RequestBuilder
44+
*/
45+
public ProspectReadRequest withFullOutputFormat() {
46+
return setParam("output", "full");
47+
}
48+
49+
/**
50+
* Get Response in 'Simple' format.
51+
* @return RequestBuilder
52+
*/
53+
public ProspectReadRequest withSimpleOutputFormat() {
54+
return setParam("output", "simple");
55+
}
56+
}

src/main/java/com/darksci/pardot/api/response/account/Account.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.darksci.pardot.api.response.account;
22

33
import com.fasterxml.jackson.annotation.JsonFormat;
4+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
45
import org.joda.time.DateTime;
56

67
/**
@@ -14,8 +15,10 @@ public class Account {
1415
private String vanityDomain;
1516
private Long pluginCampaignId;
1617
private String trackingCodeTemplate;
17-
private String address1;
18-
private String address2;
18+
@JacksonXmlProperty(localName = "address1")
19+
private String addressOne;
20+
@JacksonXmlProperty(localName = "address2")
21+
private String addressTwo;
1922
private String city;
2023
private String state;
2124
private String territory;
@@ -56,12 +59,12 @@ public String getTrackingCodeTemplate() {
5659
return trackingCodeTemplate;
5760
}
5861

59-
public String getAddress1() {
60-
return address1;
62+
public String getAddressOne() {
63+
return addressOne;
6164
}
6265

63-
public String getAddress2() {
64-
return address2;
66+
public String getAddressTwo() {
67+
return addressTwo;
6568
}
6669

6770
public String getCity() {
@@ -110,8 +113,8 @@ public String toString() {
110113
+ ", vanityDomain='" + vanityDomain + '\''
111114
+ ", pluginCampaignId=" + pluginCampaignId
112115
+ ", trackingCodeTemplate='" + trackingCodeTemplate + '\''
113-
+ ", address1='" + address1 + '\''
114-
+ ", address2='" + address2 + '\''
116+
+ ", addressOne='" + addressOne + '\''
117+
+ ", addressTwo='" + addressTwo + '\''
115118
+ ", city='" + city + '\''
116119
+ ", state='" + state + '\''
117120
+ ", territory='" + territory + '\''
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.darksci.pardot.api.response.list;
2+
3+
import com.fasterxml.jackson.annotation.JsonFormat;
4+
import org.joda.time.LocalDateTime;
5+
6+
/**
7+
* Represents a Pardot List.
8+
*/
9+
public class List {
10+
private Long id;
11+
private String name;
12+
private String title;
13+
private String description;
14+
private Boolean isPublic;
15+
private Boolean isDynamic;
16+
private Boolean isCrmVisible;
17+
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
18+
private LocalDateTime createdAt;
19+
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
20+
private LocalDateTime updatedAt;
21+
22+
public Long getId() {
23+
return id;
24+
}
25+
26+
public String getName() {
27+
return name;
28+
}
29+
30+
public String getTitle() {
31+
return title;
32+
}
33+
34+
public String getDescription() {
35+
return description;
36+
}
37+
38+
public Boolean getPublic() {
39+
return isPublic;
40+
}
41+
42+
public Boolean getDynamic() {
43+
return isDynamic;
44+
}
45+
46+
public Boolean getCrmVisible() {
47+
return isCrmVisible;
48+
}
49+
50+
public LocalDateTime getCreatedAt() {
51+
return createdAt;
52+
}
53+
54+
public LocalDateTime getUpdatedAt() {
55+
return updatedAt;
56+
}
57+
58+
@Override
59+
public String toString() {
60+
return "List{"
61+
+ "id=" + id
62+
+ ", name='" + name + '\''
63+
+ ", title='" + title + '\''
64+
+ ", description='" + description + '\''
65+
+ ", isPublic=" + isPublic
66+
+ ", isDynamic=" + isDynamic
67+
+ ", isCrmVisible=" + isCrmVisible
68+
+ ", createdAt=" + createdAt
69+
+ ", updatedAt=" + updatedAt
70+
+ '}';
71+
}
72+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.darksci.pardot.api.response.list;
2+
3+
import com.fasterxml.jackson.annotation.JsonFormat;
4+
import org.joda.time.LocalDateTime;
5+
6+
/**
7+
* Represents a membership of a list.
8+
*/
9+
public class ListSubscription {
10+
private Long id;
11+
private Boolean didOptIn;
12+
private Boolean didOptOut;
13+
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
14+
private LocalDateTime createdAt;
15+
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
16+
private LocalDateTime updatedAt;
17+
private List list;
18+
19+
public Long getId() {
20+
return id;
21+
}
22+
23+
public Boolean getDidOptIn() {
24+
return didOptIn;
25+
}
26+
27+
public Boolean getDidOptOut() {
28+
return didOptOut;
29+
}
30+
31+
public LocalDateTime getCreatedAt() {
32+
return createdAt;
33+
}
34+
35+
public LocalDateTime getUpdatedAt() {
36+
return updatedAt;
37+
}
38+
39+
public List getList() {
40+
return list;
41+
}
42+
43+
@Override
44+
public String toString() {
45+
return "ListSubscription{"
46+
+ "id=" + id
47+
+ ", didOptIn=" + didOptIn
48+
+ ", didOptOut=" + didOptOut
49+
+ ", createdAt=" + createdAt
50+
+ ", updatedAt=" + updatedAt
51+
+ ", list=" + list
52+
+ '}';
53+
}
54+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.darksci.pardot.api.response.profile;
2+
3+
import java.util.List;
4+
5+
/**
6+
* Represents a Pardot profile.
7+
*/
8+
public class Profile {
9+
private Long id;
10+
private String name;
11+
private List<ProfileCriteria> profileCriteria;
12+
13+
public Long getId() {
14+
return id;
15+
}
16+
17+
public String getName() {
18+
return name;
19+
}
20+
21+
public List<ProfileCriteria> getProfileCriteria() {
22+
return profileCriteria;
23+
}
24+
25+
@Override
26+
public String toString() {
27+
return "Profile{"
28+
+ "id=" + id
29+
+ ", name='" + name + '\''
30+
+ ", profileCriteria=" + profileCriteria
31+
+ '}';
32+
}
33+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.darksci.pardot.api.response.profile;
2+
3+
/**
4+
* Represents a Pardot Profile Criteria.
5+
*/
6+
public class ProfileCriteria {
7+
private Long id;
8+
private String name;
9+
private String matches;
10+
11+
public Long getId() {
12+
return id;
13+
}
14+
15+
public String getName() {
16+
return name;
17+
}
18+
19+
public String getMatches() {
20+
return matches;
21+
}
22+
23+
@Override
24+
public String toString() {
25+
return "ProfileCriteria{"
26+
+ "id=" + id
27+
+ ", name='" + name + '\''
28+
+ ", matches='" + matches + '\''
29+
+ '}';
30+
}
31+
}

0 commit comments

Comments
 (0)