def METHOD_NAME(
    lines: list[dict[str, Union[str, int]]],
    errors: list[dict[str, str]],
    error_code: str,
) -> dict[uuid.UUID, models.OrderGrantedRefundLine]:
    granted_refund_lines = {}
    for line in lines:
        order_line_id = cast(str, line["id"])
        try:
            _, pk = from_global_id_or_error(
                order_line_id, only_type="OrderLine", raise_error=True
            )
            uuid_pk = uuid.UUID(pk)
            reason = cast(Optional[str], line.get("reason"))
            granted_refund_lines[uuid_pk] = models.OrderGrantedRefundLine(
                order_line_id=uuid_pk,
                quantity=int(line["quantity"]),
                reason=reason,
            )
        except (GraphQLError, ValueError) as e:
            errors.append(
                {
                    "line_id": order_line_id,
                    "field": "id",
                    "code": error_code,
                    "message": str(e),
                }
            )
    return granted_refund_lines