Skip to content

Add schema site contract model #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
30 changes: 30 additions & 0 deletions models/schema_site_contract.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package models

type SiteContract struct {
Ops string `json:",omitempty"`
Path string `json:",omitempty"`
Value map[string]interface{} `json:",omitempty"`
}
Comment on lines +3 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type SiteContract struct {
Ops string `json:",omitempty"`
Path string `json:",omitempty"`
Value map[string]interface{} `json:",omitempty"`
}


func NewSchemaSiteContract(ops, path string, contractRef map[string]interface{}) *SiteContract {
contractMap := map[string]interface{}{
"contractRef": contractRef,
}

return &SiteContract{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We moved to a generic version of PatchPayload in the latest code so if you can use this going forward.

Suggested change
return &SiteContract{
return & PatchPayload{

Ops: ops,
Path: path,
Value: contractMap,
}
}

func (contractAttributes *SiteContract) ToMap() (map[string]interface{}, error) {
contractAttributesMap := make(map[string]interface{})
A(contractAttributesMap, "op", contractAttributes.Ops)
A(contractAttributesMap, "path", contractAttributes.Path)
if contractAttributes.Value != nil {
A(contractAttributesMap, "value", contractAttributes.Value)
}

return contractAttributesMap, nil
}
Comment on lines +21 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (contractAttributes *SiteContract) ToMap() (map[string]interface{}, error) {
contractAttributesMap := make(map[string]interface{})
A(contractAttributesMap, "op", contractAttributes.Ops)
A(contractAttributesMap, "path", contractAttributes.Path)
if contractAttributes.Value != nil {
A(contractAttributesMap, "value", contractAttributes.Value)
}
return contractAttributesMap, nil
}