package template import ( "context" "encoding/json" "net/http" "repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/constants" "repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/validators" "repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/template/models" "repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/template/requests" ) // List gets a list of all templates the user has access to a ListAccounts struct func (t Template) List(ctx context.Context, req requests.ListTemplateRequest) (*models.ListTemplate, error) { res, err := t.ListRaw(ctx, req) if err != nil { return nil, err } list := models.ListTemplate{} err = json.Unmarshal(res, &list) if err != nil { return nil, err } return &list, nil } // ListRaw gets a list of all templates the user has access to as an array of bytes func (t Template) ListRaw(ctx context.Context, req requests.ListTemplateRequest) ([]byte, error) { if err := validators.ValidateRequest(req); err != nil { return nil, validators.ValidationErrors(validators.GetErrors(err)) } url := constants.APIv1 + "/template" res, err := t.client.ApiCall(ctx, http.MethodGet, url, req) return res, err }