Esempio n. 1
0
// Get attachment data as string array.
//
// @param  encode bool
// @return map[string]string
func (this *DocumentAttachment) ToArray(encode bool) map[string]string {
	// read file contents
	this.ReadFile(encode)

	array := util.MapString()
	array["data"] = this.Data
	array["content_type"] = this.ContentType

	return array
}
Esempio n. 2
0
// Set error.
//
// @param  body string
// @return void
func (this *Stream) SetError(body string) {
	if body == "" {
		body = this.Body.(string)
	}

	data, err := util.ParseBody(body, &StreamError{})
	if data != nil && err == nil {
		errorKey := data.(*StreamError).ErrorKey
		errorValue := data.(*StreamError).ErrorValue

		this.Error = _fmt.Sprintf("Stream Error >> error: \"%s\", reason: \"%s\"",
			errorKey,
			errorValue,
		)

		this.ErrorData = util.MapString()
		this.ErrorData["error"] = errorKey
		this.ErrorData["reason"] = errorValue
	}
}
Esempio n. 3
0
// Info.
//
// @return map[string]interface{}, error
func (this *Server) Info() (map[string]interface{}, error) {
	data, err := this.Client.Get("/", nil, nil).GetBodyData(nil)
	if err != nil {
		return nil, err
	}

	ret := util.Map()
	for key, value := range data.(map[string]interface{}) {
		switch value := value.(type) {
		case map[string]interface{}:
			ret[key] = util.MapString()
			for kkey, vvalue := range value {
				ret[key].(map[string]string)[kkey] = vvalue.(string)
			}
		default:
			ret[key] = value
		}
	}

	return ret, nil
}