1
0

hydrawise.js 541 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. import rp from 'request-promise';
  3. class Hydrawise {
  4. constructor(key) {
  5. this.url = 'https://hydrawise.com/api/v1/';
  6. this.api_key = key;
  7. }
  8. request(method = 'GET', url = '', params = {}) {
  9. const options = {
  10. method,
  11. uri: `${this.url}${url}.php`,
  12. json: true
  13. };
  14. options.qs = {...params};
  15. options.qs.api_key = this.api_key;
  16. return rp(options);
  17. }
  18. customerdetails() {
  19. return this.request('GET', 'customerdetails', {type: 'controllers'});
  20. }
  21. }
  22. export default Hydrawise;