Skip to content

Commit

Permalink
Merge pull request #96 from andy89923/fix/charing-oauth2
Browse files Browse the repository at this point in the history
Fix: Add CHF consumer with OAuth2 Token
  • Loading branch information
ianchen0119 authored Mar 6, 2024
2 parents 5aab128 + 0216152 commit c9bd506
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/sbi/consumer/converged_charging.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package consumer

import (
"context"
"fmt"
"net/http"
"strings"
Expand Down Expand Up @@ -83,17 +82,22 @@ func SendConvergedChargingRequest(smContext *smf_context.SMContext, requestType
var httpResponse *http.Response
var err error

ctx, pd, err := smf_context.GetSelf().GetTokenCtx(models.ServiceName_NCHF_CONVERGEDCHARGING, models.NfType_CHF)
if err != nil {
return nil, pd, err
}

// select the appropriate converged charging service based on trigger type
switch requestType {
case smf_context.CHARGING_INIT:
rsp, httpResponse, err = smContext.ChargingClient.DefaultApi.ChargingdataPost(context.Background(), *req)
rsp, httpResponse, err = smContext.ChargingClient.DefaultApi.ChargingdataPost(ctx, *req)
chargingDataRef := strings.Split(httpResponse.Header.Get("Location"), "/")
smContext.ChargingDataRef = chargingDataRef[len(chargingDataRef)-1]
case smf_context.CHARGING_UPDATE:
rsp, httpResponse, err = smContext.ChargingClient.DefaultApi.ChargingdataChargingDataRefUpdatePost(
context.Background(), smContext.ChargingDataRef, *req)
ctx, smContext.ChargingDataRef, *req)
case smf_context.CHARGING_RELEASE:
httpResponse, err = smContext.ChargingClient.DefaultApi.ChargingdataChargingDataRefReleasePost(context.Background(),
httpResponse, err = smContext.ChargingClient.DefaultApi.ChargingdataChargingDataRefReleasePost(ctx,
smContext.ChargingDataRef, *req)
}

Expand Down

0 comments on commit c9bd506

Please sign in to comment.