Skip to content
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

Add Card in ResponseBuilder #155

Merged
merged 1 commit into from
Nov 8, 2018
Merged
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
11 changes: 11 additions & 0 deletions ask-sdk-core/src/com/amazon/ask/response/ResponseBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ public ResponseBuilder withSpeech(String speechText) {
return this;
}

/**
* Sets a {@link Card} object on the response.
*
* @param card card object
* @return response builder
*/
public ResponseBuilder withCard(Card card) {
this.card = card;
return this;
}

/**
* Sets a simple {@link Card} on the response with the specified title and content.
*
Expand Down
17 changes: 17 additions & 0 deletions ask-sdk-core/tst/com/amazon/ask/response/ResponseBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,23 @@ public void build_response_with_setters_standard_card() {
assertEquals(responseWithBuilder.get(), response);
}

@Test
public void build_response_with_card() {
SimpleCard simpleCard = SimpleCard.builder()
.withTitle("fooTitle")
.withContent("fooContent")
.build();

Response response = Response.builder()
.withCard(simpleCard)
.build();

Optional<Response> responseWithBuilder = builder
.withCard(simpleCard)
.build();
assertEquals(responseWithBuilder.get(), response);
}

@Test
public void build_response_with_link_account_card() {
Response response = Response.builder()
Expand Down