Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarmer08 committed Feb 29, 2024
1 parent a21f196 commit 3cb026c
Showing 1 changed file with 59 additions and 15 deletions.
74 changes: 59 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ module.exports = class WyzeAPI {
this.lastLoginAttempt = 0;
this.loginAttemptDebounceMilliseconds = 1000;



// Token is good for 216,000 seconds (60 hours) but 48 hours seems like a reasonable refresh interval 172800
if (this.refreshTokenTimerEnabled === true) {
setInterval(this.refreshToken.bind(this), 172800);
Expand Down Expand Up @@ -564,7 +566,12 @@ module.exports = class WyzeAPI {
const result = await axios.post(urlPath, payload);
if (this.apiLogEnabled) {
this.log.debug(
`API response ControlLock: ${JSON.stringify(result.data)}`
`API response: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
}
return result.data;
Expand Down Expand Up @@ -606,7 +613,12 @@ module.exports = class WyzeAPI {
const result = await axios.get(url, config);
if (this.apiLogEnabled) {
this.log.debug(
`API response GetLockInfo: ${JSON.stringify(result.data)}`
`API response: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
}
return result.data;
Expand Down Expand Up @@ -649,9 +661,14 @@ module.exports = class WyzeAPI {
if (this.apiLogEnabled) this.log.debug(`Performing request: ${url}`);
const result = await axios.get(url, config);
if (this.apiLogEnabled)
this.log.debug(
`API response GetIotProp: ${JSON.stringify(result.data)}`
);
this.log.debug(
`API response: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
return result.data;
} catch (e) {
this.log.error(`Request failed: ${e}`);
Expand Down Expand Up @@ -701,7 +718,12 @@ module.exports = class WyzeAPI {
const result = await axios.post(url, JSON.stringify(payload), config);
if (this.apiLogEnabled) {
this.log.debug(
`API response SetIotProp: ${JSON.stringify(result.data)}`
`API response: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
}

Expand Down Expand Up @@ -745,7 +767,12 @@ module.exports = class WyzeAPI {
const result = await axios.get(url, config);
if (this.apiLogEnabled) {
this.log.debug(
`API response GetUserProfile: ${JSON.stringify(result.data)}`
`API response MonitoringProfileActive: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
}

Expand Down Expand Up @@ -784,7 +811,12 @@ module.exports = class WyzeAPI {
const result = await axios.delete(url, config);
if (this.apiLogEnabled) {
this.log.debug(
`API response DisableRemeAlarm: ${JSON.stringify(result.data)}`
`API response MonitoringProfileActive: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
}
return result.data;
Expand Down Expand Up @@ -825,9 +857,12 @@ module.exports = class WyzeAPI {
const result = await axios.get(url, config);
if (this.apiLogEnabled) {
this.log.debug(
`API response GetPlanBindingListByUser: ${JSON.stringify(
result.data
)}`
`API response MonitoringProfileActive: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
}

Expand Down Expand Up @@ -870,10 +905,14 @@ module.exports = class WyzeAPI {
const result = await axios.get(url, config);
if (this.apiLogEnabled) {
this.log.debug(
`API response MonitoringProfileStateStatus: ${JSON.stringify(
result.data
)}`
`API response MonitoringProfileActive: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);

}
return result.data;
} catch (e) {
Expand Down Expand Up @@ -926,7 +965,12 @@ module.exports = class WyzeAPI {
const result = await axios.patch(url, data, config);
if (this.apiLogEnabled) {
this.log.debug(
`API response MonitoringProfileActive: ${JSON.stringify(result.data)}`
`API response MonitoringProfileActive: ${JSON.stringify({
url,
status: result.status,
data: result.data,
headers: result.headers,
})}`
);
}
return result.data;
Expand Down

0 comments on commit 3cb026c

Please sign in to comment.