diff --git a/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java b/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java index bf2ffb5..ddaa88f 100644 --- a/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java +++ b/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java @@ -535,16 +535,7 @@ public CompletableFuture check(ClientCheckRequest request, configuration.assertValid(); String storeId = configuration.getStoreIdChecked(); - CheckRequest body = new CheckRequest(); - - if (request != null) { - body.tupleKey(request.asCheckRequestTupleKey()); - - var contextualTuples = request.getContextualTuples(); - if (contextualTuples != null && !contextualTuples.isEmpty()) { - body.contextualTuples(ClientTupleKey.asContextualTupleKeys(contextualTuples)); - } - } + CheckRequest body = request.asCheckRequest(); if (options != null && !isNullOrWhitespace(options.getAuthorizationModelId())) { body.authorizationModelId(options.getAuthorizationModelId()); diff --git a/src/main/java/dev/openfga/sdk/api/client/model/ClientCheckRequest.java b/src/main/java/dev/openfga/sdk/api/client/model/ClientCheckRequest.java index 0b6b5be..5563896 100644 --- a/src/main/java/dev/openfga/sdk/api/client/model/ClientCheckRequest.java +++ b/src/main/java/dev/openfga/sdk/api/client/model/ClientCheckRequest.java @@ -12,6 +12,7 @@ package dev.openfga.sdk.api.client.model; +import dev.openfga.sdk.api.model.CheckRequest; import dev.openfga.sdk.api.model.CheckRequestTupleKey; import java.util.List; @@ -19,10 +20,18 @@ public class ClientCheckRequest { private String user; private String relation; private String _object; + private Object context; private List contextualTuples; - public CheckRequestTupleKey asCheckRequestTupleKey() { - return new CheckRequestTupleKey().user(user).relation(relation)._object(_object); + public CheckRequest asCheckRequest() { + var checkRequest = new CheckRequest() + .tupleKey( + new CheckRequestTupleKey().user(user).relation(relation)._object(_object)) + .context(context); + if (contextualTuples != null && !contextualTuples.isEmpty()) { + checkRequest.contextualTuples(ClientTupleKey.asContextualTupleKeys(contextualTuples)); + } + return checkRequest; } public ClientCheckRequest _object(String _object) { @@ -43,6 +52,19 @@ public ClientCheckRequest relation(String relation) { return this; } + /** + * Get context + * @return context + **/ + public Object getContext() { + return context; + } + + public ClientCheckRequest context(Object context) { + this.context = context; + return this; + } + /** * Get relation * @return relation