package sep

import (
	"context"
	"net/http"

	"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
)

// GetTemplateRequest struct to get template of SEP
type GetTemplateRequest struct {
	// Type of SEP
	// Required: true
	SepType string `url:"sep_type" json:"sep_type" validate:"required,sepType"`

	// Language of template
	// Required: true
	Language string `url:"lang" json:"lang" validate:"required,language"`
}

// GetTemplate gets data to sep template
func (s SEP) GetTemplate(ctx context.Context, req GetTemplateRequest) (string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return "", validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/sep/getTemplate"

	res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
	if err != nil {
		return "", err
	}

	return string(res), nil
}
