package services import ( "context" "fmt" "git.dynamicdiscord.de/malobeo/portal/internal" "git.dynamicdiscord.de/malobeo/portal/openapi" "github.com/gin-gonic/gin" "os" ) var ( AccessAuths AccessAuthService = AccessAuthService{} ) type AccessAuthService struct{} func (u *AccessAuthService) GetAll(c *gin.Context) ([]openapi.AccessAuthorizationResponse, error) { apiClient := internal.GetApiClient(c) resp, r, err := apiClient.AccessAuthAPI.GetAllAccessauthsApiV1AaGet(context.Background()).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `AccessAuthAPI.GetAllAccessAuthAaGet``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) return nil, err } fmt.Fprintf(os.Stdout, "Response from `AccessAuthAPI.GetAllAccessAuthAaGet`: %v\n", resp) return resp, nil } func (u *AccessAuthService) Create(c *gin.Context, name string) (*openapi.AccessAuthorizationResponse, error) { accessAuthorizationCreate := *openapi.NewAccessAuthorizationCreate("Name_example", false, []openapi.TimetableCreate{}) apiClient := internal.GetApiClient(c) resp, r, err := apiClient.AccessAuthAPI.AddAccessauthApiV1AaPost(context.Background()).AccessAuthorizationCreate(accessAuthorizationCreate).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `AccessAuthAPI.CreateAccessAuthAccessAuthsPost``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) return nil, err } fmt.Fprintf(os.Stdout, "Response from `AccessAuthAPI.CreateAccessAuthAccessAuthsPost`: %v\n", resp) return resp, nil } func (u *AccessAuthService) SetActive(c *gin.Context, accessAuthId int32, isActive bool) (*openapi.AccessAuthorizationResponse, error) { apiClient := internal.GetApiClient(c) accessAuthorizationUpdate := *openapi.NewAccessAuthorizationUpdate() accessAuthorizationUpdate.IsActive = *openapi.NewNullableBool(&isActive) resp, r, err := apiClient.AccessAuthAPI.ChangeAccessauthApiV1AaAaIdPatch(context.Background(), accessAuthId).AccessAuthorizationUpdate(accessAuthorizationUpdate).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `AccessAuthAPI.ChangeAccessauthAaAaIdPatch``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) return nil, err } fmt.Fprintf(os.Stdout, "Response from `AccessAuthAPI.ChangeAccessauthAaAaIdPatch`: %v\n", resp) return resp, nil } func (u *AccessAuthService) SetName(c *gin.Context, accessAuthId int32, name string) (*openapi.AccessAuthorizationResponse, error) { apiClient := internal.GetApiClient(c) accessAuthorizationUpdate := *openapi.NewAccessAuthorizationUpdate() accessAuthorizationUpdate.Name = *openapi.NewNullableString(&name) resp, r, err := apiClient.AccessAuthAPI.ChangeAccessauthApiV1AaAaIdPatch(context.Background(), accessAuthId).AccessAuthorizationUpdate(accessAuthorizationUpdate).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `AccessAuthAPI.ChangeAccessauthAaAaIdPatch``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) return nil, err } fmt.Fprintf(os.Stdout, "Response from `AccessAuthAPI.ChangeAccessauthAaAaIdPatch`: %v\n", resp) return resp, nil } func (u *AccessAuthService) SetTimetables(c *gin.Context, accessAuthId int32, timetables []openapi.TimetableCreate) (*openapi.AccessAuthorizationResponse, error) { apiClient := internal.GetApiClient(c) accessAuthorizationUpdate := *openapi.NewAccessAuthorizationUpdate() accessAuthorizationUpdate.Timetables = timetables resp, r, err := apiClient.AccessAuthAPI.ChangeAccessauthApiV1AaAaIdPatch(context.Background(), accessAuthId).AccessAuthorizationUpdate(accessAuthorizationUpdate).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `AccessAuthAPI.ChangeAccessauthAaAaIdPatch``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) return nil, err } fmt.Fprintf(os.Stdout, "Response from `AccessAuthAPI.ChangeAccessauthAaAaIdPatch`: %v\n", resp) return resp, nil }