func (a *API) UpdateAccount(cfg *Account) (*Account, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid account config [nil]")
	}

	accountCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.AccountCIDRegex, accountCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid account CID [%s]", accountCID)
	}

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

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

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

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

	return account, nil
}
func (a *API) UpdateAccount(cfg *Account) (*Account, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid account config [nil]")
	}

	accountCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.AccountCIDRegex, accountCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid account CID [%s]", accountCID)
	}

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

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

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

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

	return account, nil
}
func ( a * API ) UpdateAccount ( cfg * Account ) ( * Account , error ) { if cfg == nil { return nil , fmt . Errorf ( " " ) } accountCID := string ( cfg . CID ) matched , err := regexp . MatchString ( config . AccountCIDRegex , accountCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , accountCID ) } jsonCfg , err := json . Marshal ( cfg ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( jsonCfg ) ) } result , err := a . Put ( accountCID , jsonCfg ) if err != nil { return nil , err } account := & Account { } if err := json . Unmarshal ( result , account ) ; err != nil { return nil , err } return account , nil }
// UpdateAccount updates passed account.
UpdateAccount updates passed account .