1. 汇率数据获取

服务器收到汇率查询请求后,调用该接口获取服务或者服务目录信息。

接口公共定义,参考Fulfillment API接口定义

下面描述的为接口内针对汇率查询的定义,请求参数定义通过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

/

消息样例

请求

汇率查询请求样例如下:

  1. {
  2. "version": "1.0",
  3. "session": {
  4.  "isNew": "true",
  5.  "sessionId": "123456"
  6. },
  7. "endpoint": {
  8.  "auth": {
  9.   "apiAccessToken": "",
  10.   "application": {
  11.    "appId": "da8afea3619a411fb59bf5f673b7ff1e"
  12.   }
  13.  },
  14.  "device": {
  15.   "deviceId": "2906",
  16.   "supportedInterfaces": {}
  17.  },
  18.  "audioPlayer": {
  19.   "token": "",
  20.   "posInMilliSeconds": "",
  21.   "playStatus": ""
  22.  },
  23.  "locale": "en_GB"
  24. },
  25. "header": {
  26.  "type": "IntentRequest",
  27.  "prodPkgName": "com.huawei.intelligent",
  28.  "timestamp": "15869741258"
  29. },
  30. "inquire": {
  31.  "inquireId": "efd1f6ca-8fdf-11e8-9eb6-529269fb1459",
  32.  "intent": {
  33.   "apiKey": "rate-exchange",
  34.   "slots": {
  35.    "fromCurrency": {
  36.     "name": "fromCurrency",
  37.     "values": [
  38.      {
  39.       "real": "CNY"
  40.      }
  41.     ]
  42.    },
  43.    "number": {
  44.     "name": "number",
  45.     "values": [
  46.      {
  47.       "real": "1"
  48.      }
  49.     ]
  50.    },
  51.    "toCurrency": {
  52.     "name": "toCurrency",
  53.     "values": [
  54.      {
  55.       "real": "JPY"
  56.      }
  57.     ]
  58.    }
  59.   }
  60.  },
  61.  "utterance": {
  62.   "original": ""
  63.  }
  64. }
  65. }

响应

汇率查询响应样例如下:

  1. {
  2. "version": "1.0",
  3. "reply": {
  4.  "displayText": "displayText",
  5.  "commands": [
  6.   {
  7.    "head": {
  8.     "namespace": "Render",
  9.     "name": "DisplayTemplate"
  10.    },
  11.    "body": {
  12.     "templateType": "rate-exchange",
  13.     "templateContent": {
  14.      "items": {
  15.       "items": [
  16.        {
  17.         "answer": "15.137701",
  18.         "fromCurrency": "CNY",
  19.         "number": "1",
  20.         "toCurrency": "JPY",
  21.         "extendObject": {},
  22.         "updateTime": "20200501080000000",
  23.         "detailUrl": {
  24.          "webURL": "string",
  25.          "deepLink": {
  26.           "url": "string",
  27.           "appName": "string",
  28.           "appPackage": "string",
  29.           "minVersion": 0,
  30.           "minAndroidAPILevel": 0
  31.          },
  32.          "quickApp": {
  33.           "url": "string",
  34.           "minPlatformVersion": 0,
  35.           "minVersion": 0
  36.          }
  37.         }
  38.        }
  39.       ],
  40.       "categoryId": "string",
  41.       "categoryName": "string",
  42.       "shortAnswer": "The exchange rate between us dollar and RMB is 6.932601"
  43.      }
  44.     }
  45.    }
  46.   }
  47.  ]
  48. },
  49. "isEndSession": true,
  50. "errorCode": "0",
  51. "errorMessage": "OK"
  52. }

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