Skip to content

Commit

Permalink
Merge pull request #464 from anandrgitnirman/master
Browse files Browse the repository at this point in the history
#463 :Added more detais on userdata stored for easier view
  • Loading branch information
anandrgitnirman authored Mar 9, 2020
2 parents a6c2691 + 85adaa4 commit 990a6d2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
6 changes: 5 additions & 1 deletion escrow/free_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (h *lockingFreeCallUserService) FreeCallUser(key *FreeCallUserKey) (freeCal
return
}
if !ok {
return &FreeCallUserData{FreeCallsMade: 0,UserId:key.UserId}, true, nil
return &FreeCallUserData{FreeCallsMade: 0, UserId: key.UserId, GroupID: key.GroupID, ServiceId: key.ServiceId, OrganizationId: key.OrganizationId}, true, nil
}
return
}
Expand Down Expand Up @@ -69,6 +69,10 @@ func (h *lockingFreeCallUserService) StartFreeCallUserTransaction(payment *FreeC
return nil, NewPaymentError(Internal, "payment freeCallUserKey error:"+err.Error())
}
freeCallUserData, ok, err := h.FreeCallUser(userKey)
//todo , will remove this line once all data is re initialized
freeCallUserData.ServiceId = userKey.ServiceId
freeCallUserData.OrganizationId = userKey.OrganizationId
freeCallUserData.GroupID = userKey.GroupID

if err != nil {
return nil, NewPaymentError(Internal, "payment freeCallUserData error:"+err.Error())
Expand Down
12 changes: 7 additions & 5 deletions escrow/free_call_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type FreeCallPayment struct {
AuthToken []byte
//Token expiration date in blocks
AuthTokenExpiryBlockNumber *big.Int

}

func (key *FreeCallPayment) String() string {
Expand All @@ -44,13 +43,16 @@ func (key *FreeCallUserKey) String() string {
}

type FreeCallUserData struct {
UserId string
FreeCallsMade int
UserId string
FreeCallsMade int
OrganizationId string
ServiceId string
GroupID string
}

func (data *FreeCallUserData) String() string {
return fmt.Sprintf("{User %v has made %v free calls}",data.UserId,
data.FreeCallsMade)
return fmt.Sprintf("{User %v has made %v free calls for org_id=%v, service_id=%v, group_id=%v }", data.UserId,
data.FreeCallsMade, data.OrganizationId, data.ServiceId, data.GroupID)
}

type FreeCallUserService interface {
Expand Down
4 changes: 2 additions & 2 deletions escrow/free_call_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func TestFreeCallUserKey_String(t *testing.T) {
}

func TestFreeCallUserData_String(t *testing.T) {
data := &FreeCallUserData{FreeCallsMade: 10,UserId:"[email protected]"}
data := &FreeCallUserData{FreeCallsMade: 10, UserId: "[email protected]", OrganizationId: "org1", ServiceId: "service1", GroupID: "grp1"}
IncrementFreeCallCount(data)
assert.Equal(t, "{User [email protected] has made 11 free calls}", data.String())
assert.Equal(t, "{User [email protected] has made 11 free calls for org_id=org1, service_id=service1, group_id=grp1 }", data.String())

}
7 changes: 5 additions & 2 deletions escrow/free_call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ type FreeCallServiceSuite struct {

func (suite *FreeCallServiceSuite) FreeCallUserData() *FreeCallUserData {
return &FreeCallUserData{
UserId:"user1",
FreeCallsMade: 11,
UserId: "user1",
FreeCallsMade: 11,
OrganizationId: config.GetString(config.OrganizationId),
ServiceId: config.GetString(config.ServiceId),
GroupID: "ewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
}
}
func (suite *FreeCallServiceSuite) SetupSuite() {
Expand Down

0 comments on commit 990a6d2

Please sign in to comment.