You need to create an app in AppGallery Connect and apply for services corresponding to the passes.
Protocol |
HTTPS GET |
|---|---|
Direction |
Developer server -> Huawei server |
URL |
{url}/hmspass/v1/transit/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 |
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 Header
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. |
GET /hmspass/v1/transit/model/transitModelTest HTTP/1.1 Content-Type: application/json;charset=utf-8 Authorization: Bearer *** Accept: application/json;charset=utf-8 Host: wallet-passentrust-drcn.cloud.huawei.com.cn
When the result code is 200:
Parameter |
Type |
Description |
|---|---|---|
For details, please refer to the HwWalletObject Parameters. |
Pass model that is obtained based on modelId. |
HTTP/1.1 200 OK
Content-Type: application/json
{
"passVersion": "1.0",
"passTypeIdentifier": "hwpass.com.huawei.wallet.transit.test",
"passStyleIdentifier": "transitModelTest",
"organizationName": "XXX Railway",
"fields": {
"countryCode": "CN",
"locationList": [
{
"longitude": "114.0679603815",
"latitude": "22.6592051284"
}
],
"commonFields": [
{
"key": "logo",
"value": "https://www.huawei.com/XXX.png"
},
{
"key": "merchantName",
"value": "XXX Railway",
"localizedValue": "merchantNameI18N"
}
],
"appendFields": [
{
"key": "backgroundColor",
"value": "#FF37C09A"
},
{
"key": "ticketFaceValue",
"value": "$127"
}
],
"imageList": [
{
"key": "mainImage[0]",
"value": "https://www.huawei.com/XXX0.png"
},
{
"key": "mainImage[1]",
"value": "https://www.huawei.com/XXX1.png"
},
{
"key": "mainImage[2]",
"value": "https://www.huawei.com/XXX2.png"
}
],
"messageList": [
{
"key": "message[0]",
"value": "Have a nice trip!"
}
],
"ticketInfoList": [
{
"key": "departureStationName",
"value": "Euston"
},
{
"key": "arrivalStationName",
"value": "Lime Street"
},
{
"key": "departureCityName",
"value": "London"
},
{
"key": "arrivalCityName",
"value": "Liverpool"
},
{
"key": "departureTime",
"value": "2019-12-09T10:49:00.010Z"
},
{
"key": "arrivalTime",
"value": "2019-12-09T13:55:00.010Z"
},
{
"key": "platform",
"value": "2"
}
],
"localized": [
{
"key": "merchantNameI18N",
"language": "zh-cn",
"value": "XXX Railway"
},
{
"key": "merchantNameI18N",
"language": "en",
"value": "XXX Railway"
}
]
}
}
public HwWalletObject getWalletModelByModelId(String url, String modelId) {
// Construct the HTTP header.
HttpHeaders header = constructHttpHeaders();
// Construct the HTTP URL.
String baseUrl = ConfigHelper.instants().getValue("walletServerBaseUrl");
String walletServerUrl = baseUrl + url + modelId;
// Send the HTTP request and obtain the response.
ResponseEntity<HwWalletObject> response =
REST_TEMPLATE.exchange(walletServerUrl, HttpMethod.GET, new HttpEntity(header), HwWalletObject.class);
// Return the wallet model with the corresponding model ID.
return response.getBody();
}