

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Amazon Connect Cases 中的案例活动有效载荷和架构
<a name="case-event-streams-sample"></a>

当您请求在事件有效负载中包含案例数据时，数据会反映该特定编辑后的案例版本。

Amazon Connect 案例的默认限制可保证有效负载小于 256KB（ EventBus 事件的最大大小）。由于您可以自定义案例对象模型（例如，您可以在案例对象上定义自定义字段以捕获特定于业务的信息），因此案例事件架构反映了对案例对象所做的自定义，如以下示例所示（例如，查看如何将特定于客户的 UUIDs 用作 JSON 属性）。

## 案例资源的示例案例事件有效负载
<a name="example-case-event-payload"></a>

```
// Given the limits on the "includedData" configuration
// this payload is guaranteed to less than 256KB at launch.
{
    "version": "0",
    "id": "{{event ID}}",
    "detail-type": "Amazon Connect Cases Change",
    "source": "aws.cases",
    "account": "{{your AWS account ID}}",
    "time": "2022-03-16T23:43:26Z",
    "region": "{{The AWS Region of your Amazon Connect instance}}",
    "resources": [
        "arn:aws:cases:{{your Amazon Connect AWS Region}}:{{your AWS account ID}}:domain/{{case domain ID}}",
        "arn:aws:cases:{{your Amazon Connect AWS Region}}:{{your AWS account ID}}:domain/{{case domain ID}}/case/{{case ID}}"
    ],
    "detail": {
        "version": "0",
        "eventType": "CASE.UPDATED",
        "approximateChangeTime": "2022-03-16T23:16:57.893Z",  // Can be used for ordering
        "changedFieldIds": ["status", "last_updated_datetime"],
        "performedBy": {
            "user": {
                "userArn": "arn:aws:connect:{{your Amazon Connect AWS Region}}:{{your AWS account ID}}:instance/{{connect instance ID}}/user/{{connect user ID}}"        
            },
            "iamPrincipalArn": "arn:aws:iam::{{your Amazon Connect AWS Region}}:role/{{role name}}"
        },       
        "case": {
            "caseId": "{{case ID}}",
            "templateId": "{{template ID}}",
            "createdDateTime": "2022-03-16T23:16:57.893Z",
            
            // This section contains only non-null field values for the 
            // fields that customers have configured in the "includedData".
           
            // Field values included in this section reflects the case
            // after this particular change is applied.
            "fields": {
                "status": {
                    "value": {
                        "stringValue": "open"
                   }
                },
                "case_reason": {
                    "value": {
                        "stringValue": "Shipment lost"
                    }
                },
                "custom-field-uuid-1": {
                    "value": {
                        "stringValue": "Customer didn't receive the product"
                    }
                }
            }
        }
    }
}
```

## 相关项目资源的示例案例事件有效负载
<a name="example-case-event-payload"></a>

```
// Given the limits on the "includedData" configuration
// this payload is guaranteed to less than 256KB
{
    "version": "0",
    "id": "{{event ID}}",
    "detail-type": "Amazon Connect Cases Change",
    "source": "aws.cases",
    "account": "{{your AWS account ID}}",
    "time": "2022-03-16T23:43:26Z",
    "region": "{{The AWS Region of your Amazon Connect instance}}",
    "resources": [
        "arn:aws:cases:{{your Amazon Connect AWS Region}}:{{your AWS account ID}}:domain/{{case domain ID}}",
        "arn:aws:cases:{{your Amazon Connect AWS Region}}:{{your AWS account ID}}:domain/{{case domain ID}}/case/{{case ID}}/related-item/{{related-item ID}}"
    ],
    
    "detail": {   
        "version": "0",
        "eventType": "RELATED_ITEM.CREATED",
        "approximateChangeTime": "2022-03-16T23:16:57.893Z", // Can be used for ordering
        "changedAttributes": ["comment.commentText"],
        "performedBy": {
            "user": {
                "userArn": "arn:aws:connect:{{your Amazon Connect AWS Region}}:{{your AWS account ID}}:instance/{{connect instance ID}}/user/{{connect user ID}}"        
            },
            "iamPrincipalArn": "arn:aws:iam::{{your Amazon Connect AWS Region}}:role/{{role name}}"
        },        
        "relatedItem": {
            "relatedItemType": "Comment",
            "relatedItemId": "{{related-item ID}}",
            "caseId": "{{case id that this related item is a sub-resource of}}",
            "createdDateTime": "2022-03-16T23:16:57.893Z",
            
            // This section includes any attributes that customers have configured
            // in the "includedData" configuration.
            "comment": {               
                "body": "Gave a $5 refund to customer to make them happy",
            },
            
            // if the related item was of type contact.
            // "contact": {
            //      "contactArn": ".......",
            // }
        }
    }
}
```

## 自定义实体执行的案例资源的示例案例事件有效载荷
<a name="example-case-event-payload-case-resource-custom-entity"></a>

```
// Given the limits on the "includedData" configuration
// this payload is guaranteed to less than 256KB at launch.
{
    "version": "0",
    "id": "{{event ID}}",
    "detail-type": "Amazon Connect Cases Change",
    "source": "aws.cases",
    "account": "{{your AWS account ID}}",
    "time": "2022-03-16T23:43:26Z",
    "region": "{{The AWS Region of your Amazon Connect instance}}",
    "resources": [
        "arn:aws:cases:{{your Amazon Connect AWS Region:your AWS account ID}}:domain/{{case domain ID}}",
        "arn:aws:cases:{{your Amazon Connect AWS Region:your AWS account ID}}:domain/{{case domain ID}}/case/{{case ID}}"
    ],
    "detail": {
        "version": "0",
        "eventType": "CASE.UPDATED",
        "approximateChangeTime": "2022-03-16T23:16:57.893Z",  // Can be used for ordering
        "changedFieldIds": ["status", "last_updated_datetime"],
        "performedBy": {
            "user": {
                "customEntity": "{{your custom entity}}"        
            },
            "iamPrincipalArn": "arn:aws:iam::{{your Amazon Connect AWS Region}}:role/{{role name}}"
        },       
        "case": {
            "caseId": "{{case ID}}",
            "templateId": "{{template ID}}",
            "createdDateTime": "2022-03-16T23:16:57.893Z",
            
            // This section contains only non-null field values for the 
            // fields that customers have configured in the "includedData".
           
            // Field values included in this section reflects the case
            // after this particular change is applied.
            "fields": {
                "status": {
                    "value": {
                        "stringValue": "open"
                   }
                },
                "case_reason": {
                    "value": {
                        "stringValue": "Shipment lost"
                    }
                },
                "custom-field-uuid-1": {
                    "value": {
                        "stringValue": "Customer didn't receive the product"
                    }
                }
            }
        }
    }
}
```