// PutFromObject Getting attributes from an object
// m destination
// o resource
// lowercase whether key if lowercase
// named refer the mappings to rename
// ignore skip fields
func PutFromObject(m map[string]interface{}, o interface{}, lowercase bool, named map[string]string, ignore ...string) error {
	refType := reflect.TypeOf(o)
	refValue := reflect.ValueOf(o)
	PuttingFor: for i := 0; i < refType.Elem().NumField(); i++ {
		field := refType.Elem().Field(i)
		if field.Anonymous {
			continue
		}
		key := field.Name
		if lowercase {
			if v := field.Tag.Get("json"); v != "" {
				key = v
			} else {
				key = strings.ToLower(field.Name)
			}
		}
		if v, ok := named[key]; ok {
			key = v
		}
		for ij, ig := range ignore {
			if key == ig {
				ignore = ignore[:ij+copy(ignore[ij:], ignore[ij+1:])] // cut size
				continue PuttingFor
			}
		}
		m[key] = refValue.Elem().Field(i).Interface()
	}
	return nil
}