---
# System prepended metadata

title: wyw-event

---

## WYW Event API Documentation

### Base URL
#### Production:
- https://www.diageocrm.com.tw/api
#### Testing: 
- https://diageocrm-com.diageoplatform.com/api

### Endpoints

#### 1. Check WYW Event Membership
##### `POST /wyw-event/check`
###### Description
Checks if a user is a loyalty member and returns their event member status.
###### Request Parameters
| Parameter | Type | Required | Validation Rules |
|-----------|------|----------|------------------|
| `line_user_id` | String | Yes | Must be present |
| `utm_campaign` | String | No | |
| `utm_medium` | String | No | |
| `utm_source` | String | No | |

###### Responses
###### Successful Response
- **Status Code**: 200 OK
- **Body**:
```json
{
  "error": false, 
  "message": "會員計劃會員",
  "data": {
      "id": 123,
      "line_user_id": "abc123",
      "point": 100,
      "is_referred": 0,
      "is_exchanged": 0,
      "is_new": 0,
      "is_answered": 0,
      "referral_count": 2,
      "referral_code": "WnwAl2",
      "created_at": "2023-04-01 12:00:00",
      "updated_at": "2023-04-05 15:30:00"
    }
}
```

###### Non-Loyalty Member
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "非會員計劃會員",
  "data": {
      "id": 123,
      "line_user_id": "abc123",
      "point": 100,
      "is_referred": 0,
      "is_exchanged": 0,
      "is_new": 0,
      "is_answered": 0,
      "referral_count": 2,
      "referral_code": "WnwAl2",
      "created_at": "2023-04-01 12:00:00",
      "updated_at": "2023-04-05 15:30:00"
    }
}
```

#### 2. Save WYW Event Result
##### `POST /wyw-event/store`
###### Description
Saves a user's WYW event result and checks for referral.
###### Request Parameters
| Parameter | Type | Required | Validation Rules |
|-----------|------|----------|------------------|
| `line_user_id` | String | Yes | Must be present |
| `result` | String | Yes | Must be present |
| `referral_code` | String | No | - |

###### Responses
###### Successful Response
- **Status Code**: 200 OK
- **Body**:
```json
{
  "error": false,
  "message": "儲存成功",
  "data": {
      "id": 123,
      "line_user_id": "abc123",
      "point": 100,
      "is_referred": 0,
      "is_exchanged": 0,
      "is_new": 0,
      "is_answered": 0,
      "referral_count": 2,
      "referral_code": "WnwAl2",
      "created_at": "2023-04-01 12:00:00",
      "updated_at": "2023-04-05 15:30:00"
    }
}
```

###### Non-Loyalty Member
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "非會員計劃會員"
}
```

###### User Not Found
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "查無此使用者"
}
```

#### 3. Exchange WYW Event Reward
##### `POST /wyw-event/exchange`
###### Description
Allows the user to exchange their WYW event reward.
###### Request Parameters
| Parameter | Type | Required | Validation Rules |
|-----------|------|----------|------------------|
| `line_user_id` | String | Yes | Must be present |

###### Responses
###### Successful Response
- **Status Code**: 200 OK
- **Body**:
```json
{
  "error": false,
  "message": "兌換成功",
  "data": {
      "id": 123,
      "line_user_id": "abc123",
      "point": 100,
      "is_referred": 0,
      "is_exchanged": 0,
      "is_new": 0,
      "referral_count": 2,
      "referral_code": "WnwAl2",
      "created_at": "2023-04-01 12:00:00",
      "updated_at": "2023-04-05 15:30:00"
    }
}
```

###### Already Exchanged
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "已兌換",
  "data": {
      "id": 123,
      "line_user_id": "abc123",
      "point": 100,
      "is_referred": 0,
      "is_exchanged": 0,
      "is_new": 0,
      "is_answered": 0,
      "referral_count": 2,
      "referral_code": "WnwAl2",
      "created_at": "2023-04-01 12:00:00",
      "updated_at": "2023-04-05 15:30:00"
    }
}
```

###### Non-Loyalty Member
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "非會員計劃會員"
}
```

###### User Not Found
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "查無此使用者"
}
```

#### 4. Save WYW Event Image
##### `POST /wyw-event/save-image`
###### Description
Saves a user-uploaded image for the WYW event.
###### Request Parameters
| Parameter | Type | Required | Validation Rules |
|-----------|------|----------|------------------|
| `image` | String | Yes | Base64-encoded image data |

###### Responses
###### Successful Response
- **Status Code**: 200 OK
- **Body**:
```json
{
  "error": false,
  "message": "成功",
  "image_url": "https://example.com/image.png"
}
```

###### Error Response
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "上傳圖片失敗"
}
```


#### 5. Answer Question WYW Event
##### `POST /wyw-event/answer`
###### Description
Saves a user-uploaded image for the WYW event.
###### Request Parameters
| Parameter | Type | Required | Validation Rules |
|-----------|------|----------|------------------|
| `id` | int | Yes | wyw event member id |

###### Responses
###### Successful Response
- **Status Code**: 200 OK
- **Body**:
```json
{
  "error": false,
  "message": "成功",
}
```

###### Error Response
- **Status Code**: 400 Bad Request
- **Body**:
```json
{
  "error": true,
  "message": "無法領取點數"
}
```
