-
Notifications
You must be signed in to change notification settings - Fork 8
Triggercamapign #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Triggercamapign #44
Conversation
<artifactId>guava</artifactId> | ||
<version>18.0</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant comment
@Getter | ||
@Setter | ||
@ToString | ||
@AllArgsConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data lombok's annotation can be used instead of a combination of Getter,Setter,ToString
|
||
private final HttpCommandExecutor httpCommandExecutor; | ||
|
||
MarketoTriggerCampaignClient(HttpCommandExecutor httpCommandExecutor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it isn't a public?
you can use @requiredargsconstructor lombok annotation
public TriggerCampaignResult requestTriggerCampaign(int campaignId, | ||
TriggerCampaignRequest.LeadId[] leadIds) | ||
throws MarketoApiException { | ||
return this.requestTriggerCampaign(campaignId, leadIds, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omit redundant 'this'
new TriggerCampaignRequest.Token[]{}); | ||
} | ||
|
||
public TriggerCampaignResult requestTriggerCampaign(int campaignId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have only one method:
TriggerCampaignResult requestTriggerCampaign(int campaignId, TriggerCampaignRequest triggerCampaignRequest)
and construct TriggerCampaignRequest outside client.
in your case, your split constructing TriggerCampaignRequest into 2 places, outside client your construct leadIds and tokens, inside client ( in RequestTriggerCampaign ) - wrap them in TriggerCampaignRequest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, maybe it is just the bad model for TriggerCampaignRequest.
and you need something like:
public TriggerCampaignResult requestTriggerCampaign(
int campaignId,
List<Integer> leadIds,
List<TriggerCampaignToken> tokens)
throws MarketoApiException { | ||
List<TriggerCampaignResult> triggerCampaignResults = httpCommandExecutor.execute( | ||
new RequestTriggerCampaign(campaignId, leadIds, tokens)); | ||
return triggerCampaignResults.get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the context, but it is an unsafe call. check size isn't empty at least. the same in next method
@Setter | ||
@ToString | ||
@AllArgsConstructor | ||
public class TriggerCampaignRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, it is confusing with RequestTriggerCampaign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request data (leads and tokens) should be moved to the appropriate command (RequestTriggerCampaignCommand)
|
||
import java.util.List; | ||
|
||
public class MarketoTriggerCampaignClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some tests for the new client
|
||
MarketoTokenClient getMarketoTokenClient(); | ||
|
||
MarketoTriggerCampaignClient getMarketoTriggerCampaignClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming convention of the Marketo and this sdk is not followed. I suggest to rename this client to SmartCampaignClient or CampaignClient. It will be able to be extended with other smart campaign endpoints.
@Setter | ||
@ToString | ||
@AllArgsConstructor | ||
public static class LeadId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According Marketo https://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#/Campaigns/triggerCampaignUsingPOST
it should be separate domain class InputLead
@Setter | ||
@ToString | ||
@AllArgsConstructor | ||
public static class Token { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like in the previous comment it should be separate domain class Token
import lombok.ToString; | ||
|
||
@Getter @Setter @ToString | ||
public class TriggerCampaignResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Result of request trigger command should be Array of Campaign domain classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like is deprecated request
No description provided.