Skip to content

Commit

Permalink
[minor_change] add action and priority attributes to template_contrac…
Browse files Browse the repository at this point in the history
…t_filter
  • Loading branch information
akinross authored and lhercot committed Oct 19, 2023
1 parent d6673bc commit 53b200b
Showing 1 changed file with 14 additions and 50 deletions.
64 changes: 14 additions & 50 deletions models/schema_template_contract_filter.go
Original file line number Diff line number Diff line change
@@ -1,63 +1,27 @@
package models

type TemplateContractFilter struct {
Ops string `json:",omitempty"`
Path string `json:",omitempty"`
Value string `json:",omitempty"`
}

type TemplateContractFilterRelationShip struct {
Ops string `json:",omitempty"`
Path string `json:",omitempty"`
Value map[string]interface{} `json:",omitempty"`
}
func NewTemplateContractFilterRelationShip(ops, path, action, priority string, filterRef map[string]interface{}, directives []interface{}) *PatchPayload {

func NewTemplateContractFilter(ops, path, filterType string) *TemplateContractFilter {

return &TemplateContractFilter{
Ops: ops,
Path: path,
Value: filterType,
filterMap := map[string]interface{}{
"filterRef": filterRef,
}

}

func NewTemplateContractFilterRelationShip(ops, path string, filterRef map[string]interface{}, directives []interface{}) *TemplateContractFilterRelationShip {
var contractMap map[string]interface{}
if ops != "remove" {
contractMap = map[string]interface{}{
"filterRef": filterRef,
"directives": directives,
}
} else {
contractMap = nil
if len(directives) > 0 {
filterMap["directives"] = directives
}
return &TemplateContractFilterRelationShip{
Ops: ops,
Path: path,
Value: contractMap,
}

}

func (FilterAttributes *TemplateContractFilter) ToMap() (map[string]interface{}, error) {
FilterAttributesMap := make(map[string]interface{})
A(FilterAttributesMap, "op", FilterAttributes.Ops)
A(FilterAttributesMap, "path", FilterAttributes.Path)
if FilterAttributes.Value != "" {
A(FilterAttributesMap, "value", FilterAttributes.Value)
if action != "" {
filterMap["action"] = action
}

return FilterAttributesMap, nil
}
if priority != "" {
filterMap["priorityOverride"] = priority
}

func (FilterAttributes *TemplateContractFilterRelationShip) ToMap() (map[string]interface{}, error) {
FilterAttributesMap := make(map[string]interface{})
A(FilterAttributesMap, "op", FilterAttributes.Ops)
A(FilterAttributesMap, "path", FilterAttributes.Path)
if FilterAttributes.Value != nil {
A(FilterAttributesMap, "value", FilterAttributes.Value)
return &PatchPayload{
Ops: ops,
Path: path,
Value: filterMap,
}

return FilterAttributesMap, nil
}

0 comments on commit 53b200b

Please sign in to comment.