smartcar / node-sdk

Smartcar Node.js SDK
MIT License
50 stars 14 forks source link

Changes how vehicle methods are created from json #23

Closed RobinJayaswal closed 7 years ago

RobinJayaswal commented 7 years ago

Methods are generated for the Vehicle prototype once, not once per vehicle. Refactor makes metric vs imperial a property on the vehicle ( #15 ), and makes it possible to pass multiple arguments to actions ( #16 ).

RobinJayaswal commented 7 years ago

@sankethkatta @gurpreetatwal will hold off on making changes before we decide if I should write out functions like in PythonSDK or if we should use another automation method.

RobinJayaswal commented 7 years ago

@gurpreetatwal @sankethkatta this is ready for review again

RobinJayaswal commented 7 years ago

@gurpreetatwal I didnt kill the json file since I need for mocking all the endpoints in the testing file:

Object.keys(methods).forEach(function(method) {
      var config = methods[method];
      if (config.type === 'action') {
        apiNock
          .post(`/vehicles/${VALID_VID}/${config.endpoint}`).times(2)
          .matchHeader('Authorization', VALID_AUTHORIZATION)
          .reply(200, SUCCESS);
      } else {
        apiNock
          .get(`/vehicles/${VALID_VID}/${config.endpoint || ''}`)
          .matchHeader('Authorization', VALID_AUTHORIZATION)
          .reply(200, SUCCESS);
      }
    });