|  | 
| 3 | 3 |  * argv[1] Secret Key | 
| 4 | 4 |  */ | 
| 5 | 5 | const args = require('yargs').argv._; | 
| 6 |  | -const Usabilla = require('../dist'); | 
|  | 6 | +const Usabilla = require('../dist/api-js-node'); | 
| 7 | 7 | 
 | 
| 8 | 8 | const usabilla = new Usabilla(args[0], args[1]); | 
| 9 | 9 | 
 | 
| 10 | 10 | // Get all buttons for this account. | 
| 11 |  | -usabilla.websites.buttons.get().then((buttons) => { | 
|  | 11 | +usabilla.websites.buttons | 
|  | 12 | +  .get() | 
|  | 13 | +  .then(buttons => { | 
|  | 14 | +    const button = buttons[0]; | 
| 12 | 15 | 
 | 
| 13 |  | -  const button = buttons[0]; | 
| 14 |  | - | 
| 15 |  | -  if (!button) { | 
| 16 |  | -    return; | 
| 17 |  | -  } | 
| 18 |  | - | 
| 19 |  | -  // Use the button id to get feedback for this button id. | 
| 20 |  | -  let buttonFeedbackQuery = { | 
| 21 |  | -    id: button.id, | 
| 22 |  | -    params: { | 
| 23 |  | -      limit: 10 | 
|  | 16 | +    if (!button) { | 
|  | 17 | +      return; | 
| 24 | 18 |     } | 
| 25 |  | -  }; | 
| 26 |  | -  usabilla.websites.buttons.feedback.get(buttonFeedbackQuery).then((feedback) => { | 
| 27 |  | -    console.log('# button feedback', feedback.length); | 
| 28 |  | -  }).catch((reason) => { | 
|  | 19 | + | 
|  | 20 | +    // Use the button id to get feedback for this button id. | 
|  | 21 | +    let buttonFeedbackQuery = { | 
|  | 22 | +      id: button.id, | 
|  | 23 | +      params: { | 
|  | 24 | +        limit: 10 | 
|  | 25 | +      } | 
|  | 26 | +    }; | 
|  | 27 | +    usabilla.websites.buttons.feedback | 
|  | 28 | +      .get(buttonFeedbackQuery) | 
|  | 29 | +      .then(feedback => { | 
|  | 30 | +        console.log('# button feedback', feedback); | 
|  | 31 | +      }) | 
|  | 32 | +      .catch(reason => { | 
|  | 33 | +        console.error(reason); | 
|  | 34 | +      }); | 
|  | 35 | +  }) | 
|  | 36 | +  .catch(reason => { | 
|  | 37 | +    // If the usabilla call fails, we want to see the error message | 
| 29 | 38 |     console.error(reason); | 
| 30 | 39 |   }); | 
| 31 | 40 | 
 | 
| 32 |  | -}).catch((reason) => { | 
| 33 |  | -  // If the usabilla call fails, we want to see the error message | 
| 34 |  | -  console.error(reason); | 
| 35 |  | -}); | 
| 36 |  | - | 
| 37 |  | - | 
| 38 | 41 | // Get all campaigns for this account. | 
| 39 |  | -usabilla.websites.campaigns.get().then((campaigns) => { | 
| 40 |  | - | 
| 41 |  | -  const campaign = campaigns[0]; | 
|  | 42 | +usabilla.websites.campaigns | 
|  | 43 | +  .get() | 
|  | 44 | +  .then(campaigns => { | 
|  | 45 | +    const campaign = campaigns[0]; | 
| 42 | 46 | 
 | 
| 43 |  | -  if (!campaign) { | 
| 44 |  | -    return; | 
| 45 |  | -  } | 
|  | 47 | +    console.log('# campaigns', campaigns.length); | 
| 46 | 48 | 
 | 
| 47 |  | -  // Get the results for a campaign with id. | 
| 48 |  | -  let campaignQuery = { | 
| 49 |  | -    id: campaign.id | 
| 50 |  | -  }; | 
| 51 |  | - | 
| 52 |  | -  // Get the responses of the first campaign | 
| 53 |  | -  usabilla.websites.campaigns.results.get(campaignQuery).then((responses) => { | 
| 54 |  | -    console.log('# web campaign responses', responses.length); | 
| 55 |  | -  }).catch((reason) => { | 
| 56 |  | -    console.error(reason); | 
| 57 |  | -  }); | 
|  | 49 | +    if (!campaign) { | 
|  | 50 | +      return; | 
|  | 51 | +    } | 
| 58 | 52 | 
 | 
| 59 |  | -  // Get the stats of the first campaign | 
| 60 |  | -  usabilla.websites.campaigns.stats.get(campaignQuery).then((stats) => { | 
| 61 |  | -    console.log('web campaign stats', stats); | 
| 62 |  | -  }).catch((reason) => { | 
|  | 53 | +    // Get the results for a campaign with id. | 
|  | 54 | +    let campaignQuery = { | 
|  | 55 | +      id: campaign.id | 
|  | 56 | +    }; | 
|  | 57 | + | 
|  | 58 | +    // Get the responses of the first campaign | 
|  | 59 | +    usabilla.websites.campaigns.results | 
|  | 60 | +      .get(campaignQuery) | 
|  | 61 | +      .then(responses => { | 
|  | 62 | +        console.log('# web campaign responses', responses.length); | 
|  | 63 | +      }) | 
|  | 64 | +      .catch(reason => { | 
|  | 65 | +        console.error(reason); | 
|  | 66 | +      }); | 
|  | 67 | + | 
|  | 68 | +    // Get the stats of the first campaign | 
|  | 69 | +    usabilla.websites.campaigns.stats | 
|  | 70 | +      .get(campaignQuery) | 
|  | 71 | +      .then(stats => { | 
|  | 72 | +        console.log('# web campaign stats', stats); | 
|  | 73 | +      }) | 
|  | 74 | +      .catch(reason => { | 
|  | 75 | +        console.error(reason); | 
|  | 76 | +      }); | 
|  | 77 | +  }) | 
|  | 78 | +  .catch(reason => { | 
|  | 79 | +    // If the usabilla call fails, we want to see the error message | 
| 63 | 80 |     console.error(reason); | 
| 64 | 81 |   }); | 
| 65 |  | -}).catch((reason) => { | 
| 66 |  | -  // If the usabilla call fails, we want to see the error message | 
| 67 |  | -  console.error(reason); | 
| 68 |  | -}); | 
| 69 | 82 | 
 | 
| 70 | 83 | // Get all inpage widgets for this account. | 
| 71 |  | -usabilla.websites.inpage.get().then((inPageWidgets) => { | 
| 72 |  | - | 
| 73 |  | -  // Get the feedback for a inpage widget with id. | 
| 74 |  | -  let inPageQuery = { | 
| 75 |  | -    id: inPageWidgets[0].id | 
| 76 |  | -  }; | 
| 77 |  | - | 
| 78 |  | -  // Get the feedback of the first inpage widget | 
| 79 |  | -  usabilla.websites.inpage.feedback.get(inPageQuery).then((feedback) => { | 
| 80 |  | -    console.log('# inpage feedback', feedback.length); | 
| 81 |  | -  }).catch((reason) => { | 
|  | 84 | +usabilla.websites.inpage | 
|  | 85 | +  .get() | 
|  | 86 | +  .then(inPageWidgets => { | 
|  | 87 | +    // Get the feedback for a inpage widget with id. | 
|  | 88 | +    let inPageQuery = { | 
|  | 89 | +      id: inPageWidgets[0].id | 
|  | 90 | +    }; | 
|  | 91 | + | 
|  | 92 | +    // Get the feedback of the first inpage widget | 
|  | 93 | +    usabilla.websites.inpage.feedback | 
|  | 94 | +      .get(inPageQuery) | 
|  | 95 | +      .then(feedback => { | 
|  | 96 | +        console.log('# inpage feedback', feedback.length); | 
|  | 97 | +      }) | 
|  | 98 | +      .catch(reason => { | 
|  | 99 | +        console.error(reason); | 
|  | 100 | +      }); | 
|  | 101 | +  }) | 
|  | 102 | +  .catch(reason => { | 
|  | 103 | +    // If the usabilla call fails, we want to see the error message | 
| 82 | 104 |     console.error(reason); | 
| 83 | 105 |   }); | 
| 84 |  | -}).catch((reason) => { | 
| 85 |  | -  // If the usabilla call fails, we want to see the error message | 
| 86 |  | -  console.error(reason); | 
| 87 |  | -}); | 
| 88 | 106 | 
 | 
| 89 | 107 | // Get all email widgets for this account. | 
| 90 |  | -usabilla.email.widgets.get().then((emailWidgets) => { | 
| 91 |  | - | 
| 92 |  | -  // Get the feedback for a email widget with id. | 
| 93 |  | -  let emailQuery = { | 
| 94 |  | -    id: emailWidgets[0].id | 
| 95 |  | -  }; | 
| 96 |  | - | 
| 97 |  | -  // Get the feedback of the first email widget | 
| 98 |  | -  usabilla.email.widgets.feedback.get(emailQuery).then((feedback) => { | 
| 99 |  | -    console.log('# email feedback', feedback.length); | 
|  | 108 | +usabilla.email.widgets | 
|  | 109 | +  .get() | 
|  | 110 | +  .then(emailWidgets => { | 
|  | 111 | +    // Get the feedback for a email widget with id. | 
|  | 112 | +    let emailQuery = { | 
|  | 113 | +      id: emailWidgets[0].id | 
|  | 114 | +    }; | 
|  | 115 | + | 
|  | 116 | +    // Get the feedback of the first email widget | 
|  | 117 | +    usabilla.email.widgets.feedback.get(emailQuery).then(feedback => { | 
|  | 118 | +      console.log('# email feedback', feedback.length); | 
|  | 119 | +    }); | 
|  | 120 | +  }) | 
|  | 121 | +  .catch(reason => { | 
|  | 122 | +    // If the usabilla call fails, we want to see the error message | 
|  | 123 | +    console.error(reason); | 
| 100 | 124 |   }); | 
| 101 |  | -}).catch((reason) => { | 
| 102 |  | -  // If the usabilla call fails, we want to see the error message | 
| 103 |  | -  console.error(reason); | 
| 104 |  | -}); | 
| 105 | 125 | 
 | 
| 106 | 126 | // Get all apps forms for this account. | 
| 107 |  | -usabilla.apps.forms.get().then((appsForms) => { | 
| 108 |  | - | 
| 109 |  | -  const appsForm = appsForms[0]; | 
| 110 |  | - | 
| 111 |  | -  if (!appsForm) { | 
| 112 |  | -    return; | 
| 113 |  | -  } | 
|  | 127 | +usabilla.apps.forms | 
|  | 128 | +  .get() | 
|  | 129 | +  .then(appsForms => { | 
|  | 130 | +    const appsForm = appsForms[0]; | 
| 114 | 131 | 
 | 
| 115 |  | -  // Get the feedback for a apps form with id. | 
| 116 |  | -  let appsQuery = { | 
| 117 |  | -    id: appsForm.id | 
| 118 |  | -  }; | 
|  | 132 | +    if (!appsForm) { | 
|  | 133 | +      return; | 
|  | 134 | +    } | 
| 119 | 135 | 
 | 
| 120 |  | -  // Get the feedback of the second app form | 
| 121 |  | -  usabilla.apps.forms.feedback.get(appsQuery).then((feedback) => { | 
| 122 |  | -    console.log('# apps feedback', feedback.length); | 
|  | 136 | +    // Get the feedback for a apps form with id. | 
|  | 137 | +    let appsQuery = { | 
|  | 138 | +      id: appsForm.id | 
|  | 139 | +    }; | 
|  | 140 | + | 
|  | 141 | +    // Get the feedback of the second app form | 
|  | 142 | +    usabilla.apps.forms.feedback.get(appsQuery).then(feedback => { | 
|  | 143 | +      console.log('# apps feedback', feedback.length); | 
|  | 144 | +    }); | 
|  | 145 | +  }) | 
|  | 146 | +  .catch(reason => { | 
|  | 147 | +    // If the usabilla call fails, we want to see the error message | 
|  | 148 | +    console.error(reason); | 
| 123 | 149 |   }); | 
| 124 |  | -}).catch((reason) => { | 
| 125 |  | -  // If the usabilla call fails, we want to see the error message | 
| 126 |  | -  console.error(reason); | 
| 127 |  | -}); | 
| 128 | 150 | 
 | 
| 129 | 151 | // Get all apps campaigns for this account. | 
| 130 |  | -usabilla.apps.campaigns.get().then((appsCampaigns) => { | 
| 131 |  | -   | 
| 132 |  | -  // Use the first campaign found | 
| 133 |  | -  const appsCampaign = appsCampaigns[0]; | 
| 134 |  | -  if (!appsCampaign) { | 
| 135 |  | -    return; | 
| 136 |  | -  } | 
| 137 |  | - | 
| 138 |  | -  // Get the feedback for a apps form with id. | 
| 139 |  | -  let appsCampaignQuery = { | 
| 140 |  | -    id: appsCampaign.id | 
| 141 |  | -  }; | 
| 142 |  | - | 
| 143 |  | -  // Get the feedback of the second app form | 
| 144 |  | -  usabilla.apps.campaigns.results.get(appsCampaignQuery).then((responses) => { | 
| 145 |  | -    console.log('# apps campaign responses', responses.length); | 
| 146 |  | -  }).catch((reason) => { | 
|  | 152 | +usabilla.apps.campaigns | 
|  | 153 | +  .get() | 
|  | 154 | +  .then(appsCampaigns => { | 
|  | 155 | +    // Use the first campaign found | 
|  | 156 | +    const appsCampaign = appsCampaigns[0]; | 
|  | 157 | +    if (!appsCampaign) { | 
|  | 158 | +      return; | 
|  | 159 | +    } | 
|  | 160 | + | 
|  | 161 | +    // Get the feedback for a apps form with id. | 
|  | 162 | +    let appsCampaignQuery = { | 
|  | 163 | +      id: appsCampaign.id | 
|  | 164 | +    }; | 
|  | 165 | + | 
|  | 166 | +    // Get the feedback of the second app form | 
|  | 167 | +    usabilla.apps.campaigns.results | 
|  | 168 | +      .get(appsCampaignQuery) | 
|  | 169 | +      .then(responses => { | 
|  | 170 | +        console.log('# apps campaign responses', responses.length); | 
|  | 171 | +      }) | 
|  | 172 | +      .catch(reason => { | 
|  | 173 | +        console.error(reason); | 
|  | 174 | +      }); | 
|  | 175 | +  }) | 
|  | 176 | +  .catch(reason => { | 
| 147 | 177 |     console.error(reason); | 
| 148 | 178 |   }); | 
| 149 |  | - | 
| 150 |  | -}).catch((reason) => { | 
| 151 |  | -  console.error(reason); | 
| 152 |  | -}); | 
|  | 
0 commit comments