package client

import (
	"context"

	chainv1 "github.com/tech/sendico/pkg/proto/gateway/chain/v1"
)

// Fake implements Client for tests.
type Fake struct {
	CreateManagedWalletFn func(ctx context.Context, req *chainv1.CreateManagedWalletRequest) (*chainv1.CreateManagedWalletResponse, error)
	GetManagedWalletFn    func(ctx context.Context, req *chainv1.GetManagedWalletRequest) (*chainv1.GetManagedWalletResponse, error)
	ListManagedWalletsFn  func(ctx context.Context, req *chainv1.ListManagedWalletsRequest) (*chainv1.ListManagedWalletsResponse, error)
	GetWalletBalanceFn    func(ctx context.Context, req *chainv1.GetWalletBalanceRequest) (*chainv1.GetWalletBalanceResponse, error)
	SubmitTransferFn      func(ctx context.Context, req *chainv1.SubmitTransferRequest) (*chainv1.SubmitTransferResponse, error)
	GetTransferFn         func(ctx context.Context, req *chainv1.GetTransferRequest) (*chainv1.GetTransferResponse, error)
	ListTransfersFn       func(ctx context.Context, req *chainv1.ListTransfersRequest) (*chainv1.ListTransfersResponse, error)
	EstimateTransferFeeFn func(ctx context.Context, req *chainv1.EstimateTransferFeeRequest) (*chainv1.EstimateTransferFeeResponse, error)
	ComputeGasTopUpFn     func(ctx context.Context, req *chainv1.ComputeGasTopUpRequest) (*chainv1.ComputeGasTopUpResponse, error)
	EnsureGasTopUpFn      func(ctx context.Context, req *chainv1.EnsureGasTopUpRequest) (*chainv1.EnsureGasTopUpResponse, error)
	CloseFn               func() error
}

func (f *Fake) CreateManagedWallet(ctx context.Context, req *chainv1.CreateManagedWalletRequest) (*chainv1.CreateManagedWalletResponse, error) {
	if f.CreateManagedWalletFn != nil {
		return f.CreateManagedWalletFn(ctx, req)
	}
	return &chainv1.CreateManagedWalletResponse{}, nil
}

func (f *Fake) GetManagedWallet(ctx context.Context, req *chainv1.GetManagedWalletRequest) (*chainv1.GetManagedWalletResponse, error) {
	if f.GetManagedWalletFn != nil {
		return f.GetManagedWalletFn(ctx, req)
	}
	return &chainv1.GetManagedWalletResponse{}, nil
}

func (f *Fake) ListManagedWallets(ctx context.Context, req *chainv1.ListManagedWalletsRequest) (*chainv1.ListManagedWalletsResponse, error) {
	if f.ListManagedWalletsFn != nil {
		return f.ListManagedWalletsFn(ctx, req)
	}
	return &chainv1.ListManagedWalletsResponse{}, nil
}

func (f *Fake) GetWalletBalance(ctx context.Context, req *chainv1.GetWalletBalanceRequest) (*chainv1.GetWalletBalanceResponse, error) {
	if f.GetWalletBalanceFn != nil {
		return f.GetWalletBalanceFn(ctx, req)
	}
	return &chainv1.GetWalletBalanceResponse{}, nil
}

func (f *Fake) SubmitTransfer(ctx context.Context, req *chainv1.SubmitTransferRequest) (*chainv1.SubmitTransferResponse, error) {
	if f.SubmitTransferFn != nil {
		return f.SubmitTransferFn(ctx, req)
	}
	return &chainv1.SubmitTransferResponse{}, nil
}

func (f *Fake) GetTransfer(ctx context.Context, req *chainv1.GetTransferRequest) (*chainv1.GetTransferResponse, error) {
	if f.GetTransferFn != nil {
		return f.GetTransferFn(ctx, req)
	}
	return &chainv1.GetTransferResponse{}, nil
}

func (f *Fake) ListTransfers(ctx context.Context, req *chainv1.ListTransfersRequest) (*chainv1.ListTransfersResponse, error) {
	if f.ListTransfersFn != nil {
		return f.ListTransfersFn(ctx, req)
	}
	return &chainv1.ListTransfersResponse{}, nil
}

func (f *Fake) EstimateTransferFee(ctx context.Context, req *chainv1.EstimateTransferFeeRequest) (*chainv1.EstimateTransferFeeResponse, error) {
	if f.EstimateTransferFeeFn != nil {
		return f.EstimateTransferFeeFn(ctx, req)
	}
	return &chainv1.EstimateTransferFeeResponse{}, nil
}

func (f *Fake) ComputeGasTopUp(ctx context.Context, req *chainv1.ComputeGasTopUpRequest) (*chainv1.ComputeGasTopUpResponse, error) {
	if f.ComputeGasTopUpFn != nil {
		return f.ComputeGasTopUpFn(ctx, req)
	}
	return &chainv1.ComputeGasTopUpResponse{}, nil
}

func (f *Fake) EnsureGasTopUp(ctx context.Context, req *chainv1.EnsureGasTopUpRequest) (*chainv1.EnsureGasTopUpResponse, error) {
	if f.EnsureGasTopUpFn != nil {
		return f.EnsureGasTopUpFn(ctx, req)
	}
	return &chainv1.EnsureGasTopUpResponse{}, nil
}

func (f *Fake) Close() error {
	if f.CloseFn != nil {
		return f.CloseFn()
	}
	return nil
}
