1. 汇率数据获取
服务器收到汇率查询请求后,调用该接口获取服务或者服务目录信息。
下面描述的为接口内针对汇率查询的定义,请求参数定义通过inquire.intent.slots传递
响应参数定义通过reply.commands.body.templateContent中返回,下面重点定义这两部分信息。
方法:POST
URL:/rate/exchange
请求
汇率数据请求
成员名称 | 描述 | 是否必选 | 类型 | 取值范围 |
fromCurrency | 原始币种,如CNY | 是 | string | 最大长度32位 |
number | 汇率转换值,不带默认返回1对应的汇率 | 否 | string | 最大长度32位 |
toCurrency | 目标币种,如JPY | 是 | string | 最大长度32位 |
响应
汇率数据响应,最多返回符合条件的10条汇率数据即可。排序由合作伙伴根据匹配度进行排序返回。
成员名称 | 描述 | 是否必选 | 类型 | 取值范围 |
items | 汇率列表 | 是 | ExchangeRateItem [] | serviceInfoList |
categoryId | 意图分类ID | 否 | string | 最大长度32位 |
categoryName | 意图名称,固定返回“汇率” | 是 | string | 最大长度32位 |
shortAnswer | 播报语 | 否 | string | 最大长度512位 |
结构定义
ExchangeRateItem
成员名称 | 描述 | 是否必选 | 类型 | 取值范围 |
answer | 转换后的汇率值,精确到小数点后6位 | 否 | ExchangeRateItem [] | serviceInfoList |
fromCurrency | 原始币种,如:人民币 | 否 | string | 最大长度32位 |
number | 汇率转换值 | 否 | string | 最大长度32位 |
toCurrency | 目标币种,如:日元 | 否 | string | 最大长度32位 |
extendObject | 扩展信息,预留,暂不使用 | 否 | object | / |
updateTime | 汇率数据的更新时间,UTC格式时间 | 否 | DateTimeFormatString | / |
detailUrl | 汇率详情页跳转地址 | No | Interaction | / |
消息样例
请求
汇率查询请求样例如下:
- {
- "version": "1.0",
- "session": {
- "isNew": "true",
- "sessionId": "123456"
- },
- "endpoint": {
- "auth": {
- "apiAccessToken": "",
- "application": {
- "appId": "da8afea3619a411fb59bf5f673b7ff1e"
- }
- },
- "device": {
- "deviceId": "2906",
- "supportedInterfaces": {}
- },
- "audioPlayer": {
- "token": "",
- "posInMilliSeconds": "",
- "playStatus": ""
- },
- "locale": "en_GB"
- },
- "header": {
- "type": "IntentRequest",
- "prodPkgName": "com.huawei.intelligent",
- "timestamp": "15869741258"
- },
- "inquire": {
- "inquireId": "efd1f6ca-8fdf-11e8-9eb6-529269fb1459",
- "intent": {
- "apiKey": "rate-exchange",
- "slots": {
- "fromCurrency": {
- "name": "fromCurrency",
- "values": [
- {
- "real": "CNY"
- }
- ]
- },
- "number": {
- "name": "number",
- "values": [
- {
- "real": "1"
- }
- ]
- },
- "toCurrency": {
- "name": "toCurrency",
- "values": [
- {
- "real": "JPY"
- }
- ]
- }
- }
- },
- "utterance": {
- "original": ""
- }
- }
- }
响应
汇率查询响应样例如下:
- {
- "version": "1.0",
- "reply": {
- "displayText": "displayText",
- "commands": [
- {
- "head": {
- "namespace": "Render",
- "name": "DisplayTemplate"
- },
- "body": {
- "templateType": "rate-exchange",
- "templateContent": {
- "items": {
- "items": [
- {
- "answer": "15.137701",
- "fromCurrency": "CNY",
- "number": "1",
- "toCurrency": "JPY",
- "extendObject": {},
- "updateTime": "20200501080000000",
- "detailUrl": {
- "webURL": "string",
- "deepLink": {
- "url": "string",
- "appName": "string",
- "appPackage": "string",
- "minVersion": 0,
- "minAndroidAPILevel": 0
- },
- "quickApp": {
- "url": "string",
- "minPlatformVersion": 0,
- "minVersion": 0
- }
- }
- }
- ],
- "categoryId": "string",
- "categoryName": "string",
- "shortAnswer": "The exchange rate between us dollar and RMB is 6.932601"
- }
- }
- }
- }
- ]
- },
- "isEndSession": true,
- "errorCode": "0",
- "errorMessage": "OK"
- }
2. 垂类公共结构
结构
Interaction
成员名称 | 描述 | 是否必选 | 类型 | 取值范围 |
webURL | 点击整个卡片需要实际跳转的H5链接,要求为https地址 | 否 | string | 最大长度:512 |
deepLink | 对原生App的跳转 | 否 | NativeAppLinkInteraction | / |
quickApp | 对快应用的扩展 | 否 | QuickAppLinkInteraction | / |
NativeAppLinkInteraction
对原生App的跳转
成员名称 | 描述 | 是否必选 | 类型 | 取值范围 |
url | App的deeplink地址 | 是 | string | 最大长度:512 |
appName | App名称 | 否 | string | 最大长度:256 |
appPackage | App包名 | 是 | string | 最大长度:256 |
minVersion | 支持的APP的最小版本号VersionCode | 是 | long | / |
minAndroidAPILevel | 所需android最小API Level | 否 | long | / |
QuickAppLinkInteraction
对快应用的扩展
成员名称 | 描述 | 是否必选 | 类型 | 取值范围 |
url | 快应用的deeplink地址 | 是 | string | 最大长度:512 |
minPlatformVersion | 所需快应用引擎最小版本号。 | 是 | long | / |
minVersion | 支持的快应用的最小版本号VersionCode | 是 | long | / |
DateTimeFormatString
时间格式
成员名称 | 描述 | 是否必选 | 类型 | 取值范围 |
DateTimeFormatString | 时间格式,yyyyMMddHHmmssSSS | 是 | string | 最大长度:512 |