api/acknowledgement.go
func (a *API) UpdateAcknowledgement(cfg *Acknowledgement) (*Acknowledgement, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid acknowledgement config [nil]")
	}

	acknowledgementCID := string(cfg.CID)

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

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

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

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

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

	return acknowledgement, nil
}
func (a *API) UpdateAcknowledgement(cfg *Acknowledgement) (*Acknowledgement, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid acknowledgement config [nil]")
	}

	acknowledgementCID := string(cfg.CID)

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

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

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

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

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

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