diff --git a/extensions/armatak/util.go b/extensions/armatak/util.go index c36f70f..269d38c 100644 --- a/extensions/armatak/util.go +++ b/extensions/armatak/util.go @@ -77,3 +77,43 @@ func postRequest(route string, body any) (string, error) { return string(parsedBody), nil } + +func putRequest(route string, body any) (string, error) { + jsonData, err := json.Marshal(body) + if err != nil { + fmt.Println("Error marshalling payload:", err) + return "", err + } + + client := &http.Client{} + + req, err := http.NewRequest(http.MethodPut, route, bytes.NewReader(jsonData)) + if err != nil { + fmt.Println("Error creating request:", err) + return "", err + } + + req.Header.Set("Content-Type", "application/json") + + req.Header.Set("Authorization", "Bearer token") + + resp, err := client.Do(req) + if err != nil { + fmt.Println("Error sending request:", err) + return "", err + } + + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + fmt.Println("Error sending request:", resp.Status) + return "", nil + } + + parsedBody, err := io.ReadAll(resp.Body) + if err != nil { + return "", fmt.Errorf("getting Error reading response body: %w", err) + } + + return string(parsedBody), nil +}