package services import ( "context" "fmt" "git.dynamicdiscord.de/malobeo/portal/internal" "git.dynamicdiscord.de/malobeo/portal/openapi" "os" ) var ( Cards CardService = CardService{} ) type CardService struct{} // return jwt tokenstring on success func (u *CardService) Create(groupId int32) (*openapi.Card, error) { apiClient := internal.GetApiClient() resp, r, err := apiClient.CardAPI.AddCardCardsGroupIdPost(context.Background(), groupId).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `CardAPI.CreateCardCardsPost``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) return nil, err } // response from `LoginForAccessTokenTokenPost`: Token fmt.Fprintf(os.Stdout, "Response from `CardAPI.CreateCardCardsPost`: %v\n", resp) return resp, nil } func (u *CardService) GetCardsByGroup(groupId int32) ([]openapi.Card, error) { apiClient := internal.GetApiClient() resp, r, err := apiClient.CardAPI.GetCardsCardsGroupIdGet(context.Background(), groupId).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `CardAPI.GetCardsCardsGet``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) return nil, err } // response from `LoginForAccessTokenTokenPost`: Token fmt.Fprintf(os.Stdout, "Response from `CardAPI.GetCardsCardsGet`: %v\n", resp) return resp, nil }