Tuya.Net
Public Types | Public Member Functions
com.clusterrr.TuyaNet.TuyaApi Class Reference

Provides access to Tuya Cloud API. More...

Public Types

enum class  Region
 Region of server. More...
 
enum class  Method
 Request method. More...
 

Public Member Functions

 TuyaApi (Region region, string accessId, string apiSecret)
 Creates a new instance of the TuyaApi class. More...
 
async Task< string > RequestAsync (Method method, string uri, string body=null, Dictionary< string, string > headers=null, bool noToken=false, bool forceTokenRefresh=false, CancellationToken cancellationToken=default)
 Request to official API. More...
 
async Task< TuyaDeviceApiInfoGetDeviceInfoAsync (string deviceId, bool forceTokenRefresh=false, CancellationToken cancellationToken=default)
 Requests info about device by it's ID. More...
 
async Task< TuyaDeviceApiInfo[]> GetAllDevicesInfoAsync (string anyDeviceId, bool forceTokenRefresh=false, CancellationToken cancellationToken=default)
 Requests info about all registered devices, requires ID of any registered device. More...
 

Detailed Description

Provides access to Tuya Cloud API.

Member Enumeration Documentation

◆ Region

Region of server.

◆ Method

Request method.

Constructor & Destructor Documentation

◆ TuyaApi()

com.clusterrr.TuyaNet.TuyaApi.TuyaApi ( Region  region,
string  accessId,
string  apiSecret 
)
inline

Creates a new instance of the TuyaApi class.

Parameters
regionRegion of server.
accessIdAccess ID/Client ID from https://iot.tuya.com/ .
apiSecretAPI secret from https://iot.tuya.com/ .

Member Function Documentation

◆ RequestAsync()

async Task<string> com.clusterrr.TuyaNet.TuyaApi.RequestAsync ( Method  method,
string  uri,
string  body = null,
Dictionary< string, string >  headers = null,
bool  noToken = false,
bool  forceTokenRefresh = false,
CancellationToken  cancellationToken = default 
)
inline

Request to official API.

Parameters
uriMethod URI.
bodyBody of request if any.
headersAdditional headers.
noTokenExecute query without token.
forceTokenRefreshRefresh access token even it's not expired.
cancellationTokenCancellation token.
Returns
JSON string with response.
Here is the caller graph for this function:

◆ GetDeviceInfoAsync()

async Task<TuyaDeviceApiInfo> com.clusterrr.TuyaNet.TuyaApi.GetDeviceInfoAsync ( string  deviceId,
bool  forceTokenRefresh = false,
CancellationToken  cancellationToken = default 
)
inline

Requests info about device by it's ID.

Parameters
deviceIdDevice ID.
forceTokenRefreshRefresh access token even it's not expired.
cancellationTokenCancellation token.
Returns
Device info.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAllDevicesInfoAsync()

async Task<TuyaDeviceApiInfo[]> com.clusterrr.TuyaNet.TuyaApi.GetAllDevicesInfoAsync ( string  anyDeviceId,
bool  forceTokenRefresh = false,
CancellationToken  cancellationToken = default 
)
inline

Requests info about all registered devices, requires ID of any registered device.

Parameters
anyDeviceIdID of any registered device.
forceTokenRefreshRefresh access token even it's not expired.
cancellationTokenCancellation token.
Returns
Array of devices info.
Here is the call graph for this function: