From e3448b1f3c254ef8a0f528b8d5394aee4da5dbcf Mon Sep 17 00:00:00 2001 From: Julian Amelung Date: Sun, 20 Dec 2020 21:49:42 +0100 Subject: [PATCH 1/2] Add change device name --- src/api.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api.ts b/src/api.ts index 6dd896f..e5ca506 100644 --- a/src/api.ts +++ b/src/api.ts @@ -194,6 +194,14 @@ class OpenAPI { return res.body as unknown as object; } + async changeDeviceName(deviceId: string, name: string): Promise { + const res = await this._client.put(`devices/${deviceId}`, { + json: { name } + }) + + return res.body as unknown as object; + } + async getDeviceStatus(deviceId: string): Promise { const res = await this._client.get(`devices/${deviceId}/status`); From 28084e1fef93cfd91257caeca3c3b3011c495c33 Mon Sep 17 00:00:00 2001 From: Julian Amelung Date: Sun, 20 Dec 2020 21:54:33 +0100 Subject: [PATCH 2/2] update docs --- docs/assets/js/search.js | 2 +- docs/classes/_api_.handletokenerror.html | 2 +- docs/classes/_api_.openapi.html | 70 +++++++++++++++++------- docs/interfaces/_api_.tuyaresponse.html | 8 +-- src/api.ts | 4 +- 5 files changed, 58 insertions(+), 28 deletions(-) diff --git a/docs/assets/js/search.js b/docs/assets/js/search.js index 3df659e..37e1420 100644 --- a/docs/assets/js/search.js +++ b/docs/assets/js/search.js @@ -1,3 +1,3 @@ var typedoc = typedoc || {}; typedoc.search = typedoc.search || {}; - typedoc.search.data = {"kinds":{"1":"External module","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"api\"","url":"modules/_api_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":256,"name":"TuyaResponse","url":"interfaces/_api_.tuyaresponse.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"api\""},{"id":2,"kind":1024,"name":"msg","url":"interfaces/_api_.tuyaresponse.html#msg","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":3,"kind":1024,"name":"t","url":"interfaces/_api_.tuyaresponse.html#t","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":4,"kind":1024,"name":"success","url":"interfaces/_api_.tuyaresponse.html#success","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":5,"kind":1024,"name":"result","url":"interfaces/_api_.tuyaresponse.html#result","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":6,"kind":128,"name":"OpenAPI","url":"classes/_api_.openapi.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"api\""},{"id":7,"kind":1024,"name":"tokenAccess","url":"classes/_api_.openapi.html#tokenaccess","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":8,"kind":1024,"name":"tokenRefresh","url":"classes/_api_.openapi.html#tokenrefresh","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":9,"kind":1024,"name":"tokenExpiresAt","url":"classes/_api_.openapi.html#tokenexpiresat","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":10,"kind":1024,"name":"schema","url":"classes/_api_.openapi.html#schema","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":11,"kind":1024,"name":"handleToken","url":"classes/_api_.openapi.html#handletoken","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":12,"kind":1024,"name":"_client","url":"classes/_api_.openapi.html#_client","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":13,"kind":1024,"name":"_key","url":"classes/_api_.openapi.html#_key","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":14,"kind":1024,"name":"_secret","url":"classes/_api_.openapi.html#_secret","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":15,"kind":512,"name":"constructor","url":"classes/_api_.openapi.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":16,"kind":2048,"name":"isTokenExpired","url":"classes/_api_.openapi.html#istokenexpired","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":17,"kind":2048,"name":"getToken","url":"classes/_api_.openapi.html#gettoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":18,"kind":2048,"name":"refreshToken","url":"classes/_api_.openapi.html#refreshtoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":19,"kind":2048,"name":"putUser","url":"classes/_api_.openapi.html#putuser","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":20,"kind":2048,"name":"getUsers","url":"classes/_api_.openapi.html#getusers","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":21,"kind":2048,"name":"getDeviceToken","url":"classes/_api_.openapi.html#getdevicetoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":22,"kind":2048,"name":"getDevicesByToken","url":"classes/_api_.openapi.html#getdevicesbytoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":23,"kind":2048,"name":"getDevicesByUser","url":"classes/_api_.openapi.html#getdevicesbyuser","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":24,"kind":2048,"name":"getDevices","url":"classes/_api_.openapi.html#getdevices","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":25,"kind":2048,"name":"getDevice","url":"classes/_api_.openapi.html#getdevice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":26,"kind":2048,"name":"getDeviceStatus","url":"classes/_api_.openapi.html#getdevicestatus","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":27,"kind":128,"name":"HandleTokenError","url":"classes/_api_.handletokenerror.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"api\""},{"id":28,"kind":512,"name":"constructor","url":"classes/_api_.handletokenerror.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":29,"kind":1024,"name":"name","url":"classes/_api_.handletokenerror.html#name","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":30,"kind":1024,"name":"message","url":"classes/_api_.handletokenerror.html#message","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":31,"kind":1024,"name":"stack","url":"classes/_api_.handletokenerror.html#stack","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":32,"kind":1024,"name":"Error","url":"classes/_api_.handletokenerror.html#error","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static tsd-is-not-exported","parent":"\"api\".HandleTokenError"}]}; \ No newline at end of file + typedoc.search.data = {"kinds":{"1":"External module","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"api\"","url":"modules/_api_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":256,"name":"TuyaResponse","url":"interfaces/_api_.tuyaresponse.html","classes":"tsd-kind-interface tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"api\""},{"id":2,"kind":1024,"name":"msg","url":"interfaces/_api_.tuyaresponse.html#msg","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":3,"kind":1024,"name":"t","url":"interfaces/_api_.tuyaresponse.html#t","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":4,"kind":1024,"name":"success","url":"interfaces/_api_.tuyaresponse.html#success","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":5,"kind":1024,"name":"result","url":"interfaces/_api_.tuyaresponse.html#result","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"\"api\".TuyaResponse"},{"id":6,"kind":128,"name":"OpenAPI","url":"classes/_api_.openapi.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"api\""},{"id":7,"kind":1024,"name":"tokenAccess","url":"classes/_api_.openapi.html#tokenaccess","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":8,"kind":1024,"name":"tokenRefresh","url":"classes/_api_.openapi.html#tokenrefresh","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":9,"kind":1024,"name":"tokenExpiresAt","url":"classes/_api_.openapi.html#tokenexpiresat","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":10,"kind":1024,"name":"schema","url":"classes/_api_.openapi.html#schema","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":11,"kind":1024,"name":"handleToken","url":"classes/_api_.openapi.html#handletoken","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":12,"kind":1024,"name":"_client","url":"classes/_api_.openapi.html#_client","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":13,"kind":1024,"name":"_key","url":"classes/_api_.openapi.html#_key","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":14,"kind":1024,"name":"_secret","url":"classes/_api_.openapi.html#_secret","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":15,"kind":512,"name":"constructor","url":"classes/_api_.openapi.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":16,"kind":2048,"name":"isTokenExpired","url":"classes/_api_.openapi.html#istokenexpired","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":17,"kind":2048,"name":"getToken","url":"classes/_api_.openapi.html#gettoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":18,"kind":2048,"name":"refreshToken","url":"classes/_api_.openapi.html#refreshtoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":19,"kind":2048,"name":"putUser","url":"classes/_api_.openapi.html#putuser","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":20,"kind":2048,"name":"getUsers","url":"classes/_api_.openapi.html#getusers","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":21,"kind":2048,"name":"getDeviceToken","url":"classes/_api_.openapi.html#getdevicetoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":22,"kind":2048,"name":"getDevicesByToken","url":"classes/_api_.openapi.html#getdevicesbytoken","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":23,"kind":2048,"name":"getDevicesByUser","url":"classes/_api_.openapi.html#getdevicesbyuser","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":24,"kind":2048,"name":"getDevices","url":"classes/_api_.openapi.html#getdevices","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":25,"kind":2048,"name":"getDevice","url":"classes/_api_.openapi.html#getdevice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":26,"kind":2048,"name":"changeDeviceName","url":"classes/_api_.openapi.html#changedevicename","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":27,"kind":2048,"name":"getDeviceStatus","url":"classes/_api_.openapi.html#getdevicestatus","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".OpenAPI"},{"id":28,"kind":128,"name":"HandleTokenError","url":"classes/_api_.handletokenerror.html","classes":"tsd-kind-class tsd-parent-kind-external-module tsd-is-not-exported","parent":"\"api\""},{"id":29,"kind":512,"name":"constructor","url":"classes/_api_.handletokenerror.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":30,"kind":1024,"name":"name","url":"classes/_api_.handletokenerror.html#name","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":31,"kind":1024,"name":"message","url":"classes/_api_.handletokenerror.html#message","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":32,"kind":1024,"name":"stack","url":"classes/_api_.handletokenerror.html#stack","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-not-exported","parent":"\"api\".HandleTokenError"},{"id":33,"kind":1024,"name":"Error","url":"classes/_api_.handletokenerror.html#error","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static tsd-is-not-exported","parent":"\"api\".HandleTokenError"}]}; \ No newline at end of file diff --git a/docs/classes/_api_.handletokenerror.html b/docs/classes/_api_.handletokenerror.html index 6f075c9..bd3034a 100644 --- a/docs/classes/_api_.handletokenerror.html +++ b/docs/classes/_api_.handletokenerror.html @@ -116,7 +116,7 @@

constructor

  • Returns HandleTokenError

    diff --git a/docs/classes/_api_.openapi.html b/docs/classes/_api_.openapi.html index 4d70bf4..e76a20c 100644 --- a/docs/classes/_api_.openapi.html +++ b/docs/classes/_api_.openapi.html @@ -103,6 +103,7 @@

    Properties

    Methods

    @@ -180,7 +181,7 @@

    Private _key

    _key: string
    @@ -190,7 +191,7 @@

    Private _secret

    _secret: string
    @@ -200,7 +201,7 @@

    handleToken

    handleToken: boolean
    @@ -210,7 +211,7 @@

    schema

    schema: string
    @@ -220,7 +221,7 @@

    tokenAccess

    tokenAccess: string
    @@ -230,7 +231,7 @@

    tokenExpiresAt

    tokenExpiresAt: Date
    @@ -240,13 +241,39 @@

    tokenRefresh

    tokenRefresh: string

    Methods

    +
    + +

    changeDeviceName

    +
      +
    • changeDeviceName(deviceId: string, name: string): Promise<object>
    • +
    +
      +
    • + +

      Parameters

      +
        +
      • +
        deviceId: string
        +
      • +
      • +
        name: string
        +
      • +
      +

      Returns Promise<object>

      +
    • +
    +

    getDevice

    @@ -257,7 +284,7 @@

    getDevice

  • Parameters

    @@ -280,7 +307,7 @@

    getDeviceStatus

  • Parameters

    @@ -303,7 +330,7 @@

    getDeviceToken

  • Parameters

    @@ -334,7 +361,7 @@

    getDevices

  • Parameters

    @@ -368,7 +395,7 @@

    getDevicesByToken

  • Parameters

    @@ -391,7 +418,7 @@

    getDevicesByUser

  • Parameters

    @@ -414,7 +441,7 @@

    getToken

  • Returns Promise<void>

    @@ -431,7 +458,7 @@

    getUsers

  • Parameters

    @@ -462,7 +489,7 @@

    isTokenExpired

  • Returns boolean

    @@ -479,7 +506,7 @@

    putUser

  • Parameters

    @@ -519,7 +546,7 @@

    refreshToken

  • Returns Promise<void>

    @@ -576,6 +603,9 @@

    Returns Promise tokenRefresh

  • +
  • + changeDeviceName +
  • getDevice
  • diff --git a/docs/interfaces/_api_.tuyaresponse.html b/docs/interfaces/_api_.tuyaresponse.html index 15baee9..e30f4ae 100644 --- a/docs/interfaces/_api_.tuyaresponse.html +++ b/docs/interfaces/_api_.tuyaresponse.html @@ -101,7 +101,7 @@

    msg

    msg: string
    @@ -111,7 +111,7 @@

    result

    result: object
    @@ -121,7 +121,7 @@

    success

    success: boolean
    @@ -131,7 +131,7 @@

    t

    t: number
    diff --git a/src/api.ts b/src/api.ts index e5ca506..cf0ae41 100644 --- a/src/api.ts +++ b/src/api.ts @@ -196,8 +196,8 @@ class OpenAPI { async changeDeviceName(deviceId: string, name: string): Promise { const res = await this._client.put(`devices/${deviceId}`, { - json: { name } - }) + json: {name} + }); return res.body as unknown as object; }