smartcar / java-sdk

Java client SDK for the Smartcar API.
https://smartcar.github.io/java-sdk
MIT License
20 stars 20 forks source link

feat(SmartcarVehicleRequest): add support for boolean body params #134

Closed gurpreetatwal closed 11 months ago

gurpreetatwal commented 11 months ago

Asana: https://app.asana.com/0/1205492687081021/1205492826236061/f

Tested locally using the following code:

import com.google.gson.Gson;
import com.smartcar.sdk.*;
import com.smartcar.sdk.data.*;

public class Main {
  private static Gson gson = new Gson();

  public static void main(String[] args) throws Exception {
    String accessToken = "redacted";

    VehicleIds vehiclesResponse = Smartcar.getVehicles(accessToken);
    String[] vehicleIds = vehiclesResponse.getVehicleIds();

    Vehicle vehicle = new Vehicle(vehicleIds[0],accessToken);

    VehicleAttributes attributes = vehicle.attributes();
    System.out.println(gson.toJson(attributes));

    SmartcarVehicleRequest request = new SmartcarVehicleRequest.Builder()
      .method("POST")
      .path("tesla/charge/schedule")
      .addBodyParameter("type", "START_TIME")
      .addBodyParameter("enable", true)
      .addBodyParameter("time", "00:00")
      .build();

    VehicleResponse chargeSched = vehicle.request(request);

    System.out.println(gson.toJson(chargeSched));
  }
}
codecov[bot] commented 11 months ago

Codecov Report

Merging #134 (8af4694) into master (cf00588) will decrease coverage by 0.16%. The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #134      +/-   ##
============================================
- Coverage     73.74%   73.59%   -0.16%     
  Complexity      245      245              
============================================
  Files            50       50              
  Lines           975      977       +2     
  Branches         69       69              
============================================
  Hits            719      719              
- Misses          215      217       +2     
  Partials         41       41              
Flag Coverage Δ
integration 60.08% <0.00%> (-0.13%) :arrow_down:
test 46.57% <0.00%> (-0.10%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage
.../java/com/smartcar/sdk/SmartcarVehicleRequest.java 0.00%

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cf00588...8af4694. Read the comment docs.