Esempio n. 1
0
func (e Engine) Retrieve(params *tamber.BehaviorParams) (*tamber.Behavior, error) {
	body := &url.Values{}
	params.AppendToBody(body)
	behavior := &tamber.BehaviorResponse{}
	var err error

	if len(params.Name) > 0 {
		err = e.S.Call("POST", "", e.Key, object, "retrieve", body, behavior)
	} else {
		err = errors.New("Invalid behavior params: name needs to be set")
	}

	if !behavior.Succ {
		err = errors.New(behavior.Error)
	}
	return &behavior.Result, err
}
Esempio n. 2
0
func (e Engine) Create(params *tamber.BehaviorParams) (*tamber.Behavior, error) {
	body := &url.Values{}
	params.AppendToBody(body)
	behavior := &tamber.BehaviorResponse{}
	var err error

	if len(params.Name) > 0 && params.Desirability > 0 {
		err = e.S.Call("POST", "", e.Key, object, "create", body, behavior)
	} else {
		err = errors.New("Invalid behavior params: name, type, and desirability need to be set")
	}

	if !behavior.Succ {
		err = errors.New(behavior.Error)
	}
	return &behavior.Result, err
}