package client

import (
	"context"

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

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

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

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

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

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

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

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

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

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

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