-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.go
More file actions
33 lines (27 loc) · 887 Bytes
/
Copy pathprocess.go
File metadata and controls
33 lines (27 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package aurora
import (
"context"
"net/http"
)
// ProcessService handles rule processing operations.
type ProcessService struct {
client *Client
}
// Execute processes a transaction against a rule or ruleset and returns the result.
func (s *ProcessService) Execute(ctx context.Context, req *ProcessRequest) (*ProcessResponse, error) {
if req.TransactionID == "" && req.Transaction == nil {
return nil, &ValidationError{Field: "transaction", Message: "transaction is required"}
}
if !validTransactionTypes[req.Transaction.Type] {
return nil, &ValidationError{Field: "transaction.type", Message: "invalid or missing transaction type"}
}
httpReq, err := s.client.newRequest(ctx, http.MethodPost, "/process", req)
if err != nil {
return nil, err
}
var resp ProcessResponse
if err := s.client.do(httpReq, &resp); err != nil {
return nil, err
}
return &resp, nil
}