# 顧客情報連動

***

## **➊** API認証方法 <a href="#authorization" id="authorization"></a>

### **1-1.** 暗号化キー **(Security Key)** <a href="#security-key" id="security-key"></a>

* \[顧客情報管理]→\[顧客情報連動]→\[API設定]で「**暗号化可否**」を「**はい**」に設定します。
* 暗号化キーが自動生成され、そのキーをAPI認証に活用することができます。

***

### **1-2. Authorization 文字列の生成方法** <a href="#authorization-string" id="authorization-string"></a>

> 次の 2 つの方法で文字列を生成できます。

**① HmacSHA256 で暗号化**

**② (request URI + パラメータ値(json) + 現在のUTC 時間値)文字列に対して暗号化**

* **Java 例題**

```java
String token= request.getHeader("Authorization");
String time = request.getHeader("X-TC-Timestamp");
if (!StringUtils.isNumeric(time)) {
    logger.error("X-TC-Timestamp is not numeric: " + time);
    throw new Exception("error.bad_request");
}
DateTime date = null;
date = new DateTime(Long.parseLong(time));
if (date.minusMinutes(5).isAfterNow() || date.plusMinutes(5).isBeforeNow()) {
    logger.error("X-TC-Timestamp is expired: " + time + ", now timestamp: " + Calendar.getInstance().getTimeInMillis());
    throw new Exception("error.bad_request");
}

String apiKey = "bf7769e5321448de88838cdb";
String content= new String(IOUtils.toByteArray(request.getInputStream()), StandardCharsets.UTF_8) + time;

SecretKeySpec signingKey = new SecretKeySpec(apiKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
Mac mac = Mac.getInstance(signingKey.getAlgorithm());
mac.init(signingKey);
byte[] rawHmac = mac.doFinal(content.getBytes(StandardCharsets.UTF_8));
String localAuthorization = new String(Base64.encodeBase64(rawHmac));
logger.debug("Local token: " + localAuthorization);
if (StringUtils.equals(token, localAuthorization)) {
    return true;
}  else {
        logger.info("Local sha2 token: " + localAuthorization);
        return false;
    }
}
```

***

## **➋** 顧客情報連動API <a href="#api" id="api"></a>

#### **(1) インターフェース説明** <a href="#api-interface" id="api-interface"></a>

| インターフェース名 | プロトコル | 呼び出し方向 | エンコード | リクエストパラメータ形式 | URL   | 접근제한 여부 |
| --------- | ----- | ------ | ----- | ------------ | ----- | ------- |
| 顧客情報連動API | HTTPS | POST   | UTF-8 | JSON         | 基本URL | 공통 인증   |

***

#### **(2) リクエストパラメータ定義** <a href="#api-request" id="api-request"></a>

| 名称       | 変数      | データタイプ | 必須 | 説明 |
| -------- | ------- | ------ | -- | -- |
| 設定した参照項目 | callNum | String | O  |    |
|          | nation  | String |    |    |

***

#### **(3) Request Body** <a href="#api-request-body" id="api-request-body"></a>

```json
{ 
  "callNum":"1",
  "nation":"korea"
}
```

***

#### **(4)** 結果データ <a href="#api-response-data" id="api-response-data"></a>

<table><thead><tr><th width="175">名称</th><th width="217">変数</th><th width="141">データタイプ</th><th width="94">必須</th><th>説明</th></tr></thead><tbody><tr><td>成功時の返却結果</td><td>data</td><td>JSON</td><td>O</td><td></td></tr><tr><td></td><td>Contipleにおける結果項目の設定値</td><td>String</td><td>O</td><td></td></tr></tbody></table>

<table><thead><tr><th width="175">名称</th><th width="141">変数</th><th width="180">データタイプ</th><th width="132">必須</th><th>説明</th></tr></thead><tbody><tr><td>失敗時の返却結果</td><td>error</td><td>JSON</td><td>O</td><td></td></tr><tr><td></td><td>code</td><td>String</td><td>O</td><td></td></tr><tr><td></td><td>message</td><td>String</td><td>O</td><td></td></tr><tr><td></td><td>detail</td><td>String</td><td>O</td><td></td></tr></tbody></table>

**HTTP 状態コード**

| コード                  | メッセージ                  |
| -------------------- | ---------------------- |
| 200 : SUCCESS        | 取得に成功しました              |
| 400 : Bad Request    | 取得結果がありません             |
| 403 : Forbidden      | リクエスト先サーバーに参照権限がありません  |
| 404 : Not Data Found | リクエスト先サーバーでエラーが発生しています |
| 500 : Server Error   | エラーが発生しました             |

***

#### **(5) Response Body** <a href="#api-response-body" id="api-response-body"></a>

```json
200 : OK
{
  "data": {
    "userNo": "0",
    "userId": "string",
    "gameCode": "string",
     "cashReal": "0",
     "cashBonus": "0",
     "cashTotal": "0"
    }
}

```

```json
Failure case : HTTP Status Code != 200 AND error object
{
  "error": {
    "code": 911,
    "message": "Not existing user.",
    "detail": null
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.contiple.com/jp/api/open-api/data-connection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
