Exemple #1
0
func NewDomainStore(fbUrl, auth string) DomainStore {
	historyUrl := fmt.Sprintf("%s/history", fbUrl)
	domainUrl := fmt.Sprintf("%s/domain", fbUrl)
	return DomainStore{
		history: firebase.NewReference(historyUrl).Auth(auth),
		domain:  firebase.NewReference(domainUrl).Auth(auth),
	}
}
func storeResultInFirebase(results FormResults) {

	var err error

	url := "https://typeformhackathon.firebaseio.com/answers"

	// Can also be your Firebase secret:
	authToken := "INSERT TOKEN HERE"

	// Auth is optional:
	ref := firebase.NewReference(url).Auth(authToken)

	// Write the value to Firebase.
	if err = ref.Push(results); err != nil {
		panic(err)
	}

	log.Println("WROTE TO FIREBASE")

	//	// Now, we're going to retrieve the person.
	//	personUrl := "https://SampleChat.firebaseIO-demo.com/users/fred"
	//
	//	personRef := firebase.NewReference(personUrl).Export(false)
	//
	//	fred := Person{}
	//
	//	if err = personRef.Value(fred); err != nil {
	//		panic(err)
	//	}
	//
	//	fmt.Println(fred.Name.First, fred.Name.Last) // prints: Fred Swanson

}
func storeVotedPersonInFirebase(user *slack.User) {
	var err error

	url := "https://typeformhackathon.firebaseio.com/votedUsers"

	// Can also be your Firebase secret:
	authToken := "INSERT TOKEN HERE"

	// Auth is optional:
	ref := firebase.NewReference(url).Auth(authToken)

	// Write the value to Firebase.
	if err = ref.Push(user); err != nil {
		panic(err)
	}

}