| import ( | import ( | ||||
| "encoding/json" | "encoding/json" | ||||
| "errors" | |||||
| "fmt" | "fmt" | ||||
| "io/ioutil" | "io/ioutil" | ||||
| "log" | "log" | ||||
| } | } | ||||
| func crmFindEntityByID(entityType string, id string) (entity interface{}, err error) { | func crmFindEntityByID(entityType string, id string) (entity interface{}, err error) { | ||||
| id = strings.TrimSpace(id) | |||||
| if id == "" { | |||||
| err = errors.New("empty ID not accepted") | |||||
| return | |||||
| } | |||||
| filters := []crmdSearchFilter{ | filters := []crmdSearchFilter{ | ||||
| {"id", "equals", id}, | {"id", "equals", id}, | ||||
| } | } | ||||
| entity = e[0] | entity = e[0] | ||||
| case "Account": | case "Account": | ||||
| return | return | ||||
| case "Livecast": | |||||
| e := []crmdLiveCast{} | |||||
| err = json.Unmarshal(*cs.List, &e) | |||||
| if (err != nil) || (len(e) != cs.Total) { | |||||
| return | |||||
| } | |||||
| entity = e[0] | |||||
| } | } | ||||
| return | return | ||||
| } | } |