We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesWallet KitRESTAPIs Called by Your ServerAPIs for Creating, Querying, and Modifying a PassGift Card APIsUpdating Part of a Gift Card Model

Updating Part of a Gift Card Model

Function

Updates some parameters of a gift card model based on modelId.

Scenario

This API is used to update some parameters of a gift card model based on modelId. All parameters except passTypeIdentifier and passStyleIdentifier (namely, modelId) can be updated. After you modify a pass model, all passes using this model and claimed by users will be updated accordingly. For details about the update scenarios, please refer to Synchronous and Asynchronous Update.

Restrictions

You need to create an app in AppGallery Connect and apply for services corresponding to the passes. In addition, only a model that has been added to the Huawei server can be updated.

Prototype

Protocol

HTTPS PATCH

Direction

Developer server -> Huawei server

URL

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

Set the {url} variable based on the region where the server is located. For details, please refer to Wallet Server Addresses.

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

URL Parameters

Expand

Parameter

Mandatory/Optional

Type

Description

modelId

Mandatory

String

Unique identifier of a pass model. It must be unique across all models sharing the same appId. The value contains only letters, digits, dots (.), hyphens (-), and underscores (_).

Request Parameters

Request Header

Expand

Parameter

Mandatory/Optional

Type

Description

Authorization

Mandatory

String

Authorization code. For details about how to obtain the value, please refer to the Client Credentials mode in OAuth 2.0-based Authentication. In this mode, client_id and client_secret are respectively the App ID and App key of the app that you created in AppGallery Connect. Concatenate the value of access_token to the end of Bearer, with a space in between, to generate the value of Authorization.

Content-Type

Mandatory

String

The value is always application/json;charset=utf-8.

Accept

Mandatory

String

The value is always application/json;charset=utf-8.

Request Body

Expand

Parameter

Mandatory/Optional

Type

Description

For details, please refer to the HwWalletObject Parameters.

Mandatory

HwWalletObject

Pass model to be updated.

Request Example

Collapse
Word wrap
Dark theme
Copy code
  1. PATCH /hmspass/v1/giftcard/model/giftCardModelTest 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.cnm
  6. {
  7. "fields": {
  8. "commonFields": [
  9. {
  10. "key": "logo",
  11. "value": "https://www.huawei.com/new_image_url.png"
  12. }
  13. ]
  14. }
  15. }

Response Parameters

When the result code is 200:

Expand

Parameter

Type

Description

For details, please refer to the HwWalletObject parameters.

HwWalletObject

Updated pass model.

Response Example

Collapse
Word wrap
Dark theme
Copy code
  1. HTTP/1.1 200 OK
  2. Content-Type: application/json
  3. {
  4. "passVersion": "2.0",
  5. "passTypeIdentifier": "hwpass.com.huawei.wallet.giftcard.test",
  6. "passStyleIdentifier": "giftCardModelTest",
  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/new_image_url.png"
  20. },
  21. {
  22. "key": "backgroundImage",
  23. "value": "https://www.huawei.com/XXX.png"
  24. },
  25. {
  26. "key": "name",
  27. "value": "Christmas Gift Card"
  28. },
  29. {
  30. "key": "merchantName",
  31. "value": "XXX Super Market",
  32. "localizedValue": "merchantNameI18N"
  33. },
  34. {
  35. "key": "eventNumber",
  36. "value": "223421510894697",
  37. "label": "Event Number",
  38. "localizedValue": "eventNameI18n"
  39. }
  40. ],
  41. "appendFields": [
  42. {
  43. "key": "backgroundColor",
  44. "value": "#483d8b"
  45. },
  46. {
  47. "key": "hotline",
  48. "value": "8006011450"
  49. },
  50. {
  51. "key": "website",
  52. "value": "https://www.huawei.com"
  53. }
  54. ],
  55. "messageList": [
  56. {
  57. "key": "message[0]",
  58. "value": "Welcome to use this gift card.",
  59. "label": "Welcome"
  60. },
  61. {
  62. "key": "message[1]",
  63. "value": "This gift card can only be used on Christmas Eve.",
  64. "label": "Explanation"
  65. }
  66. ],
  67. "imageList": [
  68. {
  69. "key": "mainImage[0]",
  70. "value": "https://www.huawei.com/XXX0.png"
  71. },
  72. {
  73. "key": "mainImage[1]",
  74. "value": "https://www.huawei.com/XXX1.png"
  75. },
  76. {
  77. "key": "mainImage[2]",
  78. "value": "https://www.huawei.com/XXX2.png"
  79. }
  80. ],
  81. "localized": [
  82. {
  83. "key": "merchantNameI18N",
  84. "language": "zh-cn",
  85. "value": "XXX Super Market"
  86. },
  87. {
  88. "key": "merchantNameI18N",
  89. "language": "en",
  90. "value": "XXX Super Market"
  91. },
  92. {
  93. "key": "eventNumberI18N",
  94. "language": "zh-cn",
  95. "value": "Event Number"
  96. },
  97. {
  98. "key": "eventNumberI18N",
  99. "language": "en",
  100. "value": "Event Number"
  101. }
  102. ]
  103. }
  104. }

Result Codes

For details, please refer to Result Codes.

Call Example

Collapse
Word wrap
Dark theme
Copy code
  1. public HwWalletObject partialUpdateWalletModel(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 obtain the response.
  10. HttpEntity<JSONObject> entity = new HttpEntity<>(jsonObj, header);
  11. ResponseEntity<HwWalletObject> response =
  12. REST_TEMPLATE.exchange(walletServerUrl, HttpMethod.PATCH, entity, HwWalletObject.class);
  13. // Return the updated wallet model.
  14. return response.getBody();
  15. }
Search in References
Enter a keyword.