Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.yoti.api.client.docs.session.create;

import com.fasterxml.jackson.annotation.JsonProperty;

public class CompanyProfilePayload {

@JsonProperty("company_name")
private final String companyName;

private CompanyProfilePayload(String companyName) {
this.companyName = companyName;
}

public static Builder builder() {
return new Builder();
}

public String getCompanyName() {
return companyName;
}

public static class Builder {

private String companyName;

Builder() {}

/**
* Sets the company name to be used for the session
*
* @param companyName the company name
* @return the builder
*/
public Builder withCompanyName(String companyName) {
this.companyName = companyName;
return this;
}

public CompanyProfilePayload build() {
return new CompanyProfilePayload(companyName);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public class SessionSpec {
@JsonProperty("create_identity_profile_preview")
private final Boolean createIdentityProfilePreview;

@JsonProperty("company_profile")
private final CompanyProfilePayload companyProfile;

private SessionSpec(Integer clientSessionTokenTtl,
Integer resourcesTtl,
ImportTokenPayload importToken,
Expand All @@ -85,7 +88,8 @@ private SessionSpec(Integer clientSessionTokenTtl,
SubjectPayload subject,
ResourceCreationContainer resources,
Boolean createIdentityProfilePreview,
AdvancedIdentityProfileRequirementsPayload advancedIdentityProfileRequirements) {
AdvancedIdentityProfileRequirementsPayload advancedIdentityProfileRequirements,
CompanyProfilePayload companyProfile) {
this.clientSessionTokenTtl = clientSessionTokenTtl;
this.resourcesTtl = resourcesTtl;
this.importToken = importToken;
Expand All @@ -103,6 +107,7 @@ private SessionSpec(Integer clientSessionTokenTtl,
this.resources = resources;
this.createIdentityProfilePreview = createIdentityProfilePreview;
this.advancedIdentityProfileRequirements = advancedIdentityProfileRequirements;
this.companyProfile = companyProfile;
}

public static Builder builder() {
Expand Down Expand Up @@ -263,6 +268,15 @@ public AdvancedIdentityProfileRequirementsPayload getAdvancedIdentityProfileRequ
return advancedIdentityProfileRequirements;
}

/**
* The company profile to be used for the session
*
* @return the company profile
*/
public CompanyProfilePayload getCompanyProfile() {
return companyProfile;
}

public static class Builder {

private final List<RequestedCheck<?>> requestedChecks;
Expand All @@ -282,6 +296,7 @@ public static class Builder {
private SubjectPayload subject;
private ResourceCreationContainer resources;
private Boolean createIdentityProfilePreview;
private CompanyProfilePayload companyProfile;

private Builder() {
requestedChecks = new ArrayList<>();
Expand Down Expand Up @@ -477,6 +492,17 @@ public Builder withAdvancedIdentityProfileRequirements(AdvancedIdentityProfileRe
return this;
}

/**
* Sets the company profile to be used for the session
*
* @param companyProfile the company profile
* @return the builder
*/
public Builder withCompanyProfile(CompanyProfilePayload companyProfile) {
this.companyProfile = companyProfile;
return this;
}

/**
* Builds the {@link SessionSpec} based on the values supplied to the builder
*
Expand All @@ -500,7 +526,8 @@ public SessionSpec build() {
subject,
resources,
createIdentityProfilePreview,
advancedIdentityProfileRequirementsPayload);
advancedIdentityProfileRequirementsPayload,
companyProfile);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.yoti.api.client.docs.session.create;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;

import org.junit.Test;

public class CompanyProfilePayloadTest {

private static final String SOME_COMPANY_NAME = "someCompanyName";

@Test
public void shouldBuildWithCompanyName() {
CompanyProfilePayload result = CompanyProfilePayload.builder()
.withCompanyName(SOME_COMPANY_NAME)
.build();

assertThat(result.getCompanyName(), is(SOME_COMPANY_NAME));
}

@Test
public void companyName_shouldBeNullWhenNotSet() {
CompanyProfilePayload result = CompanyProfilePayload.builder()
.build();

assertThat(result.getCompanyName(), is(nullValue()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class SessionSpecTest {
@Mock ImportTokenPayload importTokenMock;
@Mock IdentityProfileRequirementsPayload identityProfileRequirementsPayloadMock;
@Mock SubjectPayload subjectPayloadMock;
@Mock CompanyProfilePayload companyProfilePayloadMock;

@Test
public void shouldBuildWithMinimalConfiguration() {
Expand All @@ -72,6 +73,7 @@ public void shouldBuildWithMinimalConfiguration() {
assertThat(result.getSubject(), is(nullValue()));
assertThat(result.getResources(), is(nullValue()));
assertThat(result.getCreateIdentityProfilePreview(), is(nullValue()));
assertThat(result.getCompanyProfile(), is(nullValue()));
}

@Test
Expand Down Expand Up @@ -252,4 +254,13 @@ public void shouldBuildWithImportToken() {
assertThat(sessionSpec.getImportToken(), is(importTokenMock));
}

@Test
public void withCompanyProfile_shouldSetTheCompanyProfile() {
SessionSpec result = SessionSpec.builder()
.withCompanyProfile(companyProfilePayloadMock)
.build();

assertThat(result.getCompanyProfile(), is(companyProfilePayloadMock));
}

}
Loading