mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-11 22:23:51 +02:00
feat:#34 refactored function to intended service, fixed docker files
This commit is contained in:
@@ -2,6 +2,7 @@ package connector
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"htwkalender-ical/model"
|
||||
"log/slog"
|
||||
)
|
||||
@@ -77,3 +78,24 @@ func parseModuleResponse(body []byte) (model.Module, error) {
|
||||
|
||||
return module, nil
|
||||
}
|
||||
|
||||
func SaveFeedRecord(modules []model.FeedCollection) (string, error) {
|
||||
var token string
|
||||
|
||||
response, err := PostRequestApi("/api/feed", modules)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if response.StatusCode() != 200 {
|
||||
return "", errors.New("failed to save feed")
|
||||
}
|
||||
|
||||
// parse the response body json to string
|
||||
err = json.Unmarshal(response.Body(), &token)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user