public class DefaultClient extends AbstractIClient
| 构造器和说明 |
|---|
DefaultClient() |
DefaultClient(String host,
String clientId,
String clientSecret)
客户端认证
|
DefaultClient(String host,
String username,
String password,
String pwdClientId,
String pwdClientSecret)
密码认证
|
| 限定符和类型 | 方法和说明 |
|---|---|
String |
doAction(IotHttpRequest request)
请求结果以String
实现类已设置鉴权,无需再次设置accessToken
|
<T extends IotResponse> |
doAction(IotHttpRequest request,
Class<T> tClass)
请求结果以对象返回
实现类已设置鉴权,无需再次设置accessToken
|
IotTokenResponse |
getAccessToken()
使用默认类型,获取access_token
|
IotTokenResponse |
getAccessToken(GrantType grantType)
根据grantType类型,获取access_token
|
<T extends IotResponse> |
unmarshal(Class<T> clasz,
String content)
字符串转换对象
|
public DefaultClient()
throws ClientException
ClientExceptionpublic DefaultClient(String host, String clientId, String clientSecret) throws ClientException
host - 服务地址clientId - 客户端IDclientSecret - 客户端秘钥ClientException - 客户端异常public DefaultClient(String host, String username, String password, String pwdClientId, String pwdClientSecret) throws ClientException
host - 服务地址username - 用户名password - 密码pwdClientId - 客户端IDpwdClientSecret - 客户端秘钥ClientException - 客户端异常public String doAction(IotHttpRequest request) throws ClientException, ServerException
IClient实现类已设置鉴权,无需再次设置accessToken
request - iot请求ClientException - 客户端异常ServerException - 服务异常public <T extends IotResponse> T doAction(IotHttpRequest request, Class<T> tClass) throws ClientException, ServerException
IClient实现类已设置鉴权,无需再次设置accessToken
T - 泛型 对象request - iot请求tClass - response 对象ClientException - 客户端异常ServerException - 服务异常public IotTokenResponse getAccessToken(GrantType grantType)
IClientgrantType - 使用鉴权类型public IotTokenResponse getAccessToken()
IClientpublic <T extends IotResponse> T unmarshal(Class<T> clasz, String content) throws ClientException
UnmarshallerT - 对象类clasz - 对象content - 字符串JSONClientException - 异常信息Copyright © 2023. All rights reserved.