|
| 1 | +using System.Runtime.Serialization; |
| 2 | +using System.Text; |
| 3 | +using JsonSubTypes; |
| 4 | +using Newtonsoft.Json; |
| 5 | +using Newtonsoft.Json.Converters; |
| 6 | +using Newtonsoft.Json.Linq; |
| 7 | +using Seam.Client; |
| 8 | +using Seam.Model; |
| 9 | + |
| 10 | +namespace Seam.Api |
| 11 | +{ |
| 12 | + public class SimulateLocks |
| 13 | + { |
| 14 | + private ISeamClient _seam; |
| 15 | + |
| 16 | + public SimulateLocks(ISeamClient seam) |
| 17 | + { |
| 18 | + _seam = seam; |
| 19 | + } |
| 20 | + |
| 21 | + [DataContract(Name = "keypadCodeEntryRequest_request")] |
| 22 | + public class KeypadCodeEntryRequest |
| 23 | + { |
| 24 | + [JsonConstructorAttribute] |
| 25 | + protected KeypadCodeEntryRequest() { } |
| 26 | + |
| 27 | + public KeypadCodeEntryRequest(string code = default, string deviceId = default) |
| 28 | + { |
| 29 | + Code = code; |
| 30 | + DeviceId = deviceId; |
| 31 | + } |
| 32 | + |
| 33 | + [DataMember(Name = "code", IsRequired = true, EmitDefaultValue = false)] |
| 34 | + public string Code { get; set; } |
| 35 | + |
| 36 | + [DataMember(Name = "device_id", IsRequired = true, EmitDefaultValue = false)] |
| 37 | + public string DeviceId { get; set; } |
| 38 | + |
| 39 | + public override string ToString() |
| 40 | + { |
| 41 | + JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(null); |
| 42 | + |
| 43 | + StringWriter stringWriter = new StringWriter( |
| 44 | + new StringBuilder(256), |
| 45 | + System.Globalization.CultureInfo.InvariantCulture |
| 46 | + ); |
| 47 | + using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) |
| 48 | + { |
| 49 | + jsonTextWriter.IndentChar = ' '; |
| 50 | + jsonTextWriter.Indentation = 2; |
| 51 | + jsonTextWriter.Formatting = Formatting.Indented; |
| 52 | + jsonSerializer.Serialize(jsonTextWriter, this, null); |
| 53 | + } |
| 54 | + |
| 55 | + return stringWriter.ToString(); |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + [DataContract(Name = "keypadCodeEntryResponse_response")] |
| 60 | + public class KeypadCodeEntryResponse |
| 61 | + { |
| 62 | + [JsonConstructorAttribute] |
| 63 | + protected KeypadCodeEntryResponse() { } |
| 64 | + |
| 65 | + public KeypadCodeEntryResponse(ActionAttempt actionAttempt = default) |
| 66 | + { |
| 67 | + ActionAttempt = actionAttempt; |
| 68 | + } |
| 69 | + |
| 70 | + [DataMember(Name = "action_attempt", IsRequired = false, EmitDefaultValue = false)] |
| 71 | + public ActionAttempt ActionAttempt { get; set; } |
| 72 | + |
| 73 | + public override string ToString() |
| 74 | + { |
| 75 | + JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(null); |
| 76 | + |
| 77 | + StringWriter stringWriter = new StringWriter( |
| 78 | + new StringBuilder(256), |
| 79 | + System.Globalization.CultureInfo.InvariantCulture |
| 80 | + ); |
| 81 | + using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) |
| 82 | + { |
| 83 | + jsonTextWriter.IndentChar = ' '; |
| 84 | + jsonTextWriter.Indentation = 2; |
| 85 | + jsonTextWriter.Formatting = Formatting.Indented; |
| 86 | + jsonSerializer.Serialize(jsonTextWriter, this, null); |
| 87 | + } |
| 88 | + |
| 89 | + return stringWriter.ToString(); |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + public ActionAttempt KeypadCodeEntry(KeypadCodeEntryRequest request) |
| 94 | + { |
| 95 | + var requestOptions = new RequestOptions(); |
| 96 | + requestOptions.Data = request; |
| 97 | + return _seam |
| 98 | + .Post<KeypadCodeEntryResponse>("/locks/simulate/keypad_code_entry", requestOptions) |
| 99 | + .Data.ActionAttempt; |
| 100 | + } |
| 101 | + |
| 102 | + public ActionAttempt KeypadCodeEntry(string code = default, string deviceId = default) |
| 103 | + { |
| 104 | + return KeypadCodeEntry(new KeypadCodeEntryRequest(code: code, deviceId: deviceId)); |
| 105 | + } |
| 106 | + |
| 107 | + public async Task<ActionAttempt> KeypadCodeEntryAsync(KeypadCodeEntryRequest request) |
| 108 | + { |
| 109 | + var requestOptions = new RequestOptions(); |
| 110 | + requestOptions.Data = request; |
| 111 | + return ( |
| 112 | + await _seam.PostAsync<KeypadCodeEntryResponse>( |
| 113 | + "/locks/simulate/keypad_code_entry", |
| 114 | + requestOptions |
| 115 | + ) |
| 116 | + ) |
| 117 | + .Data |
| 118 | + .ActionAttempt; |
| 119 | + } |
| 120 | + |
| 121 | + public async Task<ActionAttempt> KeypadCodeEntryAsync( |
| 122 | + string code = default, |
| 123 | + string deviceId = default |
| 124 | + ) |
| 125 | + { |
| 126 | + return ( |
| 127 | + await KeypadCodeEntryAsync( |
| 128 | + new KeypadCodeEntryRequest(code: code, deviceId: deviceId) |
| 129 | + ) |
| 130 | + ); |
| 131 | + } |
| 132 | + |
| 133 | + [DataContract(Name = "manualLockViaKeypadRequest_request")] |
| 134 | + public class ManualLockViaKeypadRequest |
| 135 | + { |
| 136 | + [JsonConstructorAttribute] |
| 137 | + protected ManualLockViaKeypadRequest() { } |
| 138 | + |
| 139 | + public ManualLockViaKeypadRequest(string deviceId = default) |
| 140 | + { |
| 141 | + DeviceId = deviceId; |
| 142 | + } |
| 143 | + |
| 144 | + [DataMember(Name = "device_id", IsRequired = true, EmitDefaultValue = false)] |
| 145 | + public string DeviceId { get; set; } |
| 146 | + |
| 147 | + public override string ToString() |
| 148 | + { |
| 149 | + JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(null); |
| 150 | + |
| 151 | + StringWriter stringWriter = new StringWriter( |
| 152 | + new StringBuilder(256), |
| 153 | + System.Globalization.CultureInfo.InvariantCulture |
| 154 | + ); |
| 155 | + using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) |
| 156 | + { |
| 157 | + jsonTextWriter.IndentChar = ' '; |
| 158 | + jsonTextWriter.Indentation = 2; |
| 159 | + jsonTextWriter.Formatting = Formatting.Indented; |
| 160 | + jsonSerializer.Serialize(jsonTextWriter, this, null); |
| 161 | + } |
| 162 | + |
| 163 | + return stringWriter.ToString(); |
| 164 | + } |
| 165 | + } |
| 166 | + |
| 167 | + [DataContract(Name = "manualLockViaKeypadResponse_response")] |
| 168 | + public class ManualLockViaKeypadResponse |
| 169 | + { |
| 170 | + [JsonConstructorAttribute] |
| 171 | + protected ManualLockViaKeypadResponse() { } |
| 172 | + |
| 173 | + public ManualLockViaKeypadResponse(ActionAttempt actionAttempt = default) |
| 174 | + { |
| 175 | + ActionAttempt = actionAttempt; |
| 176 | + } |
| 177 | + |
| 178 | + [DataMember(Name = "action_attempt", IsRequired = false, EmitDefaultValue = false)] |
| 179 | + public ActionAttempt ActionAttempt { get; set; } |
| 180 | + |
| 181 | + public override string ToString() |
| 182 | + { |
| 183 | + JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(null); |
| 184 | + |
| 185 | + StringWriter stringWriter = new StringWriter( |
| 186 | + new StringBuilder(256), |
| 187 | + System.Globalization.CultureInfo.InvariantCulture |
| 188 | + ); |
| 189 | + using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) |
| 190 | + { |
| 191 | + jsonTextWriter.IndentChar = ' '; |
| 192 | + jsonTextWriter.Indentation = 2; |
| 193 | + jsonTextWriter.Formatting = Formatting.Indented; |
| 194 | + jsonSerializer.Serialize(jsonTextWriter, this, null); |
| 195 | + } |
| 196 | + |
| 197 | + return stringWriter.ToString(); |
| 198 | + } |
| 199 | + } |
| 200 | + |
| 201 | + public ActionAttempt ManualLockViaKeypad(ManualLockViaKeypadRequest request) |
| 202 | + { |
| 203 | + var requestOptions = new RequestOptions(); |
| 204 | + requestOptions.Data = request; |
| 205 | + return _seam |
| 206 | + .Post<ManualLockViaKeypadResponse>( |
| 207 | + "/locks/simulate/manual_lock_via_keypad", |
| 208 | + requestOptions |
| 209 | + ) |
| 210 | + .Data.ActionAttempt; |
| 211 | + } |
| 212 | + |
| 213 | + public ActionAttempt ManualLockViaKeypad(string deviceId = default) |
| 214 | + { |
| 215 | + return ManualLockViaKeypad(new ManualLockViaKeypadRequest(deviceId: deviceId)); |
| 216 | + } |
| 217 | + |
| 218 | + public async Task<ActionAttempt> ManualLockViaKeypadAsync( |
| 219 | + ManualLockViaKeypadRequest request |
| 220 | + ) |
| 221 | + { |
| 222 | + var requestOptions = new RequestOptions(); |
| 223 | + requestOptions.Data = request; |
| 224 | + return ( |
| 225 | + await _seam.PostAsync<ManualLockViaKeypadResponse>( |
| 226 | + "/locks/simulate/manual_lock_via_keypad", |
| 227 | + requestOptions |
| 228 | + ) |
| 229 | + ) |
| 230 | + .Data |
| 231 | + .ActionAttempt; |
| 232 | + } |
| 233 | + |
| 234 | + public async Task<ActionAttempt> ManualLockViaKeypadAsync(string deviceId = default) |
| 235 | + { |
| 236 | + return ( |
| 237 | + await ManualLockViaKeypadAsync(new ManualLockViaKeypadRequest(deviceId: deviceId)) |
| 238 | + ); |
| 239 | + } |
| 240 | + } |
| 241 | +} |
| 242 | + |
| 243 | +namespace Seam.Client |
| 244 | +{ |
| 245 | + public partial class SeamClient |
| 246 | + { |
| 247 | + public Api.SimulateLocks SimulateLocks => new(this); |
| 248 | + } |
| 249 | + |
| 250 | + public partial interface ISeamClient |
| 251 | + { |
| 252 | + public Api.SimulateLocks SimulateLocks { get; } |
| 253 | + } |
| 254 | +} |
0 commit comments