# API Documentation for Hr2025Controller
## Base URLs
- **Production**: `https://crm.twsamsungcampaign.com/`
- **Staging**: `https://crmdemo.twsamsungcampaign.com/`
## Endpoints
### 1. Store Form Submission
- **Method**: `POST`
- **Endpoint**: `/api/hr2025/store`
- **Description**: Submits a new HR 2025 form record after validation and converts question arrays to a string format (e.g., `A1|A3|A5`).
- **Request Body**:
```json
{
"first_name": "string, max 255 characters",
"last_name": "string, max 255 characters",
"phone": "string, Taiwan format (09xxxxxxxxx)",
"email": "string, valid email",
"question1": "array of integers",
"question2": "array of integers",
"question3": "array of integers",
"question4": "array of integers",
"question5": "array of integers",
"question6": "array of integers"
}
```
**Example**:
```json
{
"first_name": "John",
"last_name": "Doe",
"phone": "0912345678",
"email": "john.doe@example.com",
"question1": [1, 3, 5],
"question2": [2, 4],
"question3": [1, 5],
"question4": [3],
"question5": [2],
"question6": [1, 4]
}
```
- **Response**:
- **Success (200)**:
```json
{
"message": "Form submitted successfully",
"data": {
"id": integer,
"first_name": "string",
"last_name": "string",
"phone": "string",
"email": "string",
"question1": "string (e.g., A1|A3|A5)",
"question2": "string",
"question3": "string",
"question4": "string",
"question5": "string",
"question6": "string",
"created_at": "timestamp",
"updated_at": "timestamp"
}
}
```
- **Error (400)**:
```json
{
"message": "活動已結束"
}
```
- **Validation Error (422)**: Returns validation errors.
### 2. Share Record
- **Method**: `POST`
- **Endpoint**: `/api/hr2025/share`
- **Description**: Marks an existing HR 2025 record as shared by updating `is_shared` to `1`.
- **Request Body**:
```json
{
"line_user_id": "line_user_id"
}
```
**Example**:
```json
{
"line_user_id": "xxxx"
}
```
- **Response**:
- **Success (200)**:
```json
{
"message": "成功"
}
```
- **Error (400)**:
```json
{
"message": "活動已結束"
}
```
- **Not Found (404)**: If the record ID does not exist.
- **Validation Error (422)**: Returns validation errors.
### 3. Check Record
- **Method**: `POST`
- **Endpoint**: `/api/hr2025/check`
- **Description**: Verifies a user's HR 2025 record using their LINE User ID and an optional hashed ID.
- **Request Body**:
```json
{
"line_user_id": "string, required",
"hashed_id": "string, optional"
}
```
**Example**:
```json
{
"line_user_id": "U1234567890abcdef",
"hashed_id": "abc123xyz"
}
```
- **Response**:
- **Success (200)**:
```json
{
"success": true,
"message": "成功"
}
```
- **Not Bound (201)**:
```json
{
"success": false,
"message": "未綁定"
}
```
- **Error (400)**:
```json
{
"success": false,
"message": "非好友 | 無紀錄 | 驗證碼錯誤 | 驗證碼已使用"
}
```
- **Validation Error (422)**: Returns validation errors.
- **Notes**:
- Validates `line_user_id` and optional `hashed_id`.
- Checks user existence and record association.