This commit is contained in:
2026-01-01 15:49:49 +01:00
parent 8c289622e1
commit 85567d87b7
8 changed files with 29 additions and 26 deletions

View File

@@ -19,16 +19,16 @@ import json
from typing import Optional
from pydantic import BaseModel, StrictStr
from pydantic import BaseModel, Field, StrictStr
class ClientDto(BaseModel):
"""
ClientDto
"""
name: Optional[StrictStr] = None
company_name: Optional[StrictStr] = Field(None, alias="companyName")
username: Optional[StrictStr] = None
key: Optional[StrictStr] = None
__properties = ["name", "username", "key"]
__properties = ["companyName", "username", "key"]
class Config:
"""Pydantic configuration"""
@@ -66,7 +66,7 @@ class ClientDto(BaseModel):
return ClientDto.parse_obj(obj)
_obj = ClientDto.parse_obj({
"name": obj.get("name"),
"company_name": obj.get("companyName"),
"username": obj.get("username"),
"key": obj.get("key")
})

View File

@@ -4,7 +4,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
**company_name** | **str** | | [optional]
**username** | **str** | | [optional]
**key** | **str** | | [optional]

View File

@@ -36,7 +36,7 @@ class TestClientDto(unittest.TestCase):
model = ClientDto() # noqa: E501
if include_optional:
return ClientDto(
name = '',
company_name = '',
username = '',
key = ''
)

View File

@@ -44,7 +44,7 @@ components:
ClientDto:
type: "object"
properties:
name:
companyName:
type: "string"
nullable: true
username:

View File

@@ -19,6 +19,7 @@ class AuthController:
auth_api = AuthApi(client)
auth_request = AuthRequestDto(
username=StrictStr(received_data["username"]),
username=StrictStr(received_data["username"]),
key=StrictStr(received_data["key"]),
)

View File

@@ -1,5 +1,5 @@
from board_mate.client import Configuration, ApiClient, ClientApi, ClientDto, ApiException
from flask import jsonify
from flask import jsonify, request
from pydantic import StrictStr
@@ -13,21 +13,25 @@ class GameController:
app.add_url_rule("/client/create", view_func=self.create, methods=['POST'])
def create(self):
with ApiClient(self.config) as api_client:
client_api = ClientApi(api_client)
try:
with ApiClient(self.config) as api_client:
request_data = request.get_json()
new_client = ClientDto(
name=StrictStr("Alice Example"),
username=StrictStr("alice123"),
)
client_api = ClientApi(api_client)
new_client = ClientDto(
companyName=StrictStr(request_data["companyName"]),
username=StrictStr(request_data["username"]),
key=StrictStr(request_data["key"]),
)
try:
response = client_api.create(client_dto=new_client)
print("Success:", response.success)
print("Message:", response.message)
print("Data:", response.data)
return jsonify(response), 200
except ApiException as e:
print(f"Exception when calling ClientApi->create: {e}")
return jsonify(response), 500
except ApiException as e:
print(f"Exception when calling ClientApi->create: {e}")
return jsonify(response), 500

View File

@@ -1,7 +1,5 @@
package be.naaturel.boardmateapi.controllers;
import be.naaturel.boardmateapi.controllers.dtos.AuthRequestDto;
import be.naaturel.boardmateapi.controllers.dtos.AuthResponseDto;
import be.naaturel.boardmateapi.controllers.dtos.ClientDto;
import be.naaturel.boardmateapi.controllers.dtos.ResponseBody;
import be.naaturel.boardmateapi.services.ClientService;
@@ -27,7 +25,7 @@ public class ClientController {
public ResponseEntity<ResponseBody<String>> create(@RequestBody ClientDto dto) {
ResponseBody<String> result = ResponseBody.createEmpty();
try{
String clientId = service.create(dto.getName(), dto.getUsername(), dto.getKey());
String clientId = service.create(dto.getCompanyName(), dto.getUsername(), dto.getKey());
result.setData(clientId);
return ResponseEntity.
status(HttpStatus.OK)

View File

@@ -2,16 +2,16 @@ package be.naaturel.boardmateapi.controllers.dtos;
public class ClientDto {
private String name;
private String companyName;
private String username;
private String key;
public String getName() {
return name;
public String getCompanyName() {
return companyName;
}
public void setName(String name) {
this.name = name;
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getUsername() {