/
models_trigger.go
49 lines (36 loc) · 1.14 KB
/
models_trigger.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package davinci
import "encoding/json"
type _Trigger Trigger
type Trigger struct {
AdditionalProperties map[string]interface{} `json:"-" davinci:"-,unmappedproperties"` // used to capture all other properties that are not explicitly defined in the model
TriggerType *string `json:"type,omitempty" davinci:"type,config,omitempty"`
}
func (o Trigger) MarshalJSON() ([]byte, error) {
result, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(result)
}
func (o Trigger) ToMap() (map[string]interface{}, error) {
result := map[string]interface{}{}
if o.TriggerType != nil {
result["type"] = o.TriggerType
}
for k, v := range o.AdditionalProperties {
result[k] = v
}
return result, nil
}
func (o *Trigger) UnmarshalJSON(bytes []byte) (err error) {
varTrigger := _Trigger{}
if err = json.Unmarshal(bytes, &varTrigger); err == nil {
*o = Trigger(varTrigger)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
delete(additionalProperties, "type")
o.AdditionalProperties = additionalProperties
}
return err
}