Skip to content

3. Usage

Vikram Ezhil edited this page Jan 29, 2019 · 8 revisions

Cordova, Ionic 1

// Authentication
window.plugin.humanapi.auth("CLIENT_ID", "CLIENT_SECRET", "USER_ID", "PUBLIC_TOKEN", "ACCESS_TOKEN", function(result) {
    alert("Result = " + result)
}, function(error) {
    alert("Error = " + error)
})

// Wellness Data
window.plugin.humanapi.execute("WELLNESS_NAME", "ACCESS_TOKEN", function(result) {
   alert("Result = " + result)
}, function(error) {
   alert("Error = " + error)
})

// Wellness Data by filter
window.plugin.humanapi.executeByFilter("WELLNESS_NAME", "ACCESS_TOKEN", "FILTER_NAME", function(result) {
   alert("Result = " + result)
}, function(error) {
   alert("Error = " + error)
})

// Sources Data
window.plugin.humanapi.execute("sources", "ACCESS_TOKEN", function(result) {
  alert("Result = " + result)
}, function(error) {
  alert("Error = " + error)
})

Ionic 2+

var human: any = window

// Authentication
human.plugin.humanapi.auth("CLIENT_ID", "CLIENT_SECRET", "USER_ID", "PUBLIC_TOKEN", "ACCESS_TOKEN", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})

// Wellness Data
human.plugin.humanapi.execute("WELLNESS_NAME", "ACCESS_TOKEN", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})

// Wellness Data by filter
human.plugin.humanapi.executeByFilter("WELLNESS_NAME", "ACCESS_TOKEN", "FILTER_NAME", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})

// Sources Data
human.plugin.humanapi.execute("sources", "ACCESS_TOKEN", (result) => {
  alert("Result = " + result)
}, (error) => {
  alert("Error = " + error)
})
Clone this wiki locally