Skip to content

Commit

Permalink
Merge pull request #9 from satimoto/hotfix/v0.3.2
Browse files Browse the repository at this point in the history
v0.3.2
  • Loading branch information
dangeross authored Jan 11, 2023
2 parents 37b9255 + 106005e commit f3fe815
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
12 changes: 8 additions & 4 deletions internal/rpc/command/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
ocpiTokenAuthorization "github.com/satimoto/go-ocpi/pkg/ocpi/tokenauthorization"
)

func (r *RpcCommandResolver) ReserveNow(ctx context.Context, input *ocpirpc.ReserveNowRequest) (*ocpirpc.ReserveNowResponse, error) {
func (r *RpcCommandResolver) ReserveNow(reqCtx context.Context, input *ocpirpc.ReserveNowRequest) (*ocpirpc.ReserveNowResponse, error) {
if input != nil {
ctx := context.Background()
expiryDate := util.ParseTime(input.ExpiryDate, nil)
getTokenByUserIDParams := db.GetTokenByUserIDParams{
UserID: input.UserId,
Expand Down Expand Up @@ -74,8 +75,9 @@ func (r *RpcCommandResolver) ReserveNow(ctx context.Context, input *ocpirpc.Rese
return nil, errors.New("missing request")
}

func (r *RpcCommandResolver) StartSession(ctx context.Context, input *ocpirpc.StartSessionRequest) (*ocpirpc.StartSessionResponse, error) {
func (r *RpcCommandResolver) StartSession(reqCtx context.Context, input *ocpirpc.StartSessionRequest) (*ocpirpc.StartSessionResponse, error) {
if input != nil {
ctx := context.Background()
getTokenByUserIDParams := db.GetTokenByUserIDParams{
UserID: input.UserId,
Type: db.TokenTypeOTHER,
Expand Down Expand Up @@ -154,8 +156,9 @@ func (r *RpcCommandResolver) StartSession(ctx context.Context, input *ocpirpc.St
return nil, errors.New("missing request")
}

func (r *RpcCommandResolver) StopSession(ctx context.Context, input *ocpirpc.StopSessionRequest) (*ocpirpc.StopSessionResponse, error) {
func (r *RpcCommandResolver) StopSession(reqCtx context.Context, input *ocpirpc.StopSessionRequest) (*ocpirpc.StopSessionResponse, error) {
if input != nil {
ctx := context.Background()
defaultResponse := ocpirpc.StopSessionResponse{
Status: string(db.CommandResponseTypeACCEPTED),
AuthorizationId: input.AuthorizationId,
Expand Down Expand Up @@ -222,8 +225,9 @@ func (r *RpcCommandResolver) StopSession(ctx context.Context, input *ocpirpc.Sto
return nil, errors.New("missing request")
}

func (r *RpcCommandResolver) UnlockConnector(ctx context.Context, input *ocpirpc.UnlockConnectorRequest) (*ocpirpc.UnlockConnectorResponse, error) {
func (r *RpcCommandResolver) UnlockConnector(reqCtx context.Context, input *ocpirpc.UnlockConnectorRequest) (*ocpirpc.UnlockConnectorResponse, error) {
if input != nil {
ctx := context.Background()
location, err := r.LocationResolver.Repository.GetLocationByUid(ctx, input.LocationUid)

if err != nil {
Expand Down
12 changes: 8 additions & 4 deletions internal/rpc/credential/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
ocpiCredential "github.com/satimoto/go-ocpi/pkg/ocpi/credential"
)

func (r *RpcCredentialResolver) CreateCredential(ctx context.Context, request *ocpirpc.CreateCredentialRequest) (*ocpirpc.CreateCredentialResponse, error) {
func (r *RpcCredentialResolver) CreateCredential(reqCtx context.Context, request *ocpirpc.CreateCredentialRequest) (*ocpirpc.CreateCredentialResponse, error) {
if request != nil {
ctx := context.Background()
params := ocpiCredential.NewCreateCredentialParams(*request)

if request.BusinessDetail != nil {
Expand All @@ -41,8 +42,9 @@ func (r *RpcCredentialResolver) CreateCredential(ctx context.Context, request *o
return nil, errors.New("Missing request")
}

func (r *RpcCredentialResolver) RegisterCredential(ctx context.Context, request *ocpirpc.RegisterCredentialRequest) (*ocpirpc.RegisterCredentialResponse, error) {
func (r *RpcCredentialResolver) RegisterCredential(reqCtx context.Context, request *ocpirpc.RegisterCredentialRequest) (*ocpirpc.RegisterCredentialResponse, error) {
if request != nil {
ctx := context.Background()
credential, err := r.CredentialResolver.Repository.GetCredential(ctx, request.Id)

if err != nil {
Expand Down Expand Up @@ -71,8 +73,9 @@ func (r *RpcCredentialResolver) RegisterCredential(ctx context.Context, request
return nil, errors.New("Missing request")
}

func (r *RpcCredentialResolver) SyncCredential(ctx context.Context, request *ocpirpc.SyncCredentialRequest) (*ocpirpc.SyncCredentialResponse, error) {
func (r *RpcCredentialResolver) SyncCredential(reqCtx context.Context, request *ocpirpc.SyncCredentialRequest) (*ocpirpc.SyncCredentialResponse, error) {
if request != nil {
ctx := context.Background()
credential, err := r.CredentialResolver.Repository.GetCredential(ctx, request.Id)

if err != nil {
Expand All @@ -99,8 +102,9 @@ func (r *RpcCredentialResolver) SyncCredential(ctx context.Context, request *ocp
return nil, errors.New("Missing request")
}

func (r *RpcCredentialResolver) UnregisterCredential(ctx context.Context, request *ocpirpc.UnregisterCredentialRequest) (*ocpirpc.UnregisterCredentialResponse, error) {
func (r *RpcCredentialResolver) UnregisterCredential(reqCtx context.Context, request *ocpirpc.UnregisterCredentialRequest) (*ocpirpc.UnregisterCredentialResponse, error) {
if request != nil {
ctx := context.Background()
credential, err := r.CredentialResolver.Repository.GetCredential(ctx, request.Id)

if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/rpc/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
"github.com/satimoto/go-ocpi/pkg/ocpi"
)

func (r *RpcResolver) TestConnection(ctx context.Context, input *ocpirpc.TestConnectionRequest) (*ocpirpc.TestConnectionResponse, error) {
func (r *RpcResolver) TestConnection(reqCtx context.Context, input *ocpirpc.TestConnectionRequest) (*ocpirpc.TestConnectionResponse, error) {
if input != nil {
ctx := context.Background()
ocpiService := ocpi.NewService(input.Addr)
message := strconv.FormatInt(time.Now().Unix(), 16)
testMessageReponse, err := ocpiService.TestMessage(ctx, &ocpirpc.TestMessageRequest{
Expand Down
6 changes: 4 additions & 2 deletions internal/rpc/token/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import (
ocpiToken "github.com/satimoto/go-ocpi/pkg/ocpi/token"
)

func (r *RpcTokenResolver) CreateToken(ctx context.Context, request *ocpirpc.CreateTokenRequest) (*ocpirpc.CreateTokenResponse, error) {
func (r *RpcTokenResolver) CreateToken(reqCtx context.Context, request *ocpirpc.CreateTokenRequest) (*ocpirpc.CreateTokenResponse, error) {
if request != nil {
// TODO: Handle if a token is linked by another user
// Should the token be voided for both users?
ctx := context.Background()
tokenDto := NewCreateTokenDto(request)
tokenAllowed := db.TokenAllowedTypeNOCREDIT
authID, err := r.TokenResolver.GenerateAuthID(ctx)
Expand Down Expand Up @@ -65,8 +66,9 @@ func (r *RpcTokenResolver) CreateToken(ctx context.Context, request *ocpirpc.Cre
return nil, errors.New("error creating token")
}

func (r *RpcTokenResolver) UpdateTokens(ctx context.Context, request *ocpirpc.UpdateTokensRequest) (*ocpirpc.UpdateTokensResponse, error) {
func (r *RpcTokenResolver) UpdateTokens(reqCtx context.Context, request *ocpirpc.UpdateTokensRequest) (*ocpirpc.UpdateTokensResponse, error) {
if request != nil {
ctx := context.Background()
tokens, err := r.TokenResolver.Repository.ListTokensByUserID(ctx, request.UserId)

if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/rpc/tokenauthorization/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
"github.com/satimoto/go-ocpi/ocpirpc"
)

func (r *RpcTokenAuthorizationResolver) UpdateTokenAuthorization(ctx context.Context, request *ocpirpc.UpdateTokenAuthorizationRequest) (*ocpirpc.UpdateTokenAuthorizationResponse, error) {
func (r *RpcTokenAuthorizationResolver) UpdateTokenAuthorization(reqCtx context.Context, request *ocpirpc.UpdateTokenAuthorizationRequest) (*ocpirpc.UpdateTokenAuthorizationResponse, error) {
if request != nil {
ctx := context.Background()
tokenAuthorization, err := r.TokenAuthorizationRepository.GetTokenAuthorizationByAuthorizationID(ctx, request.AuthorizationId)

if err != nil {
Expand Down

0 comments on commit f3fe815

Please sign in to comment.