package http

import (
	"bytes"
	"context"
	"encoding/json"
	"hyapp/services/gateway-service/internal/transport/http/httpkit"
	"net/http"
	"net/http/httptest"
	"testing"

	activityv1 "hyapp.local/api/proto/activity/v1"
	userv1 "hyapp.local/api/proto/user/v1"
	walletv1 "hyapp.local/api/proto/wallet/v1"
	"hyapp/services/gateway-service/internal/auth"
)

func newManagerCenterTestRouter(walletClient *fakeWalletClient, hostClient *fakeUserHostClient, profileClient *fakeUserProfileClient) http.Handler {
	handler := NewHandlerWithClients(&fakeRoomClient{}, nil, nil, profileClient)
	handler.SetWalletClient(walletClient)
	handler.SetUserHostClient(hostClient)
	return handler.Routes(auth.NewVerifier("secret"))
}

func newManagerCenterTestRouterWithHostAdmin(walletClient *fakeWalletClient, hostClient *fakeUserHostClient, hostAdminClient *fakeUserHostAdminClient, profileClient *fakeUserProfileClient) http.Handler {
	handler := NewHandlerWithClients(&fakeRoomClient{}, nil, nil, profileClient)
	handler.SetWalletClient(walletClient)
	handler.SetUserHostClient(hostClient)
	handler.SetUserHostAdminClient(hostAdminClient)
	return handler.Routes(auth.NewVerifier("secret"))
}

func newManagerCenterTestRouterWithGrowth(walletClient *fakeWalletClient, hostClient *fakeUserHostClient, profileClient *fakeUserProfileClient, growthClient *fakeGrowthLevelClient) http.Handler {
	handler := NewHandlerWithClients(&fakeRoomClient{}, nil, nil, profileClient)
	handler.SetWalletClient(walletClient)
	handler.SetUserHostClient(hostClient)
	handler.SetGrowthLevelClient(growthClient)
	return handler.Routes(auth.NewVerifier("secret"))
}

func TestListManagerGrantResourcesChecksCapabilityAndFiltersWalletRequest(t *testing.T) {
	walletClient := &fakeWalletClient{
		listResourcesResp: &walletv1.ListResourcesResponse{
			Total: 1,
			Resources: []*walletv1.Resource{
				{
					ResourceId:        101,
					ResourceType:      "badge",
					Name:              "VIP Badge",
					AssetUrl:          "https://cdn.example/badge.png",
					PreviewUrl:        "https://cdn.example/badge-preview.png",
					WalletAssetType:   "",
					WalletAssetAmount: 0,
					SortOrder:         7,
				},
			},
		},
	}
	hostClient := &fakeUserHostClient{}
	router := newManagerCenterTestRouter(walletClient, hostClient, &fakeUserProfileClient{})
	request := httptest.NewRequest(http.MethodGet, "/api/v1/manager-center/resource-grants/resources?resource_type=badge&page=2&page_size=99", nil)
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-resources")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	if hostClient.lastCapability == nil || hostClient.lastCapability.GetActorUserId() != 42 || hostClient.lastCapability.GetCapability() != "manager_resource_grant" {
		t.Fatalf("manager capability request mismatch: %+v", hostClient.lastCapability)
	}
	if walletClient.lastListResources == nil {
		t.Fatal("wallet ListResources was not called")
	}
	generatedRequestID := assertGeneratedRequestID(t, recorder, "req-manager-resources")
	if req := walletClient.lastListResources; req.GetRequestId() != generatedRequestID || req.GetAppCode() != "lalu" || req.GetResourceType() != "badge" || req.GetPage() != 2 || req.GetPageSize() != 20 || !req.GetActiveOnly() || !req.GetManagerGrantOnly() {
		t.Fatalf("wallet ListResources request mismatch: %+v", req)
	}

	var envelope struct {
		Code      string `json:"code"`
		RequestID string `json:"request_id"`
		Data      struct {
			Items []struct {
				ResourceID string `json:"resource_id"`
				Name       string `json:"name"`
			} `json:"items"`
			Total    int64 `json:"total"`
			Page     int32 `json:"page"`
			PageSize int32 `json:"page_size"`
		} `json:"data"`
	}
	if err := json.NewDecoder(recorder.Body).Decode(&envelope); err != nil {
		t.Fatalf("decode response failed: %v", err)
	}
	if envelope.Code != httpkit.CodeOK || envelope.RequestID != generatedRequestID || envelope.Data.Total != 1 || len(envelope.Data.Items) != 1 {
		t.Fatalf("response envelope mismatch: %+v", envelope)
	}
	if envelope.Data.Items[0].ResourceID != "101" || envelope.Data.Items[0].Name != "VIP Badge" {
		t.Fatalf("resource data mismatch: %+v", envelope.Data.Items[0])
	}
}

func TestListManagerGrantResourcesRejectsUnauthorizedManager(t *testing.T) {
	walletClient := &fakeWalletClient{}
	hostClient := &fakeUserHostClient{capabilityResp: &userv1.CheckBusinessCapabilityResponse{Allowed: false, Reason: "active_agency_owner_required"}}
	router := newManagerCenterTestRouter(walletClient, hostClient, &fakeUserProfileClient{})
	request := httptest.NewRequest(http.MethodGet, "/api/v1/manager-center/resource-grants/resources", nil)
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-denied")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	assertEnvelope(t, recorder, http.StatusForbidden, httpkit.CodePermissionDenied, "req-manager-denied")
	if walletClient.lastListResources != nil {
		t.Fatalf("unauthorized manager must not reach wallet-service: %+v", walletClient.lastListResources)
	}
}

func TestBusinessUserLookupForwardsSceneAndActor(t *testing.T) {
	profileClient := &fakeUserProfileClient{
		businessLookupResp: &userv1.BusinessUserLookupResponse{
			Users: []*userv1.BusinessUserLookupItem{
				{UserId: 900001, DisplayUserId: "123456", Username: "Alice", Avatar: "https://cdn.example/a.png", Status: userv1.UserStatus_USER_STATUS_ACTIVE, RegionId: 1001, RegionCode: "SA", RegionName: "Saudi Arabia"},
			},
		},
	}
	router := newManagerCenterTestRouter(&fakeWalletClient{}, &fakeUserHostClient{}, profileClient)
	request := httptest.NewRequest(http.MethodGet, "/api/v1/business/users/lookup?scene=manager_resource_grant&keyword=123456&page_size=99", nil)
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-business-lookup")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	if req := profileClient.lastBusinessLookup; req == nil || req.GetMeta().GetRequestId() != assertGeneratedRequestID(t, recorder, "req-business-lookup") || req.GetActorUserId() != 42 || req.GetScene() != "manager_resource_grant" || req.GetKeyword() != "123456" || req.GetPageSize() != 20 {
		t.Fatalf("business lookup request mismatch: %+v", req)
	}
	var envelope struct {
		Code string `json:"code"`
		Data struct {
			Items []struct {
				UserID string `json:"user_id"`
				Status string `json:"status"`
			} `json:"items"`
			Total int `json:"total"`
		} `json:"data"`
	}
	if err := json.NewDecoder(recorder.Body).Decode(&envelope); err != nil {
		t.Fatalf("decode response failed: %v", err)
	}
	if envelope.Code != httpkit.CodeOK || envelope.Data.Total != 1 || envelope.Data.Items[0].UserID != "900001" || envelope.Data.Items[0].Status != "active" {
		t.Fatalf("business lookup response mismatch: %+v", envelope)
	}
}

func TestGrantManagerResourceUsesServerControlledGrantShape(t *testing.T) {
	walletClient := &fakeWalletClient{}
	hostClient := &fakeUserHostClient{}
	profileClient := &fakeUserProfileClient{}
	router := newManagerCenterTestRouter(walletClient, hostClient, profileClient)
	body := []byte(`{"command_id":"mgr-grant-1","target_user_id":"900001","resource_id":"101"}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/resource-grants", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-grant")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	if hostClient.lastCapability == nil || hostClient.lastCapability.GetActorUserId() != 42 {
		t.Fatalf("manager capability request mismatch: %+v", hostClient.lastCapability)
	}
	if profileClient.lastGet == nil || profileClient.lastGet.GetUserId() != 900001 {
		t.Fatalf("target user lookup mismatch: %+v", profileClient.lastGet)
	}
	if req := walletClient.lastGrantResource; req == nil || req.GetCommandId() != "mgr-grant-1" || req.GetTargetUserId() != 900001 || req.GetResourceId() != 101 || req.GetQuantity() != 1 || req.GetDurationMs() != 604800000 || req.GetOperatorUserId() != 42 || req.GetGrantSource() != "manager_center" || req.GetReason() != "manager_center" {
		t.Fatalf("wallet GrantResource request mismatch: %+v", req)
	}
}

func TestGrantManagerResourceAllowsConfiguredDuration(t *testing.T) {
	walletClient := &fakeWalletClient{}
	router := newManagerCenterTestRouter(walletClient, &fakeUserHostClient{}, &fakeUserProfileClient{})
	body := []byte(`{"command_id":"mgr-grant-30","target_user_id":"900001","resource_id":"101","duration_ms":2592000000}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/resource-grants", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-grant-duration")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	if req := walletClient.lastGrantResource; req == nil || req.GetDurationMs() != 2592000000 {
		t.Fatalf("manager grant duration was not forwarded: %+v", req)
	}
}

func TestGrantManagerResourceRejectsClientComputedQuantityOrInvalidDuration(t *testing.T) {
	walletClient := &fakeWalletClient{}
	router := newManagerCenterTestRouter(walletClient, &fakeUserHostClient{}, &fakeUserProfileClient{})
	cases := []struct {
		name string
		body string
	}{
		{name: "quantity", body: `{"command_id":"mgr-grant-1","target_user_id":"900001","resource_id":"101","quantity":9}`},
		{name: "duration", body: `{"command_id":"mgr-grant-1","target_user_id":"900001","resource_id":"101","duration_ms":86400000}`},
	}
	for _, tc := range cases {
		t.Run(tc.name, func(t *testing.T) {
			walletClient.lastGrantResource = nil
			request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/resource-grants", bytes.NewReader([]byte(tc.body)))
			request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
			request.Header.Set("X-Request-ID", "req-manager-grant-shape")
			recorder := httptest.NewRecorder()

			router.ServeHTTP(recorder, request)

			assertEnvelope(t, recorder, http.StatusBadRequest, httpkit.CodeInvalidArgument, "req-manager-grant-shape")
			if walletClient.lastGrantResource != nil {
				t.Fatalf("client computed grant shape must not reach wallet-service: %+v", walletClient.lastGrantResource)
			}
		})
	}
}

func TestGrantManagerResourceRejectsCrossCountryTarget(t *testing.T) {
	walletClient := &fakeWalletClient{}
	profileClient := &fakeUserProfileClient{
		usersByID: map[int64]*userv1.User{
			42:     {UserId: 42, Status: userv1.UserStatus_USER_STATUS_ACTIVE, Country: "US"},
			900001: {UserId: 900001, Status: userv1.UserStatus_USER_STATUS_ACTIVE, Country: "CA"},
		},
	}
	router := newManagerCenterTestRouter(walletClient, &fakeUserHostClient{}, profileClient)
	body := []byte(`{"command_id":"mgr-grant-cross","target_user_id":"900001","resource_id":"101"}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/resource-grants", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-cross-country")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	assertEnvelope(t, recorder, http.StatusForbidden, httpkit.CodePermissionDenied, "req-manager-cross-country")
	if walletClient.lastGrantResource != nil {
		t.Fatalf("cross-country target must not reach wallet-service: %+v", walletClient.lastGrantResource)
	}
}

func TestGrantManagerVIPLimitsToVipOneToThree(t *testing.T) {
	walletClient := &fakeWalletClient{}
	router := newManagerCenterTestRouter(walletClient, &fakeUserHostClient{}, &fakeUserProfileClient{})
	body := []byte(`{"command_id":"mgr-vip-4","target_user_id":"900001","level":4}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/vip-grants", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-vip4")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	assertEnvelope(t, recorder, http.StatusBadRequest, httpkit.CodeInvalidArgument, "req-manager-vip4")
	if walletClient.lastGrantVip != nil {
		t.Fatalf("VIP4 must not reach wallet-service: %+v", walletClient.lastGrantVip)
	}
}

func TestGrantManagerVIPUsesManagerCenterGrantSource(t *testing.T) {
	walletClient := &fakeWalletClient{}
	router := newManagerCenterTestRouter(walletClient, &fakeUserHostClient{}, &fakeUserProfileClient{})
	body := []byte(`{"command_id":"mgr-vip-3","target_user_id":"900001","level":3}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/vip-grants", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-vip3")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	if req := walletClient.lastGrantVip; req == nil || req.GetCommandId() != "mgr-vip-3" || req.GetTargetUserId() != 900001 || req.GetLevel() != 3 || req.GetGrantSource() != "manager_center" || req.GetOperatorUserId() != 42 {
		t.Fatalf("wallet GrantVip request mismatch: %+v", req)
	}
}

func TestManagerBlockAndUnblockCallUserService(t *testing.T) {
	profileClient := &fakeUserProfileClient{}
	router := newManagerCenterTestRouter(&fakeWalletClient{}, &fakeUserHostClient{}, profileClient)
	body := []byte(`{"command_id":"block-163006","target_user_id":"900001","blocked_until_ms":1780000000000}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/blocks", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-block")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	if req := profileClient.lastCreateBlock; req == nil || req.GetCommandId() != "block-163006" || req.GetManagerUserId() != 42 || req.GetTargetUserId() != 900001 || req.GetBlockedUntilMs() != 1780000000000 {
		t.Fatalf("CreateManagerUserBlock request mismatch: %+v", req)
	}

	unblockReq := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/blocks/block-1/unblock", nil)
	unblockReq.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	unblockReq.Header.Set("X-Request-ID", "req-manager-unblock")
	unblockRecorder := httptest.NewRecorder()

	router.ServeHTTP(unblockRecorder, unblockReq)

	if unblockRecorder.Code != http.StatusOK {
		t.Fatalf("unblock status mismatch: got %d body=%s", unblockRecorder.Code, unblockRecorder.Body.String())
	}
	if req := profileClient.lastUnblock; req == nil || req.GetManagerUserId() != 42 || req.GetBlockId() != "block-1" {
		t.Fatalf("UnblockManagerUser request mismatch: %+v", req)
	}
}

func TestSetManagerUserLevelCallsGrowthService(t *testing.T) {
	growthClient := &fakeGrowthLevelClient{}
	router := newManagerCenterTestRouterWithGrowth(&fakeWalletClient{}, &fakeUserHostClient{}, &fakeUserProfileClient{}, growthClient)
	body := []byte(`{"command_id":"level-wealth-5","target_user_id":"900001","track":"wealth","level":5}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/levels", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-level")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	if req := growthClient.lastSet; req == nil || req.GetCommandId() != "level-wealth-5" || req.GetUserId() != 900001 || req.GetTrack() != "wealth" || req.GetLevel() != 5 || req.GetOperatorUserId() != 42 {
		t.Fatalf("SetUserLevel request mismatch: %+v", req)
	}
}

func TestCreateManagerBDLeaderCallsHostAdminAfterSameCountryCheck(t *testing.T) {
	hostAdminClient := &fakeUserHostAdminClient{}
	profileClient := &fakeUserProfileClient{usersByID: map[int64]*userv1.User{
		42:     {UserId: 42, Status: userv1.UserStatus_USER_STATUS_ACTIVE, DisplayUserId: "420001", Username: "manager", Country: "US", RegionId: 1001},
		900001: {UserId: 900001, Status: userv1.UserStatus_USER_STATUS_ACTIVE, DisplayUserId: "163006", Username: "target", Country: "US", RegionId: 1001},
	}}
	router := newManagerCenterTestRouterWithHostAdmin(&fakeWalletClient{}, &fakeUserHostClient{}, hostAdminClient, profileClient)
	body := []byte(`{"command_id":"mgr-bdleader-1","target_user_id":"900001"}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/bd-leaders", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-bdleader")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	if recorder.Code != http.StatusOK {
		t.Fatalf("status mismatch: got %d body=%s", recorder.Code, recorder.Body.String())
	}
	generatedRequestID := assertGeneratedRequestID(t, recorder, "req-manager-bdleader")
	if req := hostAdminClient.lastCreateBDLeader; req == nil || req.GetMeta().GetRequestId() != generatedRequestID || req.GetAdminUserId() != 42 || req.GetTargetUserId() != 900001 || req.GetCommandId() != "mgr-bdleader-1" || req.GetReason() != "manager_center" {
		t.Fatalf("CreateBDLeader request mismatch: %+v", req)
	}

	var envelope struct {
		Code string `json:"code"`
		Data struct {
			BDProfile struct {
				UserID          string `json:"user_id"`
				Role            string `json:"role"`
				CreatedByUserID string `json:"created_by_user_id"`
			} `json:"bd_profile"`
			TargetUser struct {
				UserID        string `json:"user_id"`
				DisplayUserID string `json:"display_user_id"`
			} `json:"target_user"`
		} `json:"data"`
	}
	if err := json.NewDecoder(recorder.Body).Decode(&envelope); err != nil {
		t.Fatalf("decode response failed: %v", err)
	}
	if envelope.Code != httpkit.CodeOK || envelope.Data.BDProfile.UserID != "900001" || envelope.Data.BDProfile.Role != "bd_leader" || envelope.Data.BDProfile.CreatedByUserID != "42" || envelope.Data.TargetUser.DisplayUserID != "163006" {
		t.Fatalf("CreateBDLeader response mismatch: %+v", envelope)
	}
}

func TestCreateManagerBDLeaderRejectsCrossCountryTarget(t *testing.T) {
	hostAdminClient := &fakeUserHostAdminClient{}
	profileClient := &fakeUserProfileClient{usersByID: map[int64]*userv1.User{
		42:     {UserId: 42, Status: userv1.UserStatus_USER_STATUS_ACTIVE, Country: "US", RegionId: 1001},
		900001: {UserId: 900001, Status: userv1.UserStatus_USER_STATUS_ACTIVE, Country: "CA", RegionId: 2002},
	}}
	router := newManagerCenterTestRouterWithHostAdmin(&fakeWalletClient{}, &fakeUserHostClient{}, hostAdminClient, profileClient)
	body := []byte(`{"command_id":"mgr-bdleader-cross","target_user_id":"900001"}`)
	request := httptest.NewRequest(http.MethodPost, "/api/v1/manager-center/bd-leaders", bytes.NewReader(body))
	request.Header.Set("Authorization", "Bearer "+signGatewayToken(t, "secret", 42))
	request.Header.Set("X-Request-ID", "req-manager-bdleader-cross")
	recorder := httptest.NewRecorder()

	router.ServeHTTP(recorder, request)

	assertEnvelope(t, recorder, http.StatusForbidden, httpkit.CodePermissionDenied, "req-manager-bdleader-cross")
	if hostAdminClient.lastCreateBDLeader != nil {
		t.Fatalf("cross-country target must not reach CreateBDLeader: %+v", hostAdminClient.lastCreateBDLeader)
	}
}

type fakeGrowthLevelClient struct {
	lastSet *activityv1.SetUserLevelRequest
}

func (f *fakeGrowthLevelClient) GetMyLevelOverview(context.Context, *activityv1.GetMyLevelOverviewRequest) (*activityv1.GetMyLevelOverviewResponse, error) {
	return &activityv1.GetMyLevelOverviewResponse{}, nil
}

func (f *fakeGrowthLevelClient) GetLevelTrack(context.Context, *activityv1.GetLevelTrackRequest) (*activityv1.GetLevelTrackResponse, error) {
	return &activityv1.GetLevelTrackResponse{}, nil
}

func (f *fakeGrowthLevelClient) BatchGetUserLevelDisplayProfiles(context.Context, *activityv1.BatchGetUserLevelDisplayProfilesRequest) (*activityv1.BatchGetUserLevelDisplayProfilesResponse, error) {
	return &activityv1.BatchGetUserLevelDisplayProfilesResponse{}, nil
}

func (f *fakeGrowthLevelClient) ListLevelRewards(context.Context, *activityv1.ListLevelRewardsRequest) (*activityv1.ListLevelRewardsResponse, error) {
	return &activityv1.ListLevelRewardsResponse{}, nil
}

func (f *fakeGrowthLevelClient) SetUserLevel(_ context.Context, req *activityv1.SetUserLevelRequest) (*activityv1.SetUserLevelResponse, error) {
	f.lastSet = req
	return &activityv1.SetUserLevelResponse{EventId: "event-1", Status: "applied", Track: req.GetTrack(), NewLevel: req.GetLevel(), TotalValue: 1000}, nil
}
