@@ -11,8 +11,8 @@ import (
1111// APIHandler is an interface for encoding, decoding, and implenting contexual api functions for different API implementations.
1212// It encapsulates behavior for encoding and decoding requests and responses.
1313type 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
1616 MarshalRequest (body interface {}, method string , endpoint string , log logger.Logger ) ([]byte , error )
1717 MarshalMultipartRequest (fields map [string ]string , files map [string ]string , log logger.Logger ) ([]byte , string , error )
1818 GetContentTypeHeader (method string , log logger.Logger ) string
@@ -29,22 +29,21 @@ type APIHandler interface {
2929 GetAPIRequestHeaders (endpoint string ) map [string ]string // Provides standard headers required for making API requests.
3030}
3131
32- // Modify the function signature to accept instanceName, tenantID, and tenantName .
32+ // LoadAPIHandler loads the appropriate API handler based on the API type .
3333func LoadAPIHandler (apiType , instanceName , tenantID , tenantName string , log logger.Logger ) (APIHandler , error ) {
3434 var apiHandler APIHandler
3535 switch apiType {
3636 case "jamfpro" :
3737 apiHandler = & jamfpro.JamfAPIHandler {
3838 Logger : log ,
39- InstanceName : instanceName , // Assuming you add InstanceName field to JamfAPIHandler
39+ InstanceName : instanceName , // Used for constructing the resource and auth endpoints
4040 }
4141 log .Info ("Jamf Pro API handler loaded successfully" , zap .String ("APIType" , apiType ), zap .String ("InstanceName" , instanceName ))
4242
4343 case "msgraph" :
4444 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
4847 }
4948 log .Info ("Microsoft Graph API handler loaded successfully" , zap .String ("APIType" , apiType ), zap .String ("TenantID" , tenantID ), zap .String ("TenantName" , tenantName ))
5049
0 commit comments