文档管理中心
我的

单个查询礼品卡个人化实例

功能介绍

根据instanceId获取对应的礼品卡个人化实例。

场景描述

开发者可以调用该API,查看某一个已添加到华为钱包服务器的礼品卡个人化实例。

使用约束

需在华为AGC网站上创建应用并申请卡券对应的服务。

接口原型

承载协议

HTTPS GET

接口方向

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

接口URL

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

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

数据格式

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

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

路径参数

展开

参数

是否必选

参数类型

描述

instanceId

是

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”。

请求示例

GET /hmspass/v1/giftcard/instance/30001 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

响应参数

错误码为200时:

展开

参数

参数类型

描述

详见HwWalletObject参数描述

HwWalletObject

instanceId对应的卡券实例

响应示例

HTTP/1.1 200 OK
Content-Type: application/json
{
  "passTypeIdentifier": "hwpass.com.huawei.wallet.giftcard.test",
  "passStyleIdentifier": "giftCardModelTest",
  "organizationPassId": "356688115",
  "serialNumber": "30001",
  "fields": {
    "status": {
      "state": "active",
      "effectTime": "2019-11-13T00:00:00.111Z",
      "expireTime": "2028-11-20T00:00:00.111Z"
    },
    "barCode": {
      "text": "1118466050",
      "type": "codabar",
      "value": "1118466050",
      "encoding": "UTF-8"
    },
    "commonFields": [
      {
        "key": "cardNumber",
        "value": "356688115"
      },
      {
        "key": "balance",
        "value": "$199"
      },
      {
        "key": "balanceRefreshTime",
        "value": "Thursday, Dec 12,2018"
      },
      {
        "key": "pin",
        "value": "118.91",
        "label": "PIN Number"
      }
    ]
  }
}

错误码

详见错误码。

调用示例

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