edent / Renault-Zoe-API

A basic API for getting information about your Renault Zoe Electric Vehicle.
92 stars 24 forks source link

How to cancel preconditioning timer? #19

Open g-mocken opened 4 years ago

g-mocken commented 4 years ago

Can you help me deciphering what this piece of JS code from the Z.E. site does:

    removeTimer: function removeTimer() {
      return UserService.getLoggedUser().then(function (user) {
        var baseURI = AppConstants.settings.apiUrl + "/vehicle/" + user.vehicle_details.VIN + "/air-conditioning/scheduler";
        return $http["delete"](baseURI).then(function (res) {
          $log.debug("AC timer removed successfully");
          return $q.resolve(res.data);
        });
      });
    },

In what kind of http request do I have to wrap this "delete"? I am no web/JS developer.

g-mocken commented 4 years ago

Ok, I think I got it. It simply means a DELETE request, instead of the POST for setting the timer, doesn't it?

premultiply commented 4 years ago

The easiest way to find out would be to have a look on your browsers web developer network trace window. There you will find the final raw request if you run the action on the site.

g-mocken commented 4 years ago

Thanks, that confirmed my finding. In Safari, that network trace has a nice "copy as cURL" feature, which gives (with the usual privacy replacements VVVV, AAAA and some uninteresting standard headers removed):

curl 'https://www.services.renault-ze.com/api/vehicle/VVVV/air-conditioning/scheduler' \
-XDELETE \
-H 'Accept: application/json, text/plain, */*' \
-H 'Origin: https://www.services.renault-ze.com' \
-H 'Authorization: Bearer AAAA' \
-H 'Referer: https://www.services.renault-ze.com/' \
-H 'Host: www.services.renault-ze.com'