func CreateNotification()

in NewNotification.go [64:93]


func CreateNotification(r *vidispine.VSRequestor, callback_uri string, entityType string, notificationType string) error {
	newdoc, build_err := CreateNotificationDoc(&TemplateContent{
		Url:              callback_uri,
		EntityType:       entityType,
		NotificationType: notificationType,
	})
	if build_err != nil {
		log.Print("ERROR CreateNotification could not build a valid xml document: ", build_err)
		return errors.New("could not build valid xml")
	}

	urlEntityType := entityType
	if entityType == "metadata" || entityType == "shape" {
		urlEntityType = "item" //metadata updates get sent to to /item endpoint
	}
	response, serverErr := r.Post(
		fmt.Sprintf("/API/%s/notification", urlEntityType),
		"application/xml",
		"application/xml",
		strings.NewReader(newdoc),
	)

	if serverErr != nil {
		return serverErr
	}

	serverResponseBytes, _ := ioutil.ReadAll(response)
	log.Printf("Notification created succesfully: %s", string(serverResponseBytes))
	return nil
}