Skip to content

Commit 58af27f

Browse files
authored
Merge pull request #479 from deploymenttheory/bugfix-computerprestages
bug fix for accept function
2 parents 3c0a045 + 41fab5b commit 58af27f

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

examples/jamf_app_catalog_app_installers/AcceptJamfAppCatalogAppInstallerTermsAndConditions/AcceptJamfAppCatalogAppInstallerTermsAndConditions.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"log"
67

@@ -18,10 +19,15 @@ func main() {
1819
}
1920

2021
// Accept the terms and conditions
21-
err = client.AcceptJamfAppCatalogAppInstallerTermsAndConditions()
22+
status, err := client.AcceptJamfAppCatalogAppInstallerTermsAndConditions()
2223
if err != nil {
23-
log.Fatalf("Error: %v", err)
24+
log.Fatalf("Error fetching Terms And Conditions Status: %v", err)
2425
}
2526

26-
fmt.Println("Successfully accepted Jamf App Catalog App Installer terms and conditions.")
27+
// Pretty print the fetched Terms And Conditions Status using JSON marshaling
28+
statusJSON, err := json.MarshalIndent(status, "", " ") // Indent with 4 spaces
29+
if err != nil {
30+
log.Fatalf("Error marshaling Terms And Conditions Status data: %v", err)
31+
}
32+
fmt.Println("Fetched Terms And Conditions Status:", string(statusJSON))
2733
}

sdk/jamfpro/jamfproapi_app_installers.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,20 @@ func (c *Client) GetJamfAppCatalogAppInstallerTermsAndConditionsStatus() (*Respo
133133

134134
// AcceptJamfAppCatalogAppInstallerTermsAndConditions accepts the terms and conditions for the Jamf App Catalog
135135
// This is required on an account by account basis.
136-
func (c *Client) AcceptJamfAppCatalogAppInstallerTermsAndConditions() error {
137-
endpoint := fmt.Sprintf("%s/terms-and-conditions", uriJamfAppCatalogAppInstaller)
136+
func (c *Client) AcceptJamfAppCatalogAppInstallerTermsAndConditions() (*ResponseJamfAppCatalogDeploymentTermsAndConditionsStatus, error) {
137+
endpoint := fmt.Sprintf("%s/terms-and-conditions/accept", uriJamfAppCatalogAppInstaller)
138138

139-
resp, err := c.HTTP.DoRequest("POST", endpoint, nil, nil)
139+
var globalSettings ResponseJamfAppCatalogDeploymentTermsAndConditionsStatus
140+
resp, err := c.HTTP.DoRequest("POST", endpoint, nil, &globalSettings)
140141
if err != nil {
141-
return fmt.Errorf("failed to accept terms and conditions: %v", err)
142+
return nil, fmt.Errorf(errMsgFailedGet, "printers", err)
142143
}
143144

144145
if resp != nil && resp.Body != nil {
145146
defer resp.Body.Close()
146147
}
147148

148-
return nil
149+
return &globalSettings, nil
149150
}
150151

151152
// Gets full list of Get Jamf App Catalog App Installer Titles & handles pagination

0 commit comments

Comments
 (0)