Skip to content

Commit

Permalink
docs: cmd response
Browse files Browse the repository at this point in the history
  • Loading branch information
jevantang committed Mar 25, 2024
1 parent 541aa52 commit 14de477
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions docs/command-word/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,21 @@ $fresnsResp = \FresnsCmdWord::plugin('FresnsEmail')->sendEmail($wordBody);
**Handling abnormal situations**
```php
if ($fresnsResp->isErrorResponse()) {
return $fresnsResp->errorResponse(); // When an error is reported, the full amount of parameters is output(code+message+data)
return $fresnsResp->getErrorResponse();
}
```

**Handling normal situations**
```php
$fresnsResp->getOrigin(); // Obtaining raw data
$fresnsResp->getOrigin(); // Obtaining raw data(code+message+data)

$fresnsResp->getCode(); // Get code only
$fresnsResp->getMessage(); // Get only the message
$fresnsResp->getData(); // Get only the full amount of data
$fresnsResp->getData('user.nickname'); // Get only the parameters specified in data, for example: data.user.nickname

$fresnsResp->isSuccessResponse(); // Determine if the request is true
$fresnsResp->isErrorResponse(); // Determine if the request is false
$fresnsResp->getErrorResponse(); // Get the error response object

$fresnsResp->getErrorResponse(); // Internal use returns raw data, API calls return JSON.
```
9 changes: 6 additions & 3 deletions docs/zh-Hans/command-word/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,21 @@ $fresnsResp = \FresnsCmdWord::plugin('FresnsEmail')->sendEmail($wordBody);
**处理异常情况**
```php
if ($fresnsResp->isErrorResponse()) {
return $fresnsResp->errorResponse(); //报错时,输出全量参数(code+message+data)
return $fresnsResp->getErrorResponse();
}
```

**处理正常情况**
```php
$fresnsResp->getOrigin(); //获取原始数据
$fresnsResp->getOrigin(); //获取原始数据(code+message+data)

$fresnsResp->getCode(); //只获取 code
$fresnsResp->getMessage(); //只获取 message
$fresnsResp->getData(); //只获取 data 全量数据
$fresnsResp->getData('user.nickname'); //只获取 data 中指定参数,比如 data.user.nickname

$fresnsResp->isSuccessResponse(); //判断请求是否为 true
$fresnsResp->isErrorResponse(); //判断请求是否为 false
$fresnsResp->getErrorResponse(); //获取错误响应对象

$fresnsResp->getErrorResponse(); //内部使用输出原始数据,API 调用输出 JSON
```

0 comments on commit 14de477

Please sign in to comment.