-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK-1162: Add SignedRequestBuilder and SignedRequest
- Loading branch information
Showing
17 changed files
with
694 additions
and
223 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
12 changes: 12 additions & 0 deletions
12
yoti-sdk-impl/src/main/java/com/yoti/api/client/spi/remote/call/HttpMethod.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,6 +1,18 @@ | ||
package com.yoti.api.client.spi.remote.call; | ||
|
||
import static java.util.Arrays.asList; | ||
import static java.util.Collections.unmodifiableList; | ||
|
||
import java.util.List; | ||
|
||
public class HttpMethod { | ||
|
||
public static final String HTTP_GET = "GET"; | ||
public static final String HTTP_POST = "POST"; | ||
public static final String HTTP_PUT = "PUT"; | ||
public static final String HTTP_PATCH = "PATCH"; | ||
public static final String HTTP_DELETE = "DELETE"; | ||
|
||
public static final List<String> SUPPORTED_HTTP_METHODS = unmodifiableList(asList(HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_GET, HTTP_DELETE)); | ||
|
||
} |
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
48 changes: 48 additions & 0 deletions
48
yoti-sdk-impl/src/main/java/com/yoti/api/client/spi/remote/call/SignedRequest.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,48 @@ | ||
package com.yoti.api.client.spi.remote.call; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.Map; | ||
|
||
public class SignedRequest { | ||
|
||
private final URI uri; | ||
private final String method; | ||
private final byte[] data; | ||
private final Map<String, String> headers; | ||
private final JsonResourceFetcher jsonResourceFetcher; | ||
|
||
SignedRequest(final URI uri, | ||
final String method, | ||
final byte[] data, | ||
final Map<String, String> headers, | ||
JsonResourceFetcher jsonResourceFetcher) { | ||
|
||
this.uri = uri; | ||
this.method = method; | ||
this.data = data; | ||
this.headers = headers; | ||
this.jsonResourceFetcher = jsonResourceFetcher; | ||
} | ||
|
||
public URI getUri() { | ||
return uri; | ||
} | ||
|
||
public String getMethod() { | ||
return method; | ||
} | ||
|
||
public byte[] getData() { | ||
return data != null ? data.clone() : null; | ||
} | ||
|
||
public Map<String, String> getHeaders() { | ||
return headers; | ||
} | ||
|
||
public <T> T execute(Class<T> clazz) throws ResourceException, IOException { | ||
UrlConnector urlConnector = UrlConnector.get(uri.toString()); | ||
return jsonResourceFetcher.doRequest(urlConnector, getMethod(), getData(), getHeaders(), clazz); | ||
} | ||
} |
Oops, something went wrong.