目录

Querying a Transit Pass Instance

Function

Obtains a transit pass instance based on instanceId.

Scenario

This API is used to obtain a transit pass instance that has been added to the Huawei server.

Restrictions

You need to create an app in AppGallery Connect and apply for services corresponding to the passes.

Prototype

Protocol

HTTPS GET

Direction

Developer server -> Huawei server

URL

{url}/hmspass/v1/transit/instance/{instanceId}

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

Parameter

Mandatory/Optional

Type

Description

instanceId

Mandatory

String

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

Request Parameters

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.

Request Example

GET /hmspass/v1/transit/instance/60001 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

Response Parameters

When the result code is 200:

Parameter

Type

Description

For details, please refer to the HwWalletObject Parameters.

HwWalletObject

Pass instance that is identified by instanceId.

Response Example

HTTP/1.1 200 OK
Content-Type: application/json
{
  "organizationPassId": "5623489611",
  "passTypeIdentifier": "hwpass.com.huawei.wallet.transit.test",
  "passStyleIdentifier": "transitModelTest",
  "serialNumber": "60001",
  "fields": {
    "status": {
      "state": "active",
      "effectTime": "2019-11-13T00:00:00.111Z",
      "expireTime": "2020-11-20T00:00:00.111Z"
    },
    "barCode": {
      "text": "562348969211212",
      "type": "codabar",
      "value": "562348969211212",
      "encoding": "UTF-8"
    },
    "commonFields": [
      {
        "key": "ticketStatus",
        "value": "Not Used"
      }
    ],
    "ticketInfoList": [
      {
        "key": "carriage",
        "value": "8"
      },
      {
        "key": "seatNumber",
        "value": "7A"
      },
      {
        "key": "seatCoach",
        "value": "14"
      }
    ]
  }
}

Result Codes

For details, please refer to Result Codes.

Call Example

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();
}