func (a *API) UpdateContactGroup(cfg *ContactGroup) (*ContactGroup, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid contact group config [nil]")
	}

	groupCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.ContactGroupCIDRegex, groupCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid contact group CID [%s]", groupCID)
	}

	jsonCfg, err := json.Marshal(cfg)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] update contact group, sending JSON: %s", string(jsonCfg))
	}

	result, err := a.Put(groupCID, jsonCfg)
	if err != nil {
		return nil, err
	}

	group := &ContactGroup{}
	if err := json.Unmarshal(result, group); err != nil {
		return nil, err
	}

	return group, nil
}
func (a *API) UpdateContactGroup(cfg *ContactGroup) (*ContactGroup, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid contact group config [nil]")
	}

	groupCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.ContactGroupCIDRegex, groupCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid contact group CID [%s]", groupCID)
	}

	jsonCfg, err := json.Marshal(cfg)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] update contact group, sending JSON: %s", string(jsonCfg))
	}

	result, err := a.Put(groupCID, jsonCfg)
	if err != nil {
		return nil, err
	}

	group := &ContactGroup{}
	if err := json.Unmarshal(result, group); err != nil {
		return nil, err
	}

	return group, nil
}
func ( a * API ) UpdateContactGroup ( cfg * ContactGroup ) ( * ContactGroup , error ) { if cfg == nil { return nil , fmt . Errorf ( " " ) } groupCID := string ( cfg . CID ) matched , err := regexp . MatchString ( config . ContactGroupCIDRegex , groupCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , groupCID ) } jsonCfg , err := json . Marshal ( cfg ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( jsonCfg ) ) } result , err := a . Put ( groupCID , jsonCfg ) if err != nil { return nil , err } group := & ContactGroup { } if err := json . Unmarshal ( result , group ) ; err != nil { return nil , err } return group , nil }
// UpdateContactGroup updates passed contact group.
UpdateContactGroup updates passed contact group .