func (a *API) FetchAccount(cid CIDType) (*Account, error) {
	var accountCID string

	if cid == nil || *cid == "" {
		accountCID = config.AccountPrefix + "/current"
	} else {
		accountCID = string(*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)
	}

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

	if a.Debug {
		a.Log.Printf("[DEBUG] account fetch, received JSON: %s", string(result))
	}

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

	return account, nil
}
func (a *API) FetchAccount(cid CIDType) (*Account, error) {
	var accountCID string

	if cid == nil || *cid == "" {
		accountCID = config.AccountPrefix + "/current"
	} else {
		accountCID = string(*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)
	}

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

	if a.Debug {
		a.Log.Printf("[DEBUG] account fetch, received JSON: %s", string(result))
	}

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

	return account, nil
}
// FetchAccount retrieves account with passed cid. Pass nil for '/account/current'.