diff --git a/escrow/free_call.go b/escrow/free_call.go index 5b7b723d..a37d80b0 100644 --- a/escrow/free_call.go +++ b/escrow/free_call.go @@ -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 } @@ -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()) diff --git a/escrow/free_call_api.go b/escrow/free_call_api.go index 4dcde088..247d67fa 100644 --- a/escrow/free_call_api.go +++ b/escrow/free_call_api.go @@ -23,7 +23,6 @@ type FreeCallPayment struct { AuthToken []byte //Token expiration date in blocks AuthTokenExpiryBlockNumber *big.Int - } func (key *FreeCallPayment) String() string { @@ -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 { diff --git a/escrow/free_call_api_test.go b/escrow/free_call_api_test.go index 67285ef6..188fc5f0 100644 --- a/escrow/free_call_api_test.go +++ b/escrow/free_call_api_test.go @@ -11,8 +11,8 @@ func TestFreeCallUserKey_String(t *testing.T) { } func TestFreeCallUserData_String(t *testing.T) { - data := &FreeCallUserData{FreeCallsMade: 10,UserId:"abc@test.com"} + data := &FreeCallUserData{FreeCallsMade: 10, UserId: "abc@test.com", OrganizationId: "org1", ServiceId: "service1", GroupID: "grp1"} IncrementFreeCallCount(data) - assert.Equal(t, "{User abc@test.com has made 11 free calls}", data.String()) + assert.Equal(t, "{User abc@test.com has made 11 free calls for org_id=org1, service_id=service1, group_id=grp1 }", data.String()) } diff --git a/escrow/free_call_test.go b/escrow/free_call_test.go index e57380b7..078041e1 100644 --- a/escrow/free_call_test.go +++ b/escrow/free_call_test.go @@ -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() {