Result T
using djgorunmez.framework package on Nuget.DGS API
Controller:
DgsController — Base route: /api/dgsReturns:
Result<T> wrapper — state/message/dataGET — Configurations
GET — Session
POST — Login
POST — Create session
POST — Get document
GET /api/dgs/GetAllConfigurations?userToken={userToken}
Returns
Result<List<Configuration>>Supply userToken as a query parameter. Example shows how to call and parse the wrapper result.
curl -s "https://your-host/api/dgs?userToken=YOUR_USER_TOKEN"
fetch(`/api/dgs?userToken=${encodeURIComponent(token)}`)
.then(r => r.json())
.then(result => console.log(result));
using var client = new HttpClient();
var res = await client.GetAsync($"https://localhost:5001/api/dgs?userToken={token}");
var json = await res.Content.ReadAsStringAsync();
// deserialize to Result<List<Configuration>>
{
"state": "Success",
"message": "",
"data": [ { "id": 1, "name": "Default", "items": [] } ]
}
POST /api/dgs/Login — Login
Body:
LoginRequest { Username, Password }POST JSON body. Controller selects the correct POST action based on model binding — consider adding explicit routes in server code for clarity.
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"alice","password":"s3cret"}' \
https://your-host/api/dgs
fetch('/api/dgs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: 'alice', password: 's3cret' })
}).then(r => r.json()).then(console.log);
var login = new { username = "alice", password = "s3cret" };
using var client = new HttpClient();
var content = new StringContent(JsonConvert.SerializeObject(login), Encoding.UTF8, "application/json");
var res = await client.PostAsync("https://localhost:5001/api/dgs", content);
var json = await res.Content.ReadAsStringAsync();
{
"state": "Success",
"message": "Login succeeded",
"data": { "id": 5, "username": "alice", "token": "USER_TOKEN" }
}
POST /api/dgs/CreateSession — Create session
Body:
CreateSessionRequest { UserToken, ConfigurationId }Creates a session for the authenticated user. Return value is Result<Session>.
curl -X POST -H "Content-Type: application/json" \
-d '{"userToken":"USER_TOKEN","configurationId":123}' \
https://your-host/api/dgs
fetch('/api/dgs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userToken: 'USER_TOKEN', configurationId: 123 })
}).then(r => r.json()).then(console.log);
var body = new { userToken = "USER_TOKEN", configurationId = 123 };
using var client = new HttpClient();
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
var res = await client.PostAsync("https://localhost:5001/api/dgs", content);
var json = await res.Content.ReadAsStringAsync();
{
"state": "Success",
"message": "",
"data": { "id": 10, "token": "SESSION_TOKEN", "percentageCompleted": 0 }
}
POST /api/dgs/GetDocument — Get document
Body:
GetDocumentRequest { UserToken, SessionToken }Returns the first document associated to the session if tokens are valid.
curl -X POST -H "Content-Type: application/json" \
-d '{"userToken":"USER_TOKEN","sessionToken":"SESSION_TOKEN"}' \
https://your-host/api/dgs
fetch('/api/dgs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userToken: 'USER_TOKEN', sessionToken: 'SESSION_TOKEN' })
}).then(r => r.json()).then(console.log);
var body = new { userToken = "USER_TOKEN", sessionToken = "SESSION_TOKEN" };
using var client = new HttpClient();
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
var res = await client.PostAsync("https://localhost:5001/api/dgs", content);
var json = await res.Content.ReadAsStringAsync();
{
"state": "Success",
"message": "Get the document succeeded.",
"data": { "id": 42, "content": "..." }
}
GET /api/dgs/GetSession?sessionToken={sessionToken}
Returns
Result<Session>Fetch details of a session by sessionToken. This new endpoint returns the stored session information and progress.
curl -s "https://your-host/api/dgs/session?sessionToken=SESSION_TOKEN"
fetch(`/api/dgs/session?sessionToken=${encodeURIComponent(token)}`)
.then(r => r.json())
.then(result => console.log(result));
using var client = new HttpClient();
var res = await client.GetAsync($"https://localhost:5001/api/dgs/session?sessionToken={token}");
var json = await res.Content.ReadAsStringAsync();
// deserialize to Result<Session>
{
"state": "Success",
"message": "",
"data": { "id": 10, "token": "SESSION_TOKEN", "percentageCompleted": 25, "store": "{...}" }
}