-func (pm *ProviderManager) updateFunctions(updatedProvider provapi.APIProviderEnrolmentDetails, registeredProvider provapi.APIProviderEnrolmentDetails, ctx echo.Context) (bool, error) {
- for _, function := range *updatedProvider.ApiProvFuncs {
- if function.ApiProvFuncId == nil {
- pm.addFunction(function, registeredProvider)
- } else {
- shouldReturn, returnValue := pm.updateFunction(function, registeredProvider, ctx)
- if shouldReturn {
- return true, returnValue
- }
- }
- }
- return false, nil
-}
-
-func (pm *ProviderManager) addFunction(function provapi.APIProviderFunctionDetails, registeredProvider provapi.APIProviderEnrolmentDetails) {
- function.ApiProvFuncId = pm.getFuncId(function.ApiProvFuncRole, function.ApiProvFuncInfo)
- registeredFuncs := *registeredProvider.ApiProvFuncs
- newFuncs := append(registeredFuncs, function)
- registeredProvider.ApiProvFuncs = &newFuncs
- pm.onboardedProviders[*registeredProvider.ApiProvDomId] = registeredProvider
-}
-
-func (*ProviderManager) updateFunction(function provapi.APIProviderFunctionDetails, registeredProvider provapi.APIProviderEnrolmentDetails, ctx echo.Context) (bool, error) {
- pos, registeredFunction, err := getApiFunc(*function.ApiProvFuncId, registeredProvider.ApiProvFuncs)
- if err != nil {
- return true, sendCoreError(ctx, http.StatusBadRequest, "Unable to update provider due to: "+err.Error())
- }
- if function.ApiProvFuncInfo != nil {
- registeredFunction.ApiProvFuncInfo = function.ApiProvFuncInfo
- (*registeredProvider.ApiProvFuncs)[pos] = registeredFunction
- }
- return false, nil
-}
-
-func getApiFunc(funcId string, apiFunctions *[]provapi.APIProviderFunctionDetails) (int, provapi.APIProviderFunctionDetails, error) {
- for pos, function := range *apiFunctions {
- if *function.ApiProvFuncId == funcId {
- return pos, function, nil
- }
- }
- return 0, provapi.APIProviderFunctionDetails{}, fmt.Errorf("function with ID %s is not registered for the provider", funcId)
-}
-
-func (pm *ProviderManager) ModifyIndApiProviderEnrolment(ctx echo.Context, registrationId string) error {
- return ctx.NoContent(http.StatusNotImplemented)
-}
-
-func (pm *ProviderManager) registerFunctions(provFuncs *[]provapi.APIProviderFunctionDetails) {
- if provFuncs == nil {
- return
- }
- for i, provFunc := range *provFuncs {
- (*provFuncs)[i].ApiProvFuncId = pm.getFuncId(provFunc.ApiProvFuncRole, provFunc.ApiProvFuncInfo)
- }
-}
-
-func (pm *ProviderManager) getDomainId(domainInfo *string) *string {
- idAsString := "domain_id_" + strings.ReplaceAll(*domainInfo, " ", "_")
- return &idAsString
-}