package distributor

import (
	"context"

	rmodel "git-molva.ru/Molva/molva-backend/services/api_gateway/internal/request_model"
)

type DistributorService interface {
	GetVacancyList(ctx context.Context, request *rmodel.VacancyListGetRequest) (*rmodel.VacancyListGetResponse, error)
	CreateVacancy(ctx context.Context, request *rmodel.VacancyCreateRequest) (*rmodel.VacancyCreateResponse, error)
	UpdateVacancy(ctx context.Context, request *rmodel.VacancyUpdateRequest) (*rmodel.VacancyUpdateResponse, error)
	DeleteVacancy(ctx context.Context, request *rmodel.VacancyDeleteRequest) (*rmodel.VacancyDeleteResponse, error)
	SendVacancyToModeration(ctx context.Context, request *rmodel.SendVacancyToModerationRequest) (*rmodel.SendVacancyToModerationResponse, error)

	GetSubmissionListForVacancy(ctx context.Context, request *rmodel.SubmissionListForVacancyGetRequest) (*rmodel.SubmissionListForVacancyGetResponse, error)
	UpdateSubmissionStatus(ctx context.Context, request *rmodel.SubmissionStatusUpdateRequest) (*rmodel.SubmissionStatusUpdateResponse, error)

	GetProfile(ctx context.Context, request *rmodel.ProfileGetRequest) (*rmodel.ProfileGetResponse, error)
	UpdateProfile(ctx context.Context, request *rmodel.ProfileUpdateRequest) (*rmodel.ProfileUpdateResponse, error)

	GetCompanyList(ctx context.Context, request *rmodel.CompanyListGetRequest) (*rmodel.CompanyListGetResponse, error)
	GetCompanyInfoById(ctx context.Context, request *rmodel.CompanyByIdGetRequest) (*rmodel.CompanyByIdGetResponse, error)
	CreateCompany(ctx context.Context, request *rmodel.CompanyCreateRequest) (*rmodel.CompanyCreateResponse, error)
	UpdateCompanyInfo(ctx context.Context, request *rmodel.CompanyUpdateRequest) (*rmodel.CompanyUpdateResponse, error)
	AddEmployee(ctx context.Context, request *rmodel.AddDistributorCompanyMemberRequest) (*rmodel.AddDistributorCompanyMemberResponse, error)

	GetBalance(ctx context.Context, request *rmodel.BalanceGetRequest) (*rmodel.BalanceGetResponse, error)

	GetTransactionList(ctx context.Context, request *rmodel.TransactionListGetRequest) (*rmodel.TransactionListGetResponse, error)
	CreateTransaction(ctx context.Context, request *rmodel.TransactionCreateRequest) (*rmodel.TransactionCreateResponse, error)

	GetBankAccountList(ctx context.Context, request *rmodel.BankAccountListGetRequest) (*rmodel.BankAccountListGetResponse, error)
	CreateBankAccount(ctx context.Context, request *rmodel.BankAccountCreateRequest) (*rmodel.BankAccountCreateResponse, error)
	UpdateBankAccount(ctx context.Context, request *rmodel.BankAccountUpdateRequest) (*rmodel.BankAccountUpdateResponse, error)
	DeleteBankAccount(ctx context.Context, request *rmodel.BankAccountDeleteRequest) (*rmodel.BankAccountDeleteResponse, error)
}

func New(typ Type, cfg Config) (DistributorService, error) {
	switch typ {
	case CrmDistributorServiceType:
		config, ok := cfg.(CrmDistributorServiceConfig)
		if !ok {
			return nil, ErrInvalidConfig
		}

		return newCrmDistributorService(config), nil

	default:
		return nil, ErrUnknownDistributorServiceType
	}
}
