文档管理中心
API参考钱包服务REST开发者调用接口卡券创建、查询、修改接口优惠券接口全量更新优惠券模板

全量更新优惠券模板

功能介绍

重写modelId对应的优惠券模板。

场景描述

开发者可以调用该API,全量更新modelId对应的优惠券模板。除了passTypeIdentifier和passStyleIdentifier(modelId),其余字段均可更新。卡券模板被更新后,与之关联的已被华为钱包用户领取的卡券都会被相应地更新,不同的更新场景请查看同步/异步更新规则

使用约束

需在华为AGC网站上创建应用并申请卡券对应的服务。只能更新已添加到华为服务器的卡券模板。

接口原型

承载协议

HTTPS PUT

接口方向

开发者服务器->华为钱包服务器

接口URL

{url}/hmspass/v1/offer/model/{modelId}

{url}变量需要开发者根据服务器所属区域自行选择,请参见钱包服务器地址

数据格式

请求消息:Content-Type: application/json

响应消息:Content-Type: application/json

路径参数

展开

参数

是否必选

参数类型

描述

modelId

String

卡券模板的唯一标识符。这个ID在同一个appId下唯一。这个ID只能包含字母、数字和(.)、(-)、(_)。

请求参数

Request Header

展开

参数

是否必选

参数类型

描述

Authorization

String

鉴权码。获取方式详见基于OAuth 2.0开放鉴权,请使用“客户端模式”。“client_id”和“client_secret”即为开发者在华为AGC网站上创建应用后获取的“App ID”和“App key”。将获取到的“access_token”的值拼接在字符串“Bearer”之后,以空格符相隔,组成“Authorization”参数的值。

Content-Type

String

固定值:“application/json;charset=utf-8”。

Accept

String

固定值:“application/json;charset=utf-8”。

Request Body

展开

参数

是否必选

参数类型

描述

详见HwWalletObject参数描述

HwWalletObject

待更新的卡券模板

请求示例

收起
自动换行
深色代码主题
复制
  1. PUT /hmspass/v1/offer/model/offerModelTest HTTP/1.1
  2. Content-Type: application/json;charset=utf-8
  3. Authorization: Bearer ***
  4. Accept: application/json;charset=utf-8
  5. Host: wallet-passentrust-drcn.cloud.huawei.com.cn
  6. {
  7. "passVersion": "2.0",
  8. "passTypeIdentifier": "hwpass.com.huawei.wallet.offer.test",
  9. "passStyleIdentifier": "offerModelTest",
  10. "organizationName": "Huawei",
  11. "fields": {
  12. "countryCode": "CN",
  13. "locationList": [
  14. {
  15. "longitude": "114.0679603815",
  16. "latitude": "22.6592051284"
  17. }
  18. ],
  19. "commonFields": [
  20. {
  21. "key": "logo",
  22. "value": "https://www.huawei.com/XXX.png"
  23. },
  24. {
  25. "key": "name",
  26. "value": "70%-Off Coupon",
  27. "localizedValue": "nameI18N"
  28. },
  29. {
  30. "key": "providerName",
  31. "value": "YYY Producer"
  32. },
  33. {
  34. "key": "merchantName",
  35. "value": "HUAWEI Vmall",
  36. "localizedValue": "merchantNameI18N"
  37. }
  38. ],
  39. "appendFields": [
  40. {
  41. "key": "details",
  42. "value": "Detail information of this coupon.",
  43. "localizedValue": "detailsI18N"
  44. },
  45. {
  46. "key": "declaration",
  47. "value": "Coupon disclaimer provided by merchant.",
  48. "localizedValue": "declarationI18N"
  49. },
  50. {
  51. "key": "backgroundColor",
  52. "value": "#FF1C2635"
  53. }
  54. ],
  55. "messageList": [
  56. {
  57. "key": "message[0]",
  58. "value": "Don't miss this great offer!",
  59. "label": "Important!",
  60. "localizedValue": "message[0]I18N"
  61. }
  62. ],
  63. "imageList": [
  64. {
  65. "key": "mainImage[0]",
  66. "value": "https://www.huawei.com/XXX0.png"
  67. },
  68. {
  69. "key": "mainImage[1]",
  70. "value": "https://www.huawei.com/XXX1.png"
  71. },
  72. {
  73. "key": "mainImage[2]",
  74. "value": "https://www.huawei.com/XXX2.png"
  75. }
  76. ],
  77. "localized": [
  78. {
  79. "key": "merchantNameI18N",
  80. "language": "zh-cn",
  81. "value": "华为商城"
  82. },
  83. {
  84. "key": "merchantNameI18N",
  85. "language": "en",
  86. "value": "HUAWEI Vmall"
  87. },
  88. {
  89. "key": "message[0]I18N",
  90. "language": "zh-cn",
  91. "value": "不要错过这次的优惠!"
  92. },
  93. {
  94. "key": "message[0]I18N",
  95. "language": "en",
  96. "value": "Don't miss this great offer!"
  97. }
  98. ]
  99. }
  100. }

响应参数

错误码为200时:

展开

参数

参数类型

描述

详见HwWalletObject参数描述

HwWalletObject

已更新的卡券模板

响应示例

收起
自动换行
深色代码主题
复制
  1. HTTP/1.1 200 OK
  2. Content-Type: application/json
  3. {
  4. "passVersion": "2.0",
  5. "passTypeIdentifier": "hwpass.com.huawei.wallet.offer.test",
  6. "passStyleIdentifier": "offerModelTest",
  7. "organizationName": "Huawei",
  8. "fields": {
  9. "countryCode": "CN",
  10. "locationList": [
  11. {
  12. "longitude": "114.0679603815",
  13. "latitude": "22.6592051284"
  14. }
  15. ],
  16. "commonFields": [
  17. {
  18. "key": "logo",
  19. "value": "https://www.huawei.com/XXX.png"
  20. },
  21. {
  22. "key": "name",
  23. "value": "70%-Off Coupon",
  24. "localizedValue": "nameI18N"
  25. },
  26. {
  27. "key": "providerName",
  28. "value": "YYY Producer"
  29. },
  30. {
  31. "key": "merchantName",
  32. "value": "HUAWEI Vmall",
  33. "localizedValue": "merchantNameI18N"
  34. }
  35. ],
  36. "appendFields": [
  37. {
  38. "key": "details",
  39. "value": "Detail information of this coupon.",
  40. "localizedValue": "detailsI18N"
  41. },
  42. {
  43. "key": "declaration",
  44. "value": "Coupon disclaimer provided by merchant.",
  45. "localizedValue": "declarationI18N"
  46. },
  47. {
  48. "key": "backgroundColor",
  49. "value": "#FF1C2635"
  50. }
  51. ],
  52. "messageList": [
  53. {
  54. "key": "message[0]",
  55. "value": "Don't miss this great offer!",
  56. "label": "Important!",
  57. "localizedValue": "message[0]I18N"
  58. }
  59. ],
  60. "imageList": [
  61. {
  62. "key": "mainImage[0]",
  63. "value": "https://www.huawei.com/XXX0.png"
  64. },
  65. {
  66. "key": "mainImage[1]",
  67. "value": "https://www.huawei.com/XXX1.png"
  68. },
  69. {
  70. "key": "mainImage[2]",
  71. "value": "https://www.huawei.com/XXX2.png"
  72. }
  73. ],
  74. "localized": [
  75. {
  76. "key": "merchantNameI18N",
  77. "language": "zh-cn",
  78. "value": "华为商城"
  79. },
  80. {
  81. "key": "merchantNameI18N",
  82. "language": "en",
  83. "value": "HUAWEI Vmall"
  84. },
  85. {
  86. "key": "message[0]I18N",
  87. "language": "zh-cn",
  88. "value": "不要错过这次的优惠!"
  89. },
  90. {
  91. "key": "message[0]I18N",
  92. "language": "en",
  93. "value": "Don't miss this great offer!"
  94. }
  95. ]
  96. }
  97. }

错误码

详见错误码

调用示例

收起
自动换行
深色代码主题
复制
  1. public HwWalletObject fullUpdateWalletModel(String url, String modelId, String body) {
  2. // Construct the http header.
  3. HttpHeaders header = constructHttpHeaders();
  4. // Construct the http URL.
  5. String baseUrl = ConfigHelper.instants().getValue("walletServerBaseUrl");
  6. String walletServerUrl = baseUrl + url + modelId;
  7. // Construct the http body.
  8. JSONObject jsonObj = JSONObject.parseObject(body);
  9. // Send the http request and get response.
  10. HttpEntity<JSONObject> entity = new HttpEntity<>(jsonObj, header);
  11. ResponseEntity<HwWalletObject> response =
  12. REST_TEMPLATE.exchange(walletServerUrl, HttpMethod.PUT, entity, HwWalletObject.class);
  13. // Return the updated wallet model.
  14. return response.getBody();
  15. }
在 API参考 中进行搜索
请输入您想要搜索的关键词