Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing DataContract and DataMember #247

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Q42.HueApi/Models/Bridge/Bridge.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Q42.HueApi.Models;
using Q42.HueApi.Models.Groups;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Q42.HueApi
{
Expand Down
58 changes: 27 additions & 31 deletions src/Q42.HueApi/Models/Bridge/BridgeConfig.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using Q42.HueApi.Models;
using System;
using Q42.HueApi.Models.Bridge;
using Q42.HueApi.Converters;

namespace Q42.HueApi
{
[DataContract]
public class BridgeConfig
{

Expand All @@ -18,103 +14,103 @@ public BridgeConfig()
WhiteList = new Dictionary<string, WhiteList>();
}

[DataMember(Name = "name")]
[JsonProperty("name")]
public string Name { get; set; }

[DataMember(Name = "mac")]
[JsonProperty("mac")]
public string MacAddress { get; set; }

[DataMember(Name = "dhcp")]
[JsonProperty("dhcp")]
public bool Dhcp { get; set; }

[DataMember(Name = "ipaddress")]
[JsonProperty("ipaddress")]
public string IpAddress { get; set; }

[DataMember(Name = "netmask")]
[JsonProperty("netmask")]
public string NetMask { get; set; }

[DataMember(Name = "gateway")]
[JsonProperty("gateway")]
public string Gateway { get; set; }

[DataMember(Name = "UTC")]
[JsonProperty("UTC")]
[JsonConverter(typeof(NullableDateTimeConverter))]
public DateTime? Utc { get; set; }

[DataMember(Name = "swversion")]
[JsonProperty("swversion")]
public string SoftwareVersion { get; set; }

[Obsolete]
[DataMember(Name = "swupdate")]
[JsonProperty("swupdate")]
public SoftwareUpdate SoftwareUpdate { get; set; }

[DataMember(Name = "swupdate2")]
[JsonProperty("swupdate2")]
public SoftwareUpdate2 SoftwareUpdate2 { get; set; }

[DataMember(Name = "whitelist")]
[JsonProperty("whitelist")]
public IDictionary<string, WhiteList> WhiteList { get; set; }

[DataMember(Name = "linkbutton")]
[JsonProperty("linkbutton")]
public bool LinkButton { get; set; }

[DataMember(Name = "portalservices")]
[JsonProperty("portalservices")]
public bool PortalServices { get; set; }

[DataMember(Name = "portalconnection")]
[JsonProperty("portalconnection")]
public string PortalConnection { get; set; }

[DataMember(Name = "apiversion")]
[JsonProperty("apiversion")]
public string ApiVersion { get; set; }

[DataMember(Name = "localtime")]
[JsonProperty("localtime")]
[JsonConverter(typeof(NullableDateTimeConverter))]
public DateTime? LocalTime { get; set; }

[DataMember(Name = "timezone")]
[JsonProperty("timezone")]
public string TimeZone { get; set; }

[DataMember(Name = "portalstate")]
[JsonProperty("portalstate")]
public PortalState PortalState { get; set; }

[DataMember(Name = "zigbeechannel")]
[JsonProperty("zigbeechannel")]
public int ZigbeeChannel { get; set; }

/// <summary>
/// Perform a touchlink action if set to true, setting to false is ignored. When set to true a touchlink procedure starts which adds the closet lamp (within range) to the ZigBee network. You can then search for new lights and lamp will show up in the bridge.
/// </summary>
[DataMember(Name = "touchlink")]
[JsonProperty("touchlink")]
public bool TouchLink { get; set; }

/// <summary>
/// Indicates if bridge settings are factory new.
/// </summary>
[DataMember(Name = "factorynew")]
[JsonProperty("factorynew")]
public bool FactoryNew { get; set; }

/// <summary>
/// If a bridge backup file has been restored on this bridge from a bridge with a different bridgeid, it will indicate that bridge id, otherwise it will be null.
/// </summary>
[DataMember(Name = "replacesbridgeid")]
[JsonProperty("replacesbridgeid")]
public string ReplacesBridgeId { get; set; }

/// <summary>
/// This parameter uniquely identifies the hardware model of the bridge (BSB001, BSB002).
/// </summary>
[DataMember(Name = "modelid")]
[JsonProperty("modelid")]
public string ModelId { get; set; }

/// <summary>
/// The unique bridge id. This is currently generated from the bridge Ethernet mac address.
/// </summary>
[DataMember(Name = "bridgeid")]
[JsonProperty("bridgeid")]
public string BridgeId { get; set; }

[DataMember(Name = "datastoreversion")]
[JsonProperty("datastoreversion")]
public string DataStoreVersion { get; set; }

[DataMember(Name = "starterkitid")]
[JsonProperty("starterkitid")]
public string StarterKitId { get; set; }

[DataMember(Name = "internetservices")]
[JsonProperty("internetservices")]
public InternetServices InternetServices { get; set; }

}
Expand Down
30 changes: 13 additions & 17 deletions src/Q42.HueApi/Models/Bridge/BridgeConfigUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,55 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using System;

namespace Q42.HueApi
{
/// <summary>
/// Allowed properties to update the BridgeConfig
/// </summary>
[DataContract]
public class BridgeConfigUpdate
{

[DataMember(Name = "name")]
[JsonProperty("name")]
public string Name { get; set; }

[DataMember(Name = "dhcp")]
[JsonProperty("dhcp")]
public bool? Dhcp { get; set; }

[DataMember(Name = "ipaddress")]
[JsonProperty("ipaddress")]
public string IpAddress { get; set; }

[DataMember(Name = "netmask")]
[JsonProperty("netmask")]
public string NetMask { get; set; }

[DataMember(Name = "gateway")]
[JsonProperty("gateway")]
public string Gateway { get; set; }

[Obsolete]
[DataMember(Name = "swupdate")]
[JsonProperty("swupdate")]
public SoftwareUpdate SoftwareUpdate { get; set; }

[DataMember(Name = "swupdate2")]
[JsonProperty("swupdate2")]
public SoftwareUpdate2 SoftwareUpdate2 { get; set; }

[DataMember(Name = "linkbutton")]
[JsonProperty("linkbutton")]
public bool? LinkButton { get; set; }

[DataMember(Name = "portalservices")]
[JsonProperty("portalservices")]
public bool? PortalServices { get; set; }

[DataMember(Name = "timezone")]
[JsonProperty("timezone")]
public string TimeZone { get; set; }

/// <summary>
/// As of 1.9. If set to true performs a touchlink action.
/// </summary>
[DataMember(Name = "touchlink")]
[JsonProperty("touchlink")]
public bool? TouchLink { get; set; }

/// <summary>
/// The current wireless frequency channel used by the bridge. It can take values of 11, 15, 20,25 or 0 if undefined (factory new).
/// </summary>
[DataMember(Name = "zigbeechannel")]
[JsonProperty("zigbeechannel")]
public int? ZigbeeChannel { get; set; }
}
}
}
13 changes: 6 additions & 7 deletions src/Q42.HueApi/Models/Bridge/InternetServices.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Q42.HueApi.Models.Bridge
{
[DataContract]
public class InternetServices
{
/// <summary>
/// Connected: If remote CLIP is available.
/// Disconnected: If remoteaccess is unavailable, reasons can be portalservices are false or no remote connection is available.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
[DataMember(Name = "remoteaccess")]
[JsonProperty("remoteaccess")]
public InternetServicesState RemoteAccess { get; set; }

/// <summary>
/// Connected: Bridge has a connection to Internet.
/// Disconnected: Bridge cannot reach the Internet.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
[DataMember(Name = "internet")]
[JsonProperty("internet")]
public InternetServicesState Internet { get; set; }

/// <summary>
/// Connected: Time was synchronized with internet service.
/// Disconnected: Internet time service was not reachable for 48hrs.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
[DataMember(Name = "time")]
[JsonProperty("time")]
public InternetServicesState Time { get; set; }

/// <summary>
/// Connected: swupdate server is available.
/// Disconnected: swupdate server was not reachable in the last 24 hrs.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
[DataMember(Name = "swupdate")]
[JsonProperty("swupdate")]
public InternetServicesState SWUpdate { get; set; }
}

/// <summary>
/// Possible InternetServices States
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum InternetServicesState
{
[EnumMember(Value = "connected")]
Expand Down
13 changes: 6 additions & 7 deletions src/Q42.HueApi/Models/Bridge/PortalState.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace Q42.HueApi
{
[DataContract]
public class PortalState
{
[DataMember(Name = "signedon")]
[JsonProperty("signedon")]
public bool SignedOn { get; set; }

[DataMember(Name = "incoming")]
[JsonProperty("incoming")]
public bool Incoming { get; set; }

[DataMember(Name = "outgoing")]
[JsonProperty("outgoing")]
public bool Outgoing { get; set; }

[DataMember(Name = "communication")]
[JsonProperty("communication")]
public string Communication { get; set; }
}
}
}
26 changes: 12 additions & 14 deletions src/Q42.HueApi/Models/Bridge/SoftwareUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Q42.HueApi
{
[Obsolete]
[DataContract]
public class SoftwareUpdate
{
/// <summary>
Expand All @@ -15,41 +14,40 @@ public class SoftwareUpdate
/// 3 means apply/applying the update.
/// http://www.everyhue.com/vanilla/discussion/484/firmware-update-triggering
/// </summary>
[DataMember (Name = "updatestate")]
[JsonProperty("updatestate")]
public int? UpdateState { get; set; }

[DataMember (Name = "url")]
[JsonProperty("url")]
public string Url { get; set; }

[DataMember (Name = "text")]
[JsonProperty("text")]
public string Text { get; set; }

[DataMember (Name = "notify")]
[JsonProperty("notify")]
public bool? Notify { get; set; }

/// <summary>
/// Setting this flag to true lets the bridge search for software updates in the portal. After the search attempt, this flag is set back to false. Requires portal connection to update server
/// http://www.developers.meethue.com/documentation/software-update
/// </summary>
[DataMember(Name = "checkforupdate")]
[JsonProperty("checkforupdate")]
public bool CheckForUpdate { get; set; }

[DataMember(Name = "devicetypes")]
[JsonProperty("devicetypes")]
public SoftwareUpdateDevices DeviceTypes { get; set; }
}

[Obsolete]
[DataContract]
public class SoftwareUpdateDevices
{
[DataMember(Name = "bridge")]
[JsonProperty("bridge")]
public bool Bridge { get; set; }

[DataMember(Name = "lights")]
[JsonProperty("lights")]
public IReadOnlyCollection<string> Lights { get; set; }

[DataMember(Name = "sensors")]
[JsonProperty("sensors")]
public IReadOnlyCollection<string> Sensors { get; set; }

}
}
}
Loading