@@ -98,52 +98,55 @@ let authenticate (serverInfo:Domain.GlobalSettings) =
9898 username = serverInfo.UserName
9999 password = serverInfo.Password
100100 |}
101- let! responce =
101+ let! response =
102102 Http.request $" {serverInfo.Host}/api/auth/login"
103103 |> Http.method POST
104104 |> Http.content ( BodyContent.Text body)
105105 |> Http.header ( Headers.contentType " application/json" )
106106 |> Http.withTimeout 5_000
107107 |> Http.send
108108 return
109- if responce.statusCode = 201 then
110- Json.tryParseAs< AuthResult> responce.responseText
111- else Error ( $" Unsuccessful login: Server is unavailable or login/password is incorrect. {responce.responseText}" )
109+ if response.statusCode = 201 then
110+ Json.tryParseAs< AuthResult> response.responseText
111+ else
112+ let msg = $" Unsuccessful login: Server is unavailable or login/password is incorrect. {response.responseText}"
113+ GTag.logException msg
114+ Error msg
112115 }
113116
114117let getConfigEditorInfo host ( auth : AuthResult ) =
115118 async {
116- let! responce =
119+ let! response =
117120 Http.request $" %s {host}/api/config-editor"
118121 |> sendWithAuth auth
119122 return
120- if responce .statusCode = 200 then
121- Json.tryParseAs< ConfigEditorInfo> responce .responseText
122- else Error ( $" Cannot get config editor info from {host}. {responce .responseText}" )
123+ if response .statusCode = 200 then
124+ Json.tryParseAs< ConfigEditorInfo> response .responseText
125+ else Error ( $" Cannot get config editor info from {host}. {response .responseText}" )
123126 }
124127
125128let getAccessories host ( auth : AuthResult ) =
126129 async {
127- let! responce =
130+ let! response =
128131 Http.request $" %s {host}/api/accessories"
129132 |> Http.withTimeout 20_000
130133 |> sendWithAuth auth
131134 return
132- if responce .statusCode = 200 then
133- Json.tryParseAs< AccessoryDetails[]> responce .responseText
134- else Error ( $" Cannot get accessories list from {host}. {responce .responseText}" )
135+ if response .statusCode = 200 then
136+ Json.tryParseAs< AccessoryDetails[]> response .responseText
137+ else Error ( $" Cannot get accessories list from {host}. {response .responseText}" )
135138 }
136139
137140let getAccessoriesLayout host ( auth : AuthResult ) =
138141 async {
139- let! responce =
142+ let! response =
140143 Http.request $" %s {host}/api/accessories/layout"
141144 |> Http.withTimeout 20_000
142145 |> sendWithAuth auth
143146 return
144- if responce .statusCode = 200 then
145- Json.tryParseAs< RoomLayout[]> responce .responseText
146- else Error ( $" Cannot get room layout from {host}. {responce .responseText}" )
147+ if response .statusCode = 200 then
148+ Json.tryParseAs< RoomLayout[]> response .responseText
149+ else Error ( $" Cannot get room layout from {host}. {response .responseText}" )
147150 }
148151
149152let setAccessoryCharacteristic host ( auth : AuthResult ) ( uniqueId : string ) ( characteristicType : string ) ( value : obj ) =
@@ -152,24 +155,24 @@ let setAccessoryCharacteristic host (auth:AuthResult) (uniqueId:string) (charact
152155 characteristicType = characteristicType
153156 value = value
154157 |}
155- let! responce =
158+ let! response =
156159 Http.request $" %s {host}/api/accessories/{uniqueId}"
157160 |> Http.method PUT
158161 |> Http.content ( BodyContent.Text body)
159162 |> sendWithAuth auth
160163 return
161- if responce .statusCode = 200 then
162- Json.tryParseAs< AccessoryDetails> responce .responseText
163- else Error ( $" Cannot set accessory '{uniqueId}' characteristic '{characteristicType}' to '{value}'. {responce .responseText}" )
164+ if response .statusCode = 200 then
165+ Json.tryParseAs< AccessoryDetails> response .responseText
166+ else Error ( $" Cannot set accessory '{uniqueId}' characteristic '{characteristicType}' to '{value}'. {response .responseText}" )
164167 }
165168
166169let getAccessory host ( auth : AuthResult ) ( uniqueId : string )=
167170 async {
168- let! responce =
171+ let! response =
169172 Http.request $" %s {host}/api/accessories/{uniqueId}"
170173 |> sendWithAuth auth
171174 return
172- if responce .statusCode = 200 then
173- Json.tryParseAs< AccessoryDetails> responce .responseText
174- else Error ( $" Cannot get accessory by id '{uniqueId}'. {responce .responseText}" )
175- }
175+ if response .statusCode = 200 then
176+ Json.tryParseAs< AccessoryDetails> response .responseText
177+ else Error ( $" Cannot get accessory by id '{uniqueId}'. {response .responseText}" )
178+ }
0 commit comments