@@ -11,8 +11,8 @@ import (
11
11
// APIHandler is an interface for encoding, decoding, and implenting contexual api functions for different API implementations.
12
12
// It encapsulates behavior for encoding and decoding requests and responses.
13
13
type APIHandler interface {
14
- ConstructAPIResourceEndpoint (APIResourceEndpointIdentifier string , endpointPath string , log logger.Logger ) string
15
- ConstructAPIAuthEndpoint (APIAuthEndpointIdentifier string , endpointPath string , log logger.Logger ) string
14
+ ConstructAPIResourceEndpoint (endpointPath string , log logger.Logger ) string
15
+ ConstructAPIAuthEndpoint (endpointPath string , log logger.Logger ) string
16
16
MarshalRequest (body interface {}, method string , endpoint string , log logger.Logger ) ([]byte , error )
17
17
MarshalMultipartRequest (fields map [string ]string , files map [string ]string , log logger.Logger ) ([]byte , string , error )
18
18
GetContentTypeHeader (method string , log logger.Logger ) string
@@ -29,22 +29,21 @@ type APIHandler interface {
29
29
GetAPIRequestHeaders (endpoint string ) map [string ]string // Provides standard headers required for making API requests.
30
30
}
31
31
32
- // Modify the function signature to accept instanceName, tenantID, and tenantName .
32
+ // LoadAPIHandler loads the appropriate API handler based on the API type .
33
33
func LoadAPIHandler (apiType , instanceName , tenantID , tenantName string , log logger.Logger ) (APIHandler , error ) {
34
34
var apiHandler APIHandler
35
35
switch apiType {
36
36
case "jamfpro" :
37
37
apiHandler = & jamfpro.JamfAPIHandler {
38
38
Logger : log ,
39
- InstanceName : instanceName , // Assuming you add InstanceName field to JamfAPIHandler
39
+ InstanceName : instanceName , // Used for constructing the resource and auth endpoints
40
40
}
41
41
log .Info ("Jamf Pro API handler loaded successfully" , zap .String ("APIType" , apiType ), zap .String ("InstanceName" , instanceName ))
42
42
43
43
case "msgraph" :
44
44
apiHandler = & msgraph.GraphAPIHandler {
45
- Logger : log ,
46
- TenantID : tenantID , // Assuming you add TenantID field to GraphAPIHandler
47
- TenantName : tenantName , // Assuming you add TenantName field to GraphAPIHandler
45
+ Logger : log ,
46
+ TenantID : tenantID , // Used for constructing the auth endpoint
48
47
}
49
48
log .Info ("Microsoft Graph API handler loaded successfully" , zap .String ("APIType" , apiType ), zap .String ("TenantID" , tenantID ), zap .String ("TenantName" , tenantName ))
50
49
0 commit comments