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 PassBoarding Pass APIsAdding Messages to a Boarding Pass Model

Adding Messages to a Boarding Pass Model

Function

Adds messages to a boarding pass model based on modelId.

Scenario

This API is used to add one or more messages to a boarding pass model based on modelId. 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, messages can be added only to a model that has been added to the Huawei server.

Prototype

Protocol

HTTPS POST

Direction

Developer server -> HUAWEI Account Kit server

URL

{url}/hmspass/v1/flight/model/{modelId}/addMessage

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

messageList

Mandatory

List<ValueObject>

Messages to be added.

Request Example

Collapse
Word wrap
Dark theme
Copy code
  1. POST /hmspass/v1/flight/model/flightModelTest/addMessage 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. "messageList": [
  8. {
  9. "key": "message[10]",
  10. "value": "Hello everyone!"
  11. }
  12. ]
  13. }

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.flight.test",
  6. "passStyleIdentifier": "flightModelTest",
  7. "organizationName": "XXX Airline",
  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": "merchantName",
  23. "value": "XXX Airline",
  24. "localizedValue": "merchantNameI18N"
  25. },
  26. {
  27. "key": "flightNumber",
  28. "value": "MU2887"
  29. },
  30. {
  31. "key": "departureTerminal",
  32. "value": "T3"
  33. },
  34. {
  35. "key": "boardingGate",
  36. "value": "108"
  37. },
  38. {
  39. "key": "departureCity",
  40. "value": "Nanjing"
  41. },
  42. {
  43. "key": "arrivalTerminal",
  44. "value": "T3"
  45. },
  46. {
  47. "key": "arrivalCity",
  48. "value": "Shenzhen"
  49. }
  50. ],
  51. "appendFields": [
  52. {
  53. "key": "backgroundColor",
  54. "value": "#FF1C2635"
  55. }
  56. ],
  57. "imageList": [
  58. {
  59. "key": "mainImage[0]",
  60. "value": "https://www.huawei.com/XXX0.png"
  61. },
  62. {
  63. "key": "mainImage[1]",
  64. "value": "https://www.huawei.com/XXX1.png"
  65. },
  66. {
  67. "key": "mainImage[2]",
  68. "value": "https://www.huawei.com/XXX2.png"
  69. }
  70. ],
  71. "messageList": [
  72. {
  73. "key": "message[0]",
  74. "value": "Enjoy the journey!"
  75. },
  76. {
  77. "key": "message[10]",
  78. "value": "Hello everyone!"
  79. }
  80. ],
  81. "timeList": [
  82. {
  83. "key": "departureTime",
  84. "value": "2020-05-09T12:30:00.010Z"
  85. },
  86. {
  87. "key": "scheduledDepartureTime",
  88. "value": "2020-05-09T10:30:00.010Z"
  89. },
  90. {
  91. "key": "boardingTime",
  92. "value": "2020-05-09T12:00:00.010Z"
  93. },
  94. {
  95. "key": "arrivalTime",
  96. "value": "2020-05-09T14:30:00.010Z"
  97. },
  98. {
  99. "key": "scheduledArrivalTime",
  100. "value": "2020-05-09T12:30:00.010Z"
  101. }
  102. ],
  103. "localized": [
  104. {
  105. "key": "merchantNameI18N",
  106. "language": "zh-cn",
  107. "value": "XXX Airline"
  108. },
  109. {
  110. "key": "merchantNameI18N",
  111. "language": "en",
  112. "value": "XXX Airline"
  113. }
  114. ]
  115. }
  116. }

Result Codes

For details, please refer to Result Codes.

Call Example

Collapse
Word wrap
Dark theme
Copy code
  1. public HwWalletObject addMessageToHwWalletObject(String url, String resourceId, 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.replace("addMessage", "") + resourceId + "/addMessage";
  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.POST, entity, HwWalletObject.class);
  13. // Return the updated HwWalletObject.
  14. return response.getBody();
  15. }