-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,333 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
client/src/main/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sinch.sdk.domains.verification.adapters.converters; | ||
|
||
import com.sinch.sdk.core.http.HttpMethod; | ||
import com.sinch.sdk.domains.verification.models.Link; | ||
import com.sinch.sdk.domains.verification.models.LinkRelType; | ||
import com.sinch.sdk.domains.verification.models.dto.v1.VerificationResourceLinkDto; | ||
import java.util.Collection; | ||
import java.util.stream.Collectors; | ||
|
||
public class LinkDtoConverter { | ||
|
||
public static Collection<Link> convert(Collection<VerificationResourceLinkDto> dto) { | ||
return dto.stream().map(LinkDtoConverter::convert).collect(Collectors.toList()); | ||
} | ||
|
||
public static Link convert(VerificationResourceLinkDto dto) { | ||
return Link.builder() | ||
.setRel(LinkRelType.from(dto.getRel())) | ||
.setHref(dto.getHref()) | ||
.setMethod(HttpMethod.valueOf(dto.getMethod())) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
client/src/main/com/sinch/sdk/domains/verification/models/Identity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
package com.sinch.sdk.domains.verification.models; | ||
|
||
public abstract class Identity {} | ||
/** Base class for Identity based objects */ | ||
public abstract class Identity { | ||
|
||
@Override | ||
public String toString() { | ||
return "Identity{}"; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
client/src/main/com/sinch/sdk/domains/verification/models/Link.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.sinch.sdk.domains.verification.models; | ||
|
||
import com.sinch.sdk.core.http.HttpMethod; | ||
|
||
/** Available methods and actions which can be done after a successful Verification */ | ||
public class Link { | ||
private final LinkRelType rel; | ||
private final String href; | ||
private final HttpMethod method; | ||
|
||
/** | ||
* @param rel The related action that can be performed on the initiated Verification | ||
* @param href The complete URL to perform the specified action, localized to the DataCenter which | ||
* handled the original Verification request | ||
* @param method The HTTP method to use when performing the action using the linked localized URL | ||
*/ | ||
public Link(LinkRelType rel, String href, HttpMethod method) { | ||
this.rel = rel; | ||
this.href = href; | ||
this.method = method; | ||
} | ||
|
||
public LinkRelType getRel() { | ||
return rel; | ||
} | ||
|
||
public String getHref() { | ||
return href; | ||
} | ||
|
||
public HttpMethod getMethod() { | ||
return method; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Link{" + "rel='" + rel + '\'' + ", href='" + href + '\'' + ", method=" + method + '}'; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
|
||
LinkRelType rel; | ||
String href; | ||
HttpMethod method; | ||
|
||
private Builder() {} | ||
|
||
public Builder setRel(LinkRelType rel) { | ||
this.rel = rel; | ||
return this; | ||
} | ||
|
||
public Builder setHref(String href) { | ||
this.href = href; | ||
return this; | ||
} | ||
|
||
public Builder setMethod(HttpMethod method) { | ||
this.method = method; | ||
return this; | ||
} | ||
|
||
public Link build() { | ||
return new Link(rel, href, method); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
client/src/main/com/sinch/sdk/domains/verification/models/LinkRelType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.sinch.sdk.domains.verification.models; | ||
|
||
import com.sinch.sdk.core.utils.EnumDynamic; | ||
import com.sinch.sdk.core.utils.EnumSupportDynamic; | ||
import java.util.Arrays; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Link rel authorized values | ||
* | ||
* @since 1.0 | ||
*/ | ||
public class LinkRelType extends EnumDynamic<String, LinkRelType> { | ||
|
||
/** Get the status of a Verification. */ | ||
public static final LinkRelType STATUS = new LinkRelType("status"); | ||
/** Report a verification */ | ||
public static final LinkRelType REPORT = new LinkRelType("report"); | ||
|
||
private static final EnumSupportDynamic<String, LinkRelType> ENUM_SUPPORT = | ||
new EnumSupportDynamic<>(LinkRelType.class, LinkRelType::new, Arrays.asList(STATUS, REPORT)); | ||
|
||
private LinkRelType(String value) { | ||
super(value); | ||
} | ||
|
||
public static Stream<LinkRelType> values() { | ||
return ENUM_SUPPORT.values(); | ||
} | ||
|
||
public static LinkRelType from(String value) { | ||
return ENUM_SUPPORT.from(value); | ||
} | ||
|
||
public static String valueOf(LinkRelType e) { | ||
return ENUM_SUPPORT.valueOf(e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.