Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Updated models and clients to support battery voltage, device, and fuel
Browse files Browse the repository at this point in the history
grade last known location and active MILs on vehicles.
Plus Driver on trips
  • Loading branch information
supergibbs committed Mar 27, 2016
1 parent 4ac23d9 commit b0c5177
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/AutomaticSharp/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ private async Task<T> GetAsync<T>(string resource, Dictionary<string, string> pa
return new JsonNetSerializer().Deserialize<T>(content);
}

private async Task DeleteAsync(string path)
private async Task<T> DeleteAsync<T>(string path)
{
var request = new HttpRequestMessage(HttpMethod.Delete, path);
var result = await _httpClient.SendAsync(request);
var content = await result.Content.ReadAsStringAsync();

await _httpClient.SendAsync(request);
return new JsonNetSerializer().Deserialize<T>(content);
}
}
}
5 changes: 5 additions & 0 deletions src/AutomaticSharp/Models/Trip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class Trip
/// </summary>
public string Url { get; set; }

/// <summary>
/// Driver URI
/// </summary>
public string Driver { get; set; }

/// <summary>
/// User URI
/// </summary>
Expand Down
25 changes: 25 additions & 0 deletions src/AutomaticSharp/Models/Vehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,34 @@ public class Vehicle
/// </summary>
public DateTime? UpdatedAt { get; set; }

/// <summary>
/// The device plugged into this vehicle currently
/// </summary>
public string Device { get; set; }

/// <summary>
/// Fuel Grade
/// </summary>
public string FuelGrade { get; set; }

/// <summary>
/// Amount of fuel as percentage of total capacity
/// </summary>
public double FuelLevelPercent { get; set; }

/// <summary>
/// Battery voltage
/// </summary>
public double BatteryVoltage { get; set; }

/// <summary>
/// Last known location
/// </summary>
public double LastestLocation { get; set; }

/// <summary>
/// Currently active MILs
/// </summary>
public string ActiveDtcs { get; set; }
}
}
6 changes: 3 additions & 3 deletions src/AutomaticSharp/UserClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<DeviceUserRelationship> GetDeviceAsync(string deviceId, string
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<AutomaticCollection<DeviceUserRelationship>> GetDevicesAsync(DevicesRequest request=null)
public async Task<AutomaticCollection<DeviceUserRelationship>> GetDevicesAsync(DevicesRequest request = null)
{
const string path = "user/";

Expand All @@ -46,11 +46,11 @@ public async Task<AutomaticCollection<DeviceUserRelationship>> GetDevicesAsync(D
return await GetAsync<AutomaticCollection<DeviceUserRelationship>>(path + (request.UserId ?? "me") + "/device/", request.CreateParameters());
}

public async Task DeleteEmergencyContactAsync(string emergencyContactId, string userId = "me")
public async Task<EmergencyContact> DeleteEmergencyContactAsync(string emergencyContactId, string userId = "me")
{
const string path = "user/";

await DeleteAsync(path + userId + "/emergency-contact/" + emergencyContactId + "/");
return await DeleteAsync<EmergencyContact>(path + userId + "/emergency-contact/" + emergencyContactId + "/");
}
}
}

0 comments on commit b0c5177

Please sign in to comment.