> For the complete documentation index, see [llms.txt](https://docs.contiple.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.contiple.com/eng/api-guide/open-api/data-connection.md).

# Customer Information Integration

{% hint style="info" %}
This feature allows you to view information from an external service (not Contiple) within the ticket management system by configuring the API settings.
{% endhint %}

***

## **➊ API Authentication Method**

#### **1-1. Security Key**

* Configure the API encryption settings in **\[Customer Info Management] → \[Customer Info. Contact] → \[API Settings]**.
* An Security key is automatically generated and can be used for API authentication.

#### **1-2. Authorization String Generation**

> 다음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;
    }
}
```

***

## **➋ Customer Information Integration API**

#### **(1) Interface Description**

| Interface Name                           | Protocol | Request Format | Encoding | Response Format | URL         | Access Required       |
| ---------------------------------------- | -------- | -------------- | -------- | --------------- | ----------- | --------------------- |
| **Customer Information Integration API** | HTTPS    | POST           | UTF-8    | JSON            | Default URL | Common Authentication |

***

#### **(2) Request parameter**

| Name                        | Field (Parameter) | Type   | Required | Description |
| --------------------------- | ----------------- | ------ | -------- | ----------- |
| **Configured Query Fields** | callNum           | String | O        |             |
|                             | nation            | String |          |             |

***

#### **(3) Request body**

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

***

#### **(4) Response data**

<table><thead><tr><th width="213">Name</th><th width="160">Field (Parameter)</th><th width="148">Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><strong>Configured Result Fields</strong></td><td>userName</td><td>String</td><td></td><td></td></tr><tr><td></td><td>id</td><td>String</td><td></td><td></td></tr></tbody></table>

***

#### **(5) Response Body**

```json
{
  "data": {
    "userName": "test",
    "id": "testId"
    }
}
```

***

## **➌ Return Result**

#### **(1) Parameter Definition**

<table><thead><tr><th width="175">Name</th><th width="217">Field (Parameter)</th><th width="141">Type</th><th width="94">Required</th><th>Description</th></tr></thead><tbody><tr><td><strong>Return Result on Success</strong></td><td>data</td><td>JSON</td><td>O</td><td></td></tr><tr><td></td><td>Returns the configured result values defined in Contiple(OC).</td><td>String</td><td>O</td><td></td></tr></tbody></table>

<table><thead><tr><th width="175">Name</th><th width="141">Field (Parameter)</th><th width="180">Type</th><th width="132">Required</th><th>Description</th></tr></thead><tbody><tr><td><strong>Return Result on Failure</strong></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>

***

#### **(2) HTTP Status code**

| Return Code          | Contiple(OC) Message                       |
| -------------------- | ------------------------------------------ |
| 200 : SUCCESS        | Request successful                         |
| 400 : Bad Request    | No data found                              |
| 403 : Forbidden      | Access to the requested resource is denied |
| 404 : Not Data Found | An error occurred on the server            |
| 500 : Server Error   | Invalid request or error occurred          |

***

#### **(3) Response Example**

```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
  }
}
```
