Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions broker/oapi/open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,29 @@ paths:
schema:
$ref: '#/components/schemas/Error'

/state_model/templates:
get:
summary: Retrieve template defaults for built-in state models
tags:
- patron-requests-api
parameters:
- $ref: '#/components/parameters/Tenant'
responses:
'200':
description: Successful retrieval of template defaults
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CreateTemplate'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/batch_actions:
get:
summary: List all batch actions
Expand Down
4 changes: 4 additions & 0 deletions broker/patron_request/api/api-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func (a *PatronRequestApiHandler) GetStateModelBatchActions(w http.ResponseWrite
api.WriteJsonResponse(w, prservice.GetStateModelBatchActionDefaults())
}

func (a *PatronRequestApiHandler) GetStateModelTemplates(w http.ResponseWriter, r *http.Request, params proapi.GetStateModelTemplatesParams) {
api.WriteJsonResponse(w, prservice.GetStateModelTemplateDefaults())
}
Comment thread
JanisSaldabols marked this conversation as resolved.

func (a *PatronRequestApiHandler) GetPatronRequests(w http.ResponseWriter, r *http.Request, params proapi.GetPatronRequestsParams) {
logParams := map[string]string{"method": "GetPatronRequests"}
if params.Side != nil {
Expand Down
14 changes: 14 additions & 0 deletions broker/patron_request/service/statemodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type StateModelService struct {
type StateModelsConfig struct {
StateModels map[string]proapi.StateModel `json:"stateModels"`
BatchActionDefaults []proapi.BatchActionDefault `json:"batchActionDefaults"`
TemplateDefaults []proapi.CreateTemplate `json:"templateDefaults"`
}

func (s *StateModelService) GetStateModel(modelName string) (*proapi.StateModel, error) {
Expand Down Expand Up @@ -263,3 +264,16 @@ func GetStateModelBatchActionDefaults() []proapi.BatchActionDefault {
}
return out
}

func GetStateModelTemplateDefaults() []proapi.CreateTemplate {
// Return a defensive deep copy so callers can't mutate embedded defaults.
data, err := json.Marshal(stateModelsConfig.TemplateDefaults)
if err != nil {
return slices.Clone(stateModelsConfig.TemplateDefaults)
}
Comment thread
JanisSaldabols marked this conversation as resolved.
var out []proapi.CreateTemplate
if err := json.Unmarshal(data, &out); err != nil {
return slices.Clone(stateModelsConfig.TemplateDefaults)
}
return out
}
16 changes: 16 additions & 0 deletions misc/state-models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -558,3 +558,19 @@ batchActionDefaults:
schedule: "FREQ=DAILY;BYHOUR=5;BYMINUTE=0"
actionParams:
interval: 72h

templateDefaults:
- title: Scheduled pullslips email template
labels:
- pullslip-email
subject: "Scheduled pullslips"
contentType: html
audience: staff
purpose: email
body: |
<p>This is an automated pull slip summary.</p>
<p>
<strong>Query:</strong> {{batchQuery}}<br>
<strong>Matching requests:</strong> {{actualCount}} (of {{fullCount}} total)
</p>
<p>Please process the attached pull slips at your earliest convenience.</p>
Loading